logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

html_select_date bug and patch: msg#00072

Subject: html_select_date bug and patch
Hi!

html_select_date doesn't show the specified year if it is outside of assumed 
range (or range not specified).
I think it should.

Example:
{html_select_date time='2020-01-01' start_year="1990" end_year="2010" 
field_order="YMD"}
Shows 1990 instead of 2020.

Proposed patch:
================
diff -u -r1.24 function.html_select_date.php
--- function.html_select_date.php       12 Jul 2004 15:24:43 -0000      1.24
+++ function.html_select_date.php       20 Jul 2004 12:02:05 -0000
@@ -241,6 +241,17 @@
             $year_result .= '>';
         } else {
             $years = range((int)$start_year, (int)$end_year);
+            if(is_numeric($time[0]) && ((int)$time[0]<(int)$start_year || 
(int)$time[0]>(int)$end_year))
+            {
+                if($reverse_years || (int)$time[0]>(int)$end_year)
+                {
+                    $years[]=(int)$time[0];
+                }
+                else
+                {
+                    array_unshift($years,(int)$time[0]);
+                }
+            }
             if ($reverse_years) {
                 rsort($years, SORT_NUMERIC);
             }
================

In original function it is supposed that start_year<=end_year, so I don't check 
it, too.

BR,
Konstantin Pelepelin

--
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>