diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ext/date/lib/parse_tz.c | 3 | ||||
-rw-r--r-- | ext/date/tests/bug33414-1.phpt | 320 | ||||
-rw-r--r-- | ext/date/tests/bug33414-2.phpt | 121 | ||||
-rw-r--r-- | ext/date/tests/bug33415-1.phpt | 33 | ||||
-rw-r--r-- | ext/date/tests/bug33415-2.phpt | 342 |
6 files changed, 820 insertions, 0 deletions
@@ -6,6 +6,7 @@ PHP NEWS - Fixed bug #33475 (cURL handle is not closed on curl_close(). (Ilia) - Fixed bug #33469 (Compile error undefined reference to ifx_checkAPI). (Jani) - Fixed bug #33433 (strtoll not available on Tru64). (Jani, Derick) +- Fixed bug #33415 (strtotime() related bugs). (Derick) - Fixed bug #32660 (Assignment by reference causes crash when field access is overloaded (__get)). (Dmitry) - Fixed bug #31358 (Older GCC versions do not provide portable va_copy()). diff --git a/ext/date/lib/parse_tz.c b/ext/date/lib/parse_tz.c index 69bf196393..11df4d92ae 100644 --- a/ext/date/lib/parse_tz.c +++ b/ext/date/lib/parse_tz.c @@ -241,6 +241,9 @@ static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts, timelib uint32_t i; if (!tz->timecnt || !tz->trans) { + if (tz->typecnt == 1) { + return &(tz->type[0]); + } return NULL; } diff --git a/ext/date/tests/bug33414-1.phpt b/ext/date/tests/bug33414-1.phpt new file mode 100644 index 0000000000..cbb6b5f5c9 --- /dev/null +++ b/ext/date/tests/bug33414-1.phpt @@ -0,0 +1,320 @@ +--TEST-- +Bug #33414 [1] (Comprehensive list of incorrect days returned after strotime() / date() tests) +--FILE-- +<?php + +print "TZ=America/Mendoza - wrong day.\n"; +putenv("TZ=America/Mendoza"); +$tStamp = mktime (17, 17, 17, 1, 8327, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Sunday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Sunday 00:00:00\n\n"; + +print "TZ=America/Catamarca - wrong day.\n"; +putenv("TZ=America/Catamarca"); +$tStamp = mktime (17, 17, 17, 1, 7599, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Sunday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Sunday 00:00:00\n\n"; + +print "TZ=America/Cordoba - wrong day.\n"; +putenv("TZ=America/Cordoba"); +$tStamp = mktime (17, 17, 17, 1, 7599, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Sunday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Sunday 00:00:00\n\n"; + +print "TZ=America/Rosario - wrong day.\n"; +putenv("TZ=America/Rosario"); +$tStamp = mktime (17, 17, 17, 1, 7958, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Tuesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Tuesday 00:00:00\n\n"; + +print "TZ=Europe/Vienna - wrong day - giving unexpected results, at +least on my system :-)\n"; +putenv("TZ=Europe/Vienna"); +$tStamp = mktime (17, 17, 17, 1, 3746, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Thursday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Thursday 00:00:00\n\n"; + +print "TZ=Asia/Baku - wrong day.\n"; +putenv("TZ=Asia/Baku"); +$tStamp = mktime (17, 17, 17, 1, 8299, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Sunday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Sunday 00:00:00\n\n"; + +print "TZ=America/Noronha - wrong day.\n"; +putenv("TZ=America/Noronha"); +$tStamp = mktime (17, 17, 17, 1, 10866, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Friday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Friday 00:00:00\n\n"; + +print "TZ=America/Havana - wrong day.\n"; +putenv("TZ=America/Havana"); +$tStamp = mktime (17, 17, 17, 1, 12720, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Thursday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Thursday 00:00:00\n\n"; + +print "TZ=Europe/Tallinn - wrong day.\n"; +putenv("TZ=Europe/Tallinn"); +$tStamp = mktime (17, 17, 17, 1, 11777, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Saturday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Saturday 00:00:00\n\n"; + +print "TZ=Asia/Jerusalem - wrong day.\n"; +putenv("TZ=Asia/Jerusalem"); +$tStamp = mktime (17, 17, 17, 1, 13056, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Thursday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Thursday 00:00:00\n\n"; + +print "TZ=Europe/Vilnius - wrong day.\n"; +putenv("TZ=Europe/Vilnius"); +$tStamp = mktime (17, 17, 17, 1, 12140, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Friday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Friday 00:00:00\n\n"; + +print "TZ=Pacific/Kwajalein - wrong day.\n"; +putenv("TZ=Pacific/Kwajalein"); +$tStamp = mktime (17, 17, 17, 1, 8626, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Friday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Friday 00:00:00\n\n"; + +print "TZ=Asia/Ulan_Bator - wrong day.\n"; +putenv("TZ=Asia/Ulan_Bator"); +$tStamp = mktime (17, 17, 17, 1, 11588, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Saturday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Saturday 00:00:00\n\n"; + +print "TZ=America/Cancun - wrong day.\n"; +putenv("TZ=America/Cancun"); +$tStamp = mktime (17, 17, 17, 1, 11785, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Sunday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Sunday 00:00:00\n\n"; + +print "TZ=America/Mexico_City - wrong day.\n"; +putenv("TZ=America/Mexico_City"); +$tStamp = mktime (17, 17, 17, 1, 11781, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Wednesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Wednesday 00:00:00\n\n"; + +print "TZ=America/Mazatlan - wrong day.\n"; +putenv("TZ=America/Mazatlan"); +$tStamp = mktime (17, 17, 17, 1, 11780, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Tuesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Tuesday 00:00:00\n\n"; + +print "TZ=America/Chihuahua - wrong day.\n"; +putenv("TZ=America/Chihuahua"); +$tStamp = mktime (17, 17, 17, 1, 11782, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Thursday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Thursday 00:00:00\n\n"; + +print "TZ=Asia/Kuala_Lumpur - wrong day.\n"; +putenv("TZ=Asia/Kuala_Lumpur"); +$tStamp = mktime (17, 17, 17, 1, 4380, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Monday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Monday 00:00:00\n\n"; + +print "TZ=Pacific/Chatham - wrong day.\n"; +putenv("TZ=Pacific/Chatham"); +$tStamp = mktime (17, 17, 17, 1, 1762, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Monday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Monday 00:00:00\n\n"; + +print "TZ=America/Lima - wrong day.\n"; +putenv("TZ=America/Lima"); +$tStamp = mktime (17, 17, 17, 1, 5839, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Thursday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Thursday 00:00:00\n\n"; + +print "TZ=Asia/Karachi - wrong day.\n"; +putenv("TZ=Asia/Karachi"); +$tStamp = mktime (17, 17, 17, 1, 11783, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Friday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Friday 00:00:00\n\n"; + +print "TZ=America/Asuncion - wrong day.\n"; +putenv("TZ=America/Asuncion"); +$tStamp = mktime (17, 17, 17, 1, 11746, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Wednesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Wednesday 00:00:00\n\n"; + +print "TZ=Asia/Singapore - wrong day.\n"; +putenv("TZ=Asia/Singapore"); +$tStamp = mktime (17, 17, 17, 1, 4383, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Thursday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Thursday 00:00:00\n\n"; + +print "TZ=America/Montevideo - wrong day.\n"; +putenv("TZ=America/Montevideo"); +$tStamp = mktime (17, 17, 17, 1, 12678, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Thursday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Thursday 00:00:00\n\n"; + +?> +--EXPECT-- +TZ=America/Mendoza - wrong day. +tStamp=Sunday 1992-10-18 17:17:17 ARST 1 +result=Sunday 1992-10-25 00:00:00 ARST 1 +wanted=Sunday 00:00:00 + +TZ=America/Catamarca - wrong day. +tStamp=Sunday 1990-10-21 17:17:17 ARST 1 +result=Sunday 1990-10-28 00:00:00 ARST 1 +wanted=Sunday 00:00:00 + +TZ=America/Cordoba - wrong day. +tStamp=Sunday 1990-10-21 17:17:17 ARST 1 +result=Sunday 1990-10-28 00:00:00 ARST 1 +wanted=Sunday 00:00:00 + +TZ=America/Rosario - wrong day. +tStamp=Tuesday 1991-10-15 17:17:17 WART 0 +result=Tuesday 1991-10-22 00:00:00 ARST 1 +wanted=Tuesday 00:00:00 + +TZ=Europe/Vienna - wrong day - giving unexpected results, at +least on my system :-) +tStamp=Thursday 1980-04-03 17:17:17 CET 0 +result=Thursday 1980-04-10 00:00:00 CEST 1 +wanted=Thursday 00:00:00 + +TZ=Asia/Baku - wrong day. +tStamp=Sunday 1992-09-20 17:17:17 AZST 1 +result=Sunday 1992-09-27 00:00:00 AZT 0 +wanted=Sunday 00:00:00 + +TZ=America/Noronha - wrong day. +tStamp=Friday 1999-10-01 17:17:17 FNT 0 +result=Friday 1999-10-08 00:00:00 FNST 1 +wanted=Friday 00:00:00 + +TZ=America/Havana - wrong day. +tStamp=Thursday 2004-10-28 17:17:17 CDT 1 +result=Thursday 2004-11-04 00:00:00 CDT 1 +wanted=Thursday 00:00:00 + +TZ=Europe/Tallinn - wrong day. +tStamp=Saturday 2002-03-30 17:17:17 EET 0 +result=Saturday 2002-04-06 00:00:00 EEST 1 +wanted=Saturday 00:00:00 + +TZ=Asia/Jerusalem - wrong day. +tStamp=Thursday 2005-09-29 17:17:17 IDT 1 +result=Thursday 2005-10-06 00:00:00 IDT 1 +wanted=Thursday 00:00:00 + +TZ=Europe/Vilnius - wrong day. +tStamp=Friday 2003-03-28 17:17:17 EET 0 +result=Friday 2003-04-04 00:00:00 EEST 1 +wanted=Friday 00:00:00 + +TZ=Pacific/Kwajalein - wrong day. +tStamp=Friday 1993-08-13 17:17:17 KWAT 0 +result=Saturday 1993-08-21 00:00:00 MHT 0 +wanted=Friday 00:00:00 + +TZ=Asia/Ulan_Bator - wrong day. +tStamp=Saturday 2001-09-22 17:17:17 ULAST 1 +result=Saturday 2001-09-29 00:00:00 ULAST 1 +wanted=Saturday 00:00:00 + +TZ=America/Cancun - wrong day. +tStamp=Sunday 2002-04-07 17:17:17 CDT 1 +result=Sunday 2002-04-14 00:00:00 CDT 1 +wanted=Sunday 00:00:00 + +TZ=America/Mexico_City - wrong day. +tStamp=Wednesday 2002-04-03 17:17:17 CST 0 +result=Wednesday 2002-04-10 00:00:00 CDT 1 +wanted=Wednesday 00:00:00 + +TZ=America/Mazatlan - wrong day. +tStamp=Tuesday 2002-04-02 17:17:17 MST 0 +result=Tuesday 2002-04-09 00:00:00 MDT 1 +wanted=Tuesday 00:00:00 + +TZ=America/Chihuahua - wrong day. +tStamp=Thursday 2002-04-04 17:17:17 MST 0 +result=Thursday 2002-04-11 00:00:00 MDT 1 +wanted=Thursday 00:00:00 + +TZ=Asia/Kuala_Lumpur - wrong day. +tStamp=Monday 1981-12-28 17:17:17 MALT 0 +result=Monday 1982-01-04 00:00:00 MYT 0 +wanted=Monday 00:00:00 + +TZ=Pacific/Chatham - wrong day. +tStamp=Monday 1974-10-28 17:17:17 CHAST 0 +result=Monday 1974-11-04 00:00:00 CHADT 1 +wanted=Monday 00:00:00 + +TZ=America/Lima - wrong day. +tStamp=Thursday 1985-12-26 17:17:17 PET 0 +result=Thursday 1986-01-02 00:00:00 PEST 1 +wanted=Thursday 00:00:00 + +TZ=Asia/Karachi - wrong day. +tStamp=Friday 2002-04-05 17:17:17 PKT 0 +result=Friday 2002-04-12 00:00:00 PKST 1 +wanted=Friday 00:00:00 + +TZ=America/Asuncion - wrong day. +tStamp=Wednesday 2002-02-27 17:17:17 PYST 1 +result=Wednesday 2002-03-06 00:00:00 PYST 1 +wanted=Wednesday 00:00:00 + +TZ=Asia/Singapore - wrong day. +tStamp=Thursday 1981-12-31 17:17:17 SGT 0 +result=Thursday 1982-01-07 00:00:00 SGT 0 +wanted=Thursday 00:00:00 + +TZ=America/Montevideo - wrong day. +tStamp=Thursday 2004-09-16 17:17:17 UYT 0 +result=Thursday 2004-09-23 00:00:00 UYST 1 +wanted=Thursday 00:00:00 diff --git a/ext/date/tests/bug33414-2.phpt b/ext/date/tests/bug33414-2.phpt new file mode 100644 index 0000000000..1567b18c77 --- /dev/null +++ b/ext/date/tests/bug33414-2.phpt @@ -0,0 +1,121 @@ +--TEST-- +Bug #33414 [2] (Comprehensive list of incorrect days returned after strotime() / date() tests) +--FILE-- +<?php +print "TZ=Pacific/Rarotonga - wrong day.\n"; +putenv("TZ=Pacific/Rarotonga"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Tuesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Tuesday 00:00:00\n\n"; + +print "TZ=Atlantic/South_Georgia - wrong day.\n"; +putenv("TZ=Atlantic/South_Georgia"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Tuesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Tuesday 00:00:00\n\n"; + +print "TZ=America/Port-au-Prince - wrong day.\n"; +putenv("TZ=America/Port-au-Prince"); +$tStamp = mktime (17, 17, 17, 1, 12871, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Monday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Monday 00:00:00\n\n"; + +print "TZ=Pacific/Enderbury - wrong day, off by 2 days.\n"; +putenv("TZ=Pacific/Enderbury"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Monday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Monday 00:00:00\n\n"; + +print "TZ=Pacific/Kiritimati - wrong day, off by 2 days.\n"; +putenv("TZ=Pacific/Kiritimati"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Monday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Monday 00:00:00\n\n"; + +print "TZ=America/Managua - wrong day.\n"; +putenv("TZ=America/Managua"); +$tStamp = mktime (17, 17, 17, 1, 12879, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Tuesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Tuesday 00:00:00\n\n"; + +print "TZ=Pacific/Pitcairn - wrong day.\n"; +putenv("TZ=Pacific/Pitcairn"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Wednesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Wednesday 00:00:00\n\n"; + +print "TZ=Pacific/Fakaofo - wrong day.\n"; +putenv("TZ=Pacific/Fakaofo"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Saturday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Saturday 00:00:00\n\n"; + +print "TZ=Pacific/Johnston - wrong day.\n"; +putenv("TZ=Pacific/Johnston"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Friday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Friday 00:00:00\n\n"; +?> +--EXPECT-- +TZ=Pacific/Rarotonga - wrong day. +tStamp=Thursday 1970-01-01 17:17:17 CKT 0 +result=Tuesday 1970-01-06 00:00:00 CKT 0 +wanted=Tuesday 00:00:00 + +TZ=Atlantic/South_Georgia - wrong day. +tStamp=Thursday 1970-01-01 17:17:17 GST 0 +result=Tuesday 1970-01-06 00:00:00 GST 0 +wanted=Tuesday 00:00:00 + +TZ=America/Port-au-Prince - wrong day. +tStamp=Monday 2005-03-28 17:17:17 EST 0 +result=Monday 2005-04-04 00:00:00 EST 0 +wanted=Monday 00:00:00 + +TZ=Pacific/Enderbury - wrong day, off by 2 days. +tStamp=Thursday 1970-01-01 17:17:17 PHOT 0 +result=Monday 1970-01-05 00:00:00 PHOT 0 +wanted=Monday 00:00:00 + +TZ=Pacific/Kiritimati - wrong day, off by 2 days. +tStamp=Thursday 1970-01-01 17:17:17 LINT 0 +result=Monday 1970-01-05 00:00:00 LINT 0 +wanted=Monday 00:00:00 + +TZ=America/Managua - wrong day. +tStamp=Tuesday 2005-04-05 17:17:17 CST 0 +result=Tuesday 2005-04-12 00:00:00 CST 0 +wanted=Tuesday 00:00:00 + +TZ=Pacific/Pitcairn - wrong day. +tStamp=Thursday 1970-01-01 17:17:17 PNT 0 +result=Wednesday 1970-01-06 00:00:00 PNT 0 +wanted=Wednesday 00:00:00 + +TZ=Pacific/Fakaofo - wrong day. +tStamp=Thursday 1970-01-01 17:17:17 TKT 0 +result=Saturday 1970-01-03 00:00:00 TKT 0 +wanted=Saturday 00:00:00 + +TZ=Pacific/Johnston - wrong day. +tStamp=Thursday 1970-01-01 17:17:17 HST 0 +result=Friday 1970-01-02 00:00:00 HST 0 +wanted=Friday 00:00:00 diff --git a/ext/date/tests/bug33415-1.phpt b/ext/date/tests/bug33415-1.phpt new file mode 100644 index 0000000000..9642811040 --- /dev/null +++ b/ext/date/tests/bug33415-1.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #33415 [1] (Possibly invalid non-one-hour DST or timezone shifts) +--FILE-- +<?php + +print "TZ=America/Jujuy - Is it OK for this to be 2 AM, rather than 1 +AM as per most DST transitions?\n"; +putenv("TZ=America/Jujuy"); +$tStamp = mktime (17, 17, 17, 1, 7593, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Monday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Monday 00:00:00\n\n"; + +print "TZ=Asia/Tbilisi - Is it OK for this to be 2 AM?\n"; +putenv("TZ=Asia/Tbilisi"); +$tStamp = mktime (17, 17, 17, 1, 12863, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Sunday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Sunday 00:00:00\n\n"; +?> +--EXPECT-- +TZ=America/Jujuy - Is it OK for this to be 2 AM, rather than 1 +AM as per most DST transitions? +tStamp=Monday 1990-10-15 17:17:17 WART 0 +result=Monday 1990-10-22 00:00:00 WART 0 +wanted=Monday 00:00:00 + +TZ=Asia/Tbilisi - Is it OK for this to be 2 AM? +tStamp=Sunday 2005-03-20 17:17:17 GET 0 +result=Sunday 2005-03-27 00:00:00 GET 0 +wanted=Sunday 00:00:00 diff --git a/ext/date/tests/bug33415-2.phpt b/ext/date/tests/bug33415-2.phpt new file mode 100644 index 0000000000..2e3ccf0f3a --- /dev/null +++ b/ext/date/tests/bug33415-2.phpt @@ -0,0 +1,342 @@ +--TEST-- +Bug #33415 [2] (Possibly invalid non-one-hour DST or timezone shifts) +--FILE-- +<?php + +print "TZ=Africa/Bujumbura - *Note*: Unexpected, as does not appear to +have a DST or timezone transition.\n"; +putenv("TZ=Africa/Bujumbura"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Wednesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Wednesday 00:00:00\n\n"; + +print "TZ=Asia/Thimbu - Is it OK for this to be 0:30 AM? yes\n"; +putenv("TZ=Asia/Thimbu"); +$tStamp = mktime (17, 17, 17, 1, 6476, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Thursday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Thursday 00:30:00\n\n"; + +print "TZ=Indian/Cocos - Is it OK for this to be 6:30 AM? Note: does not +appear to have a DST or timezone transition.\n"; +putenv("TZ=Indian/Cocos"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Thursday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Thursday 00:00:00\n\n"; + +print "TZ=Africa/Lubumbashi - Is it OK for this to be 2 AM? Note: does +not appear to have a DST or timezone transition.\n"; +putenv("TZ=Africa/Lubumbashi"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Saturday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Saturday 00:00:00\n\n"; + +print "TZ=Asia/Kashgar - Is it OK for this to be 3 AM? yes\n"; +putenv("TZ=Asia/Kashgar"); +$tStamp = mktime (17, 17, 17, 1, 3767, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Thursday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Thursday 03:00:00\n\n"; + +print "TZ=Indian/Christmas - Is it OK for this to be 7 AM? Note: does +not appear to have a DST or timezone transition.\n"; +putenv("TZ=Indian/Christmas"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Sunday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Sunday 00:00:00\n\n"; + +print "TZ=America/Santo_Domingo - Is it OK for this to be 0:30 AM? yes\n"; +putenv("TZ=America/Santo_Domingo"); +$tStamp = mktime (17, 17, 17, 1, 291, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Sunday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Sunday 00:30:00\n\n"; + +print "TZ=Pacific/Truk - Is it OK for this to be 10 AM? Note: does not +appear to have a DST or timezone transition.\n"; +putenv("TZ=Pacific/Truk"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Tuesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Tuesday 00:00:00\n\n"; + +print "TZ=Pacific/Ponape - Is it OK for this to be 11 AM? Note: does +not appear to have a DST or timezone transition.\n"; +putenv("TZ=Pacific/Ponape"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Monday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Monday 00:00:00\n\n"; + +print "TZ=America/Scoresbysund - Is it OK for this to be 2 AM? yes\n"; +putenv("TZ=America/Scoresbysund"); +$tStamp = mktime (17, 17, 17, 1, 4099, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Sunday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Sunday 02:00:00\n\n"; + +print "TZ=America/Guyana - Is it OK for this to be 0:45 AM? yes\n"; +putenv("TZ=America/Guyana"); +$tStamp = mktime (17, 17, 17, 1, 2031, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Thursday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Thursday 00:45:00\n\n"; + +print "TZ=Asia/Tehran - Is it OK for this to be 0:30 AM? yes\n"; +putenv("TZ=Asia/Tehran"); +$tStamp = mktime (17, 17, 17, 1, 2855, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Tuesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Tuesday 00:30:00\n\n"; + +print "TZ=Pacific/Tarawa - Is it OK for this to be Midday? Note: does +not appear to have a DST or timezone transition.\n"; +putenv("TZ=Pacific/Tarawa"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Monday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Monday 00:00:00\n\n"; + +print "TZ=Africa/Monrovia - Is it OK for this to be 00:44:30 AM? yes\n"; +putenv("TZ=Africa/Monrovia"); +$tStamp = mktime (17, 17, 17, 1, 845, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Monday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Monday 00:44:30\n\n"; + +print "TZ=Asia/Katmandu - Is it OK for this to 0:15 AM?. yes\n"; +putenv("TZ=Asia/Katmandu"); +$tStamp = mktime (17, 17, 17, 1, 5838, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Wednesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Wednesday 00:15:00\n\n"; + +print "TZ=Pacific/Nauru - Is it OK for this to be 0:30? yes\n"; +putenv("TZ=Pacific/Nauru"); +$tStamp = mktime (17, 17, 17, 1, 3401, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Tuesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Tuesday 00:30:00\n\n"; + +print "TZ=Pacific/Niue - Is it OK for this to be 0:30 AM? yes\n"; +putenv("TZ=Pacific/Niue"); +$tStamp = mktime (17, 17, 17, 1, 3189, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Sunday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Sunday 00:30:00\n\n"; + +print "TZ=Pacific/Port_Moresby - Is it OK for this to be 10 AM? No DST +or timezone transition.\n"; +putenv("TZ=Pacific/Port_Moresby"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Thursday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Thursday 00:00:00\n\n"; + +print "TZ=America/Miquelon - Is it OK for this to be 1 AM ? yes\n"; +putenv("TZ=America/Miquelon"); +$tStamp = mktime (17, 17, 17, 1, 3767, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Thursday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Thursday 01:00:00\n\n"; + +print "TZ=Pacific/Palau - Is it OK for this to be 9 AM? No DST or +timezone transition.\n"; +putenv("TZ=Pacific/Palau"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Saturday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Saturday 00:00:00\n\n"; + +print "TZ=Pacific/Funafuti - Is it OK for this to be midday? Note: does +not appear to have a DST or timezone transition.\n"; +putenv("TZ=Pacific/Funafuti"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Wednesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Wednesday 00:00:00\n\n"; + +print "TZ=Pacific/Wake - Is it OK for this to be midday? Note: does not +appear to have a DST or timezone transition.\n"; +putenv("TZ=Pacific/Wake"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Tuesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Tuesday 00:00:00\n\n"; + +print "TZ=Pacific/Wallis - Is it OK for this to be midday? Note: does +not appear to have a DST or timezone transition.\n"; +putenv("TZ=Pacific/Wallis"); +$tStamp = mktime (17, 17, 17, 1, 1, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("Tuesday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Tuesday 00:00:00\n\n"; + +print "TZ=America/Paramaribo - Is it OK for this to be 0:30 AM? yes\n"; +putenv("TZ=America/Paramaribo"); +$tStamp = mktime (17, 17, 17, 1, 5381, 1970); +print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; +$strtotime_tstamp = strtotime("next Monday", $tStamp); +print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; +print "wanted=Monday 00:30:00\n\n"; + +?> +--EXPECT-- +TZ=Africa/Bujumbura - *Note*: Unexpected, as does not appear to +have a DST or timezone transition. +tStamp=Thursday 1970-01-01 17:17:17 CAT 0 +result=Wednesday 1970-01-07 00:00:00 CAT 0 +wanted=Wednesday 00:00:00 + +TZ=Asia/Thimbu - Is it OK for this to be 0:30 AM? yes +tStamp=Thursday 1987-09-24 17:17:17 IST 0 +result=Thursday 1987-10-01 00:30:00 BTT 0 +wanted=Thursday 00:30:00 + +TZ=Indian/Cocos - Is it OK for this to be 6:30 AM? Note: does not +appear to have a DST or timezone transition. +tStamp=Thursday 1970-01-01 17:17:17 CCT 0 +result=Thursday 1970-01-08 00:00:00 CCT 0 +wanted=Thursday 00:00:00 + +TZ=Africa/Lubumbashi - Is it OK for this to be 2 AM? Note: does +not appear to have a DST or timezone transition. +tStamp=Thursday 1970-01-01 17:17:17 CAT 0 +result=Saturday 1970-01-03 00:00:00 CAT 0 +wanted=Saturday 00:00:00 + +TZ=Asia/Kashgar - Is it OK for this to be 3 AM? yes +tStamp=Thursday 1980-04-24 17:17:17 KAST 0 +result=Thursday 1980-05-01 03:00:00 CST 0 +wanted=Thursday 03:00:00 + +TZ=Indian/Christmas - Is it OK for this to be 7 AM? Note: does +not appear to have a DST or timezone transition. +tStamp=Thursday 1970-01-01 17:17:17 CXT 0 +result=Sunday 1970-01-04 00:00:00 CXT 0 +wanted=Sunday 00:00:00 + +TZ=America/Santo_Domingo - Is it OK for this to be 0:30 AM? yes +tStamp=Sunday 1970-10-18 17:17:17 EST 0 +result=Sunday 1970-10-25 00:30:00 EHDT 1 +wanted=Sunday 00:30:00 + +TZ=Pacific/Truk - Is it OK for this to be 10 AM? Note: does not +appear to have a DST or timezone transition. +tStamp=Thursday 1970-01-01 17:17:17 TRUT 0 +result=Tuesday 1970-01-06 00:00:00 TRUT 0 +wanted=Tuesday 00:00:00 + +TZ=Pacific/Ponape - Is it OK for this to be 11 AM? Note: does +not appear to have a DST or timezone transition. +tStamp=Thursday 1970-01-01 17:17:17 PONT 0 +result=Monday 1970-01-05 00:00:00 PONT 0 +wanted=Monday 00:00:00 + +TZ=America/Scoresbysund - Is it OK for this to be 2 AM? yes +tStamp=Sunday 1981-03-22 17:17:17 CGT 0 +result=Sunday 1981-03-29 02:00:00 EGST 1 +wanted=Sunday 02:00:00 + +TZ=America/Guyana - Is it OK for this to be 0:45 AM? yes +tStamp=Thursday 1975-07-24 17:17:17 GYT 0 +result=Thursday 1975-07-31 00:45:00 GYT 0 +wanted=Thursday 00:45:00 + +TZ=Asia/Tehran - Is it OK for this to be 0:30 AM? yes +tStamp=Tuesday 1977-10-25 17:17:17 IRST 0 +result=Tuesday 1977-11-01 00:30:00 IRST 0 +wanted=Tuesday 00:30:00 + +TZ=Pacific/Tarawa - Is it OK for this to be Midday? Note: does +not appear to have a DST or timezone transition. +tStamp=Thursday 1970-01-01 17:17:17 GILT 0 +result=Monday 1970-01-05 00:00:00 GILT 0 +wanted=Monday 00:00:00 + +TZ=Africa/Monrovia - Is it OK for this to be 00:44:30 AM? yes +tStamp=Monday 1972-04-24 17:17:17 LRT 0 +result=Monday 1972-05-01 00:44:30 GMT 0 +wanted=Monday 00:44:30 + +TZ=Asia/Katmandu - Is it OK for this to 0:15 AM?. yes +tStamp=Wednesday 1985-12-25 17:17:17 IST 0 +result=Wednesday 1986-01-01 00:15:00 NPT 0 +wanted=Wednesday 00:15:00 + +TZ=Pacific/Nauru - Is it OK for this to be 0:30? yes +tStamp=Tuesday 1979-04-24 17:17:17 NRT 0 +result=Tuesday 1979-05-01 00:30:00 NRT 0 +wanted=Tuesday 00:30:00 + +TZ=Pacific/Niue - Is it OK for this to be 0:30 AM? yes +tStamp=Sunday 1978-09-24 17:17:17 NUT 0 +result=Sunday 1978-10-01 00:30:00 NUT 0 +wanted=Sunday 00:30:00 + +TZ=Pacific/Port_Moresby - Is it OK for this to be 10 AM? No DST +or timezone transition. +tStamp=Thursday 1970-01-01 17:17:17 PGT 0 +result=Thursday 1970-01-08 00:00:00 PGT 0 +wanted=Thursday 00:00:00 + +TZ=America/Miquelon - Is it OK for this to be 1 AM ? yes +tStamp=Thursday 1980-04-24 17:17:17 AST 0 +result=Thursday 1980-05-01 01:00:00 PMST 0 +wanted=Thursday 01:00:00 + +TZ=Pacific/Palau - Is it OK for this to be 9 AM? No DST or +timezone transition. +tStamp=Thursday 1970-01-01 17:17:17 PWT 0 +result=Saturday 1970-01-03 00:00:00 PWT 0 +wanted=Saturday 00:00:00 + +TZ=Pacific/Funafuti - Is it OK for this to be midday? Note: does +not appear to have a DST or timezone transition. +tStamp=Thursday 1970-01-01 17:17:17 TVT 0 +result=Wednesday 1970-01-07 00:00:00 TVT 0 +wanted=Wednesday 00:00:00 + +TZ=Pacific/Wake - Is it OK for this to be midday? Note: does not +appear to have a DST or timezone transition. +tStamp=Thursday 1970-01-01 17:17:17 WAKT 0 +result=Tuesday 1970-01-06 00:00:00 WAKT 0 +wanted=Tuesday 00:00:00 + +TZ=Pacific/Wallis - Is it OK for this to be midday? Note: does +not appear to have a DST or timezone transition. +tStamp=Thursday 1970-01-01 17:17:17 WFT 0 +result=Tuesday 1970-01-06 00:00:00 WFT 0 +wanted=Tuesday 00:00:00 + +TZ=America/Paramaribo - Is it OK for this to be 0:30 AM? yes +tStamp=Monday 1984-09-24 17:17:17 SRT 0 +result=Monday 1984-10-01 00:30:00 SRT 0 +wanted=Monday 00:30:00 |