ID: 32086 User updated by: marcus at corp dot grupos dot com dot br Reported By: marcus at corp dot grupos dot com dot br Status: Assigned Bug Type: Date/time related -Operating System: FreeBSD 4.11-STABLE +Operating System: FreeBSD 4.x -PHP Version: 4.3.10 +PHP Version: 4.x, 5.x Assigned To: derick New Comment:
Any idea to fix? Regards Previous Comments: ------------------------------------------------------------------------ [2005-02-23 22:01:34] marcus at corp dot grupos dot com dot br Description: ------------ If timestamp don't exist, FreeBSD mktime() return -1 is correct. This case occurs when use strtotime and have Daylight Save Time in timezone. Example: If DST save 1 hour and begin on 2004/11/02 00:00, timestamp between 00:00 and 01:00 don't exists. I fix with this patch, but I find that it is not the best skill. -- begin patch -- --- ext/standard/parsedate.c.orig Tue Dec 14 15:55:22 2004 +++ ext/standard/parsedate.c Mon Feb 14 14:43:08 2005 @@ -2211,9 +2211,9 @@ date.yyHaveTime = 0; date.yyHaveZone = 0; - if (yyparse ((void *)&date) - || date.yyHaveTime > 1 || date.yyHaveZone > 1 - || date.yyHaveDate > 1 || date.yyHaveDay > 1) + if (yyparse ((void *)&date)) +// || date.yyHaveTime > 1 || date.yyHaveZone > 1 +// || date.yyHaveDate > 1 || date.yyHaveDay > 1) return -1; tm.tm_year = ToYear (date.yyYear) - TM_YEAR_ORIGIN + date.yyRelYear; @@ -2272,7 +2272,28 @@ } if (Start == (time_t) -1) - return Start; + { + tm = tm0; + while((Start = mktime(&tm)) == -1 && tm.tm_year > 68 && tm.tm_year < 138) + { + if (tm.tm_isdst == 0) + { + tm.tm_isdst = -1; + if (tm.tm_min < 59) { + tm.tm_min += 1; + } else { + tm.tm_min = 0; + if (tm.tm_hour < 23) { + tm.tm_hour += 1; + } else { + tm.tm_hour = 0; + tm.tm_mday += 1; + } + } + } + } + return Start; + } } if (date.yyHaveDay && !date.yyHaveDate) -- end patch -- Reproduce code: --------------- <?php putenv("TZ=America/Sao_Paulo"); echo $i = strtotime("2004-11-01"), "\n"; echo strtotime("+1 day", $i), "\n"; echo $i = strtotime("2005-02-19"), "\n"; echo strtotime("+1 day", $i), "\n"; ?> America/Sao_Paulo DST begin on 2004/11/02 00:00 and terminate on 2005/02/20 00:00 Expected result: ---------------- 1099278000 1099364400 1108778400 1108864800 Actual result: -------------- 1099278000 -1 1108778400 1108864800 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32086&edit=1