Skip to content

Commit

Permalink
- Fixed bug #35699 (date() can't handle leap years before 1970).
Browse files Browse the repository at this point in the history
  • Loading branch information
Derick Rethans committed Dec 20, 2005
1 parent 3450841 commit 97ec0f3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ PHP NEWS
options like '-1'). (Tony)
- Fixed bug #35705 (strtotime() fails to parse soap date format without TZ).
(Ilia)
- Fixed bug #35699 (date() can't handle leap years before 1970). (Derick)
- Fixed bug #35694 (Improved error message for invalid fetch mode). (Ilia)
- Fixed bug #35692 (iconv_mime_decode() segmentation fault; with libiconv
only). (Tony)
Expand Down
3 changes: 3 additions & 0 deletions ext/date/lib/unixtime2tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]););
Expand Down
14 changes: 14 additions & 0 deletions ext/date/tests/bug35699.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Bug #35699 (date() can't handle leap years before 1970)
--FILE--
<?php
date_default_timezone_set("UTC");

echo date(DATE_ISO8601, strtotime('1964-06-06')), "\n";
echo date(DATE_ISO8601, strtotime('1963-06-06')), "\n";
echo date(DATE_ISO8601, strtotime('1964-01-06')), "\n";
?>
--EXPECT--
1964-06-06T00:00:00+0000
1963-06-06T00:00:00+0000
1964-01-06T00:00:00+0000

0 comments on commit 97ec0f3

Please sign in to comment.