Re: [SMARTY-DEV] html_select_date bug - maybe ?

From: Date: Wed, 10 Dec 2003 18:02:17 +0000
Subject: Re: [SMARTY-DEV] html_select_date bug - maybe ?
References: 1 2 3 4  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-1965@lists.php.net to get a copy of this message
This is how the preg would be modified so month or day could be 1 or 2 digits: preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $time) I didn't test its impact though... Monte On Wed, 2003-12-10 at 11:37, pete M wrote: > OOps my error - was giving yyyy-mm-d when day <10. > > could this snip in html_date-select be modified to accomodate single > digit month or year or would this break the standard ? (no a preg_match > gure) > > if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $time)) { > // then $time is empty or unix timestamp or mysql timestamp > // using smarty_make_timestamp to get an unix timestamp and > // strftime to make yyyy-mm-dd > $time = strftime('%Y-%m-%d', smarty_make_timestamp($time)); > } > > regards > pete > > Messju Mohr wrote: > > > to my knowledge it uses smarty_make_timestamp which uses strottime > > *only* when no time-attribute in the format "YYYY-MM-DD" is given. > > > > so if you pass a time-attribute in the correct format it should work > > fine for dates before 1970. that's what my tests tell me. > > > > greetings > > messju > > > > On Wed, Dec 10, 2003 at 11:14:22AM -0600, Monte Ohrt wrote: > > > >>It uses strtotime(), so only 1970-2038 dates work correctly. It wouldn't > >>be so difficult to create a replacement plugin that uses Date_Calc from > >>PEAR, which is consequently a library I contributed some time back. :) > >> > >>Monte > >> > >>On Wed, 2003-12-10 at 10:13, pete M wrote: > >> > >>>smarty 2.5.0 > >>> > >>>I'm using html_select_date to enter peoples birth dates in my application. > >>> > >>>I understand the problem with epoch time and have used the format > >>>'yyyy-mm-dd' to store in database/variable/etc and using a modified > >>>version of 'date_format' to present the date. > >>> > >>>However 'html_select_date' gives spurious date/month values pre > >>>1970's > >>> > >>>eg giving 1945-02-01 to html_select_date displays 1945-01-01 > >>> > >>>Indeed anything pre 1970's seems to give spurios errors with the date or > >>>month values (year seems to be correct) > >>> > >>>Is this because the timestamp is not handled correctly or should I not > >>>be using html_select_date for pre 1970 ?? > >>> > >>>Hope it makes sense > >>> > >>>tia > >>> > >>>Pete > >> > >>-- > >>Smarty Development Mailing List (http://smarty.php.net/) > >>To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.smarty.dev (#1965) next »