From: Derick Rethans Date: Thu, 1 Sep 2005 12:42:39 +0000 (+0000) Subject: - MFH: Fixed bug #33414 (Comprehensive list of incorrect days returned after X-Git-Tag: php-5.1.0RC2_PRE~35 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9057102e6e5f9d8c29b73b4c694895c1e670c551;p=php - MFH: Fixed bug #33414 (Comprehensive list of incorrect days returned after strtotime() / date() tests). --- diff --git a/NEWS b/NEWS index 525ff3e2c0..9b66df521a 100644 --- a/NEWS +++ b/NEWS @@ -76,6 +76,8 @@ PHP NEWS - Fixed bug #33578 (strtotime() problem with "Oct17" format). (Derick) - Fixed bug #33558 (warning with nested calls to functions returning by reference). (Dmitry) +- Fixed bug #33414 (Comprehensive list of incorrect days returned after + strtotime() / date() tests). (Derick) - Fixed bug #33326 (Cannot build extensions with phpize on Macosx). (Jani) - Fixed bug #32981 (ReflectionMethod::getStaticVariables() causes apache2.0.54 seg fault). (Dmitry) diff --git a/ext/date/lib/parse_tz.c b/ext/date/lib/parse_tz.c index deaef0a069..7a6e683eb1 100644 --- a/ext/date/lib/parse_tz.c +++ b/ext/date/lib/parse_tz.c @@ -164,6 +164,15 @@ void timelib_dump_tzinfo(timelib_tzinfo *tz) printf("Local types count: %lu\n", (unsigned long) tz->typecnt); printf("Zone Abbr. count: %lu\n", (unsigned long) tz->charcnt); + printf ("%8s (%12s) = %3d [%5ld %1d %3d '%s' (%d,%d)]\n", + "", "", 0, + (long int) tz->type[0].offset, + tz->type[0].isdst, + tz->type[0].abbr_idx, + &tz->timezone_abbr[tz->type[0].abbr_idx], + tz->type[0].isstdcnt, + tz->type[0].isgmtcnt + ); for (i = 0; i < tz->timecnt; i++) { printf ("%08X (%12d) = %3d [%5ld %1d %3d '%s' (%d,%d)]\n", tz->trans[i], tz->trans[i], tz->trans_idx[i], @@ -244,6 +253,8 @@ static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts, timelib { uint32_t i; + /* If there is no transistion time, we pick the first one, if that doesn't + * exist we return NULL */ if (!tz->timecnt || !tz->trans) { *transition_time = 0; if (tz->typecnt == 1) { @@ -252,10 +263,26 @@ static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts, timelib return NULL; } + /* If the TS is lower than the first transistion time, then we scan over + * all the transistion times to find the first non-DST one, or the first + * one in case there are only DST entries. Not sure which smartass came up + * with this idea in the first though :) */ if (ts < tz->trans[0]) { + uint32_t j; + *transition_time = 0; - return &(tz->type[tz->trans_idx[tz->timecnt - 1]]); + j = 0; + while (j < tz->timecnt && tz->type[j].isdst) { + ++j; + } + if (j == tz->timecnt) { + j = 0; + } + return &(tz->type[j]); } + + /* In all other cases we loop through the available transtion times to find + * the correct entry */ for (i = 0; i < tz->timecnt; i++) { if (ts < tz->trans[i]) { *transition_time = tz->trans[i - 1]; diff --git a/ext/date/tests/bug33414-2.phpt b/ext/date/tests/bug33414-2.phpt index 7f8e7b675c..d037e6dc35 100644 --- a/ext/date/tests/bug33414-2.phpt +++ b/ext/date/tests/bug33414-2.phpt @@ -106,8 +106,8 @@ result=Tuesday 2005-04-12 00:00:00 CDT 1 wanted=Tuesday 00:00:00 TZ=Pacific/Pitcairn - wrong day. -tStamp=Thursday 1970-01-01 17:17:17 PST 0 -result=Wednesday 1970-01-06 00:00:00 PST 0 +tStamp=Thursday 1970-01-01 17:17:17 PNT 0 +result=Wednesday 1970-01-07 00:00:00 PNT 0 wanted=Wednesday 00:00:00 TZ=Pacific/Fakaofo - wrong day.