html_select_date bug and patch

"Konstantin Pelepelin" <[email protected]>
Newsgroups gmane.comp.php.smarty.devel
Organization DTF
Message-ID <[email protected]>
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
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.