html_select_date bug and patch
| From: | Konstantin Pelepelin | Date: | Tue, 20 Jul 2004 12:17:54 +0000 |
| Subject: | html_select_date bug and patch | ||
| References: | 1 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-2504@lists.php.net to get a copy of this message | ||
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