From: Derick Rethans Date: Tue, 20 Dec 2005 16:01:21 +0000 (+0000) Subject: - MF51: Fixed bug #35699 (date() can't handle leap years before 1970) X-Git-Tag: RELEASE_1_0_4~305 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8e4e37ca9e2f867a9dd6f81a62e25a31e6179d75;p=php - MF51: Fixed bug #35699 (date() can't handle leap years before 1970) --- diff --git a/ext/date/lib/unixtime2tm.c b/ext/date/lib/unixtime2tm.c index 0187abbcfb..412f86f2bb 100644 --- a/ext/date/lib/unixtime2tm.c +++ b/ext/date/lib/unixtime2tm.c @@ -93,6 +93,9 @@ void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts) DEBUG(printf("tmp_days=%lld, year=%lld\n", tmp_days, cur_year);); months = timelib_is_leap(cur_year) ? month_tab_leap : month_tab; + if (timelib_is_leap(cur_year) && cur_year < 1970) { + tmp_days--; + } i = 11; while (i > 0) { DEBUG(printf("month=%lld (%d)\n", i, months[i]);); diff --git a/ext/date/tests/bug35699.phpt b/ext/date/tests/bug35699.phpt new file mode 100644 index 0000000000..5e4951e9fc --- /dev/null +++ b/ext/date/tests/bug35699.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #35699 (date() can't handle leap years before 1970) +--FILE-- + +--EXPECT-- +1964-06-06T00:00:00+0000 +1963-06-06T00:00:00+0000 +1964-01-06T00:00:00+0000