Re: [SMARTY-DEV] function.html_select_date.php bug?
[email protected] ("messju mohr") Thu, 7 Apr 2005 20:09:26 +0200
| Newsgroups | php.smarty.dev |
|---|---|
| Message-ID | <20050407180925.GA22876@dune> |
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. > You could also use (int) $time[1] instead of $time[1] > 0 FYI: it's fixed in cvs. thank you! greetings messju > Greetings, > > Yuri > > -- > Smarty Development Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php