diff options
author | Derick Rethans <derick@php.net> | 2001-10-27 17:50:26 +0000 |
---|---|---|
committer | Derick Rethans <derick@php.net> | 2001-10-27 17:50:26 +0000 |
commit | 6a5bcfef8dd182438fe91a9e1f332a46e2c38fa9 (patch) | |
tree | 94ac016dd91e84cf873c3b43ddba9e3480855692 | |
parent | 374a35144450b34ccc12bdd85bf58b025c03a99f (diff) | |
download | php-git-6a5bcfef8dd182438fe91a9e1f332a46e2c38fa9.tar.gz |
- Fix for bugs #9640 and #13789
-rw-r--r-- | ext/standard/parsedate.y | 9 | ||||
-rw-r--r-- | ext/standard/tests/time/002.phpt | 84 |
2 files changed, 58 insertions, 35 deletions
diff --git a/ext/standard/parsedate.y b/ext/standard/parsedate.y index 6cd7ba38d8..45357d9fbd 100644 --- a/ext/standard/parsedate.y +++ b/ext/standard/parsedate.y @@ -249,14 +249,17 @@ time : tUNUMBER tMERIDIAN { yyMeridian = $6; } | tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER { + /* ISO 8601 format. hh:mm:ss[+-][0-9]{2}([0-9]{2})?. */ yyHour = $1; yyMinutes = $3; yySeconds = $5; yyMeridian = MER24; yyHaveZone++; - yyTimezone = ($6 < 0 - ? -$6 % 100 + (-$6 / 100) * 60 - : - ($6 % 100 + ($6 / 100) * 60)); + if ($6 < -100 || $6 > 100) { + yyTimezone = -$6 % 100 + (-$6 / 100) * 60; + } else { + yyTimezone = -$6 * 60; + } } ; diff --git a/ext/standard/tests/time/002.phpt b/ext/standard/tests/time/002.phpt index 57325af4c4..eba00b074b 100644 --- a/ext/standard/tests/time/002.phpt +++ b/ext/standard/tests/time/002.phpt @@ -4,39 +4,59 @@ strtotime() function --GET-- --FILE-- <?php - putenv("TZ=GMT"); + $dates = array ( + "1999-10-13", + "Oct 13 1999", + "2000-01-19", + "Jan 19 2000", + "2001-12-21", + "Dec 21 2001", + "2001-12-21 12:16", + "Dec 21 2001 12:16", + "Dec 21 12:16", + "2001-10-22 21:19:58", + "2001-10-22 21:19:58-02", + "2001-10-22 21:19:58-0213", + "2001-10-22 21:19:58+02", + "2001-10-22 21:19:58+0213" + ); - echo "1999-10-13\n"; - echo strtotime ("1999-10-13")."\n"; - echo strtotime ("Oct 13 1999")."\n\n"; + putenv ("TZ=GMT"); + foreach ($dates as $date) { + echo date ("Y-m-d H:i:s\n", strtotime ($date)); + } - echo "2000-01-19\n"; - echo strtotime ("2000-01-19")."\n"; - echo strtotime ("Jan 19 2000")."\n\n"; - - echo "2001-12-21\n"; - echo strtotime ("2001-12-21")."\n"; - echo strtotime ("Dec 21 2001")."\n\n"; - - echo "2001-12-21 12:16\n"; - echo strtotime ("2001-12-21 12:16")."\n"; - echo strtotime ("Dec 21 2001 12:16")."\n"; - echo strtotime ("Dec 21 12:16")."\n"; + putenv ("TZ=Europe/Amsterdam"); + foreach ($dates as $date) { + echo date ("Y-m-d H:i:s\n", strtotime ($date)); + } ?> --EXPECT-- -1999-10-13 -939772800 -939772800 - -2000-01-19 -948240000 -948240000 - -2001-12-21 -1008892800 -1008892800 - -2001-12-21 12:16 -1008936960 -1008936960 --1 +1999-10-13 00:00:00 +1999-10-13 00:00:00 +2000-01-19 00:00:00 +2000-01-19 00:00:00 +2001-12-21 00:00:00 +2001-12-21 00:00:00 +2001-12-21 12:16:00 +2001-12-21 12:16:00 +1969-12-31 23:59:59 +2001-10-22 21:19:58 +2001-10-22 23:19:58 +2001-10-22 23:32:58 +2001-10-22 19:19:58 +2001-10-22 19:06:58 +1999-10-13 00:00:00 +1999-10-13 00:00:00 +2000-01-19 00:00:00 +2000-01-19 00:00:00 +2001-12-21 00:00:00 +2001-12-21 00:00:00 +2001-12-21 12:16:00 +2001-12-21 12:16:00 +1970-01-01 00:59:59 +2001-10-22 21:19:58 +2001-10-23 01:19:58 +2001-10-23 01:32:58 +2001-10-22 21:19:58 +2001-10-22 21:06:58 |