cvs: smarty / NEWS /libs/plugins function.html_select_date.php

"Messju Mohr" <[email protected]>
Newsgroups gmane.comp.php.cvs.smarty
Message-ID <cvsmessju1076715488@cvsserver>
messju		Fri Feb 13 18:38:08 2004 EDT

  Modified files:              
    /smarty	NEWS 
    /smarty/libs/plugins	function.html_select_date.php 
  Log:
  correctly handle partially empty dates (like "2004--" or "-12-").
  
  
  
http://cvs.php.net/diff.php/smarty/NEWS?r1=1.435&r2=1.436&ty=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.435 smarty/NEWS:1.436
--- smarty/NEWS:1.435	Thu Feb 12 06:28:49 2004
+++ smarty/NEWS	Fri Feb 13 18:38:07 2004
@@ -1,3 +1,5 @@
+  - fix allow empty years, months and days in html_select_date's
+    time-attribute (messju)
   - fix YES and NO should not be booleanized inside triple-quotes in a
     config-file (messju)
   - fix accidently slurped line following a triple-quoted value in a
http://cvs.php.net/diff.php/smarty/libs/plugins/function.html_select_date.php?r1=1.21&r2=1.22&ty=u
Index: smarty/libs/plugins/function.html_select_date.php
diff -u smarty/libs/plugins/function.html_select_date.php:1.21 smarty/libs/plugins/function.html_select_date.php:1.22
--- smarty/libs/plugins/function.html_select_date.php:1.21	Wed Dec 17 05:45:57 2003
+++ smarty/libs/plugins/function.html_select_date.php	Fri Feb 13 18:38:08 2004
@@ -123,7 +123,7 @@
     }
 
     // If $time is not in format yyyy-mm-dd
-    if (!preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $time) && $time!='--') {
+    if (!preg_match('/^\d{0,4}-\d{0,2}-\d{0,2}$/', $time)) {
         // then $time is empty or unix timestamp or mysql timestamp
         // using smarty_make_timestamp to get an unix timestamp and
         // strftime to make yyyy-mm-dd
@@ -160,8 +160,8 @@
             $month_values[''] = '';
         }
         for ($i = 1; $i <= 12; $i++) {
-            $month_names[] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
-            $month_values[] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
+            $month_names[$i] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
+            $month_values[$i] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
         }
 
         $month_result .= '<select name=';
@@ -183,7 +183,7 @@
 
         $month_result .= smarty_function_html_options(array('output'     => $month_names,
                                                             'values'     => $month_values,
-                                                            'selected'   => $month_values[$time[1]-1],
+                                                            'selected'   => $month_values[(int)$time[1]],
                                                             'print_result' => false),
                                                       $smarty);
 

-- 
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.