From 7411ae09f5565b3f0dfbbfeb71c8f848fd38d6ca Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Thu, 24 Nov 2011 17:13:47 +0000 Subject: [PATCH] - Fixed bug #60236 (TLA timezone dates are not converted properly from timestamp). - Fixed bug #55253 (DateTime::add() and sub() result -1 hour on objects with time zone type 2). And fixed some test cases. --- NEWS | 8 +++++++- ext/date/lib/unixtime2tm.c | 4 ++-- ext/date/tests/bug55253.phpt | 4 +--- ext/date/tests/bug60236.phpt | 20 +++++++++++++++++++ .../tests/date_default_timezone_get-1.phpt | 8 ++++---- .../tests/date_default_timezone_get-2.phpt | 4 ++-- ext/date/tests/mktime-2.phpt | 4 ---- ...tetime_and_daylight_saving_time-type2.phpt | 2 -- 8 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 ext/date/tests/bug60236.phpt diff --git a/NEWS b/NEWS index c646136c22617..39373d9d40e17 100644 --- a/NEWS +++ b/NEWS @@ -24,7 +24,13 @@ PHP NEWS . Added .phar to default authorized extensions. (fat) - BCmath: - . Fixed bug #60377 (bcscale related crashes on 64bits platforms) (shm) + . Fixed bug #60377 (bcscale related crashes on 64bits platforms). (shm) + +- Date: + . Fixed bug #60236 (TLA timezone dates are not converted properly from + timestamp). (Derick) + . Fixed bug #55253 (DateTime::add() and sub() result -1 hour on objects with + time zone type 2). (Derick) - EXIF: . Fixed bug #60150 (Integer overflow during the parsing of invalid exif diff --git a/ext/date/lib/unixtime2tm.c b/ext/date/lib/unixtime2tm.c index 871fa2f5e515e..a76fa80991ebf 100644 --- a/ext/date/lib/unixtime2tm.c +++ b/ext/date/lib/unixtime2tm.c @@ -146,7 +146,7 @@ void timelib_update_from_sse(timelib_time *tm) int z = tm->z; signed int dst = tm->dst; - timelib_unixtime2gmt(tm, tm->sse - (tm->z * 60)); + timelib_unixtime2gmt(tm, tm->sse - (tm->z * 60) + (tm->dst * 3600)); tm->z = z; tm->dst = dst; @@ -184,7 +184,7 @@ void timelib_unixtime2local(timelib_time *tm, timelib_sll ts) int z = tm->z; signed int dst = tm->dst; - timelib_unixtime2gmt(tm, ts - (tm->z * 60)); + timelib_unixtime2gmt(tm, ts - (tm->z * 60) + (tm->dst * 3600)); tm->z = z; tm->dst = dst; diff --git a/ext/date/tests/bug55253.phpt b/ext/date/tests/bug55253.phpt index 3c0efc4691dd3..3b2b42bc2622a 100755 --- a/ext/date/tests/bug55253.phpt +++ b/ext/date/tests/bug55253.phpt @@ -1,9 +1,7 @@ --TEST-- -DateTime::add() and sub() result -1 hour on objects with time zone type 2 +Bug #55253: DateTime::add() and sub() result -1 hour on objects with time zone type 2 --CREDITS-- Daniel Convissor ---XFAIL-- -Bug 55253 exists --FILE-- format('U'); +var_dump($ts); +$t->setTimestamp($ts); +var_dump($t); +?> +--EXPECT-- +string(10) "1278455908" +object(DateTime)#1 (3) { + ["date"]=> + string(19) "2010-07-06 18:38:28" + ["timezone_type"]=> + int(2) + ["timezone"]=> + string(3) "EDT" +} diff --git a/ext/date/tests/date_default_timezone_get-1.phpt b/ext/date/tests/date_default_timezone_get-1.phpt index d8d95a03651b7..383394a955a73 100644 --- a/ext/date/tests/date_default_timezone_get-1.phpt +++ b/ext/date/tests/date_default_timezone_get-1.phpt @@ -9,8 +9,8 @@ date.timezone= echo date('e'), "\n"; ?> --EXPECTF-- -Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected '%s' for '%s' instead in %sdate_default_timezone_get-1.php on line 3 -%s +Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in %sdate_default_timezone_get-1.php on line 3 +UTC -Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected '%s' for '%s' instead in %sdate_default_timezone_get-1.php on line 4 -%s +Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in %sdate_default_timezone_get-1.php on line 4 +UTC diff --git a/ext/date/tests/date_default_timezone_get-2.phpt b/ext/date/tests/date_default_timezone_get-2.phpt index bdef81b38d6b0..11bd3070a0eb9 100644 --- a/ext/date/tests/date_default_timezone_get-2.phpt +++ b/ext/date/tests/date_default_timezone_get-2.phpt @@ -8,5 +8,5 @@ date.timezone= echo date_default_timezone_get(), "\n"; ?> --EXPECTF-- -Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected '%s' for '%s' instead in %sdate_default_timezone_get-2.php on line 3 -%s +Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in %sdate_default_timezone_get-2.php on line 3 +UTC diff --git a/ext/date/tests/mktime-2.phpt b/ext/date/tests/mktime-2.phpt index 5ba6bd6c16151..aa259b577cab7 100644 --- a/ext/date/tests/mktime-2.phpt +++ b/ext/date/tests/mktime-2.phpt @@ -1,9 +1,5 @@ --TEST-- mktime() [2] ---SKIPIF-- - --INI-- error_reporting=2047 --FILE-- diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type2.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type2.phpt index 5813602513624..72585125ea6d8 100644 --- a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type2.phpt +++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type2.phpt @@ -2,8 +2,6 @@ RFC: DateTime and Daylight Saving Time Transitions (zone type 2) --CREDITS-- Daniel Convissor ---XFAIL-- -RFC not implemented yet --FILE--