Re: [SMARTY-DEV] function.html_select_date.php bug?
| From: | messju mohr | Date: | Fri, 25 Mar 2005 11:39:38 +0000 |
| Subject: | Re: [SMARTY-DEV] function.html_select_date.php bug? | ||
| References: | 1 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-2680@lists.php.net to get a copy of this message | ||
On Fri, Mar 25, 2005 at 10:27:54AM +0100, Yuri Weseman wrote:
> Hi,
>
>
> http://cvs.php.net/co.php/smarty/libs/plugins/function.html_select_date.php?r=1.29#201
>
> I think there's a bug in this line. It now reads:
> 'selected' => $a=$time[1] ? strftime($month_value_format, mktime(0,
> 0, 0, (int)$time[1], 1, 2000)) : '',
>
> I think this would be better:
>
> 'selected' => $time[1]>0 ? strftime($month_value_format, mktime(0,
> 0, 0, (int)$time[1], 1, 2000)) : '',
>
> I don't understand why $a should be assigned as it is isn't used later
> on in the code. And because $time[1] doesn't always have to be 0 (as
> is the case when your date comes out of the database like 0000-00-00)
> this results in december to be selected.
> To explain this: The value of $time[1] is 00 then, which results in
> true for the check $a=$time[1], which results in
> strftime($month_value_format, mktime(0, 0, 0, (int)$time[1], 1, 2000))
> being executed. And because mktime sees (int)$time[1] as 0, it thinks
> it should selected the last month of the previous year resulting in
> december to be selected.
this sounds very reasonable to me. if nobody objects i like to commit
your suggested fix.
greetings
messju
> You could also use (int) $time[1] instead of $time[1] > 0
>
> Greetings,
>
> Yuri
>
> --
> Smarty Development Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php