diff options
| author | Derick Rethans <derick@php.net> | 2003-08-16 20:55:28 +0000 |
|---|---|---|
| committer | Derick Rethans <derick@php.net> | 2003-08-16 20:55:28 +0000 |
| commit | 77729f89dd15b3b52263638dbf4e46f8299551c8 (patch) | |
| tree | 83f4132ccbfe5fa269c92f6a5d154166d47c816e | |
| parent | fe1a086d19a9635ee9e7acb4466217345902834e (diff) | |
| download | php-git-77729f89dd15b3b52263638dbf4e46f8299551c8.tar.gz | |
- Fixed bug #17988: strtotime fails to parse timestamp from postgresql
#- This is actually a feature request
| -rw-r--r-- | NEWS | 1 | ||||
| -rw-r--r-- | ext/standard/parsedate.y | 21 | ||||
| -rw-r--r-- | ext/standard/tests/time/bug17988.phpt | 33 |
3 files changed, 55 insertions, 0 deletions
@@ -41,6 +41,7 @@ PHP NEWS - Fixed bug #22367 (undefined variable has a value). (Zeev) - Fixed bug #19859 (allow fast_call_user_function to support __call). (Stanislav) +- Fixed bug #17988 (strtotime failed to parse postgresql timestamp). (Derick) 29 Jun 2003, PHP 5 Beta 1 - Removed the bundled MySQL client library. (Sterling) diff --git a/ext/standard/parsedate.y b/ext/standard/parsedate.y index 6fe1fb1b13..44af0adff3 100644 --- a/ext/standard/parsedate.y +++ b/ext/standard/parsedate.y @@ -228,6 +228,27 @@ time : tUNUMBER tMERIDIAN { ((struct date_yy *)parm)->yyTimezone = -$6 * 60; } } + | tUNUMBER ':' tUNUMBER ':' tUNUMBER '.' tUNUMBER pgsqlzonepart { + ((struct date_yy *)parm)->yyHour = $1; + ((struct date_yy *)parm)->yyMinutes = $3; + ((struct date_yy *)parm)->yySeconds = $5; + ((struct date_yy *)parm)->yyMeridian = MER24; + } + ; + +pgsqlzonepart : tSNUMBER { + ((struct date_yy *)parm)->yyHaveZone++; + if ($1 <= -100 || $1 >= 100) { + ((struct date_yy *)parm)->yyTimezone = + -$1 % 100 + (-$1 / 100) * 60; + } else { + ((struct date_yy *)parm)->yyTimezone = -$1 * 60; + } + } + | zone { + ((struct date_yy *)parm)->yyHaveZone++; + } + | /* empty */ ; zone : tZONE { diff --git a/ext/standard/tests/time/bug17988.phpt b/ext/standard/tests/time/bug17988.phpt new file mode 100644 index 0000000000..5fbc3c845f --- /dev/null +++ b/ext/standard/tests/time/bug17988.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #17988 strtotime handling of postgresql timestamps +--FILE-- +<?php +putenv("TZ=GMT"); +echo gmdate('Y-m-d H:i:s', strtotime("2002-06-25 14:18:48.543728"))."\n"; +echo gmdate('Y-m-d H:i:s', strtotime("2002-06-25 14:18:48.543728 GMT"))."\n"; +echo gmdate('Y-m-d H:i:s', strtotime("2002-06-25 14:18:48.543728 MET"))."\n"; +echo gmdate('Y-m-d H:i:s', strtotime("2002-06-25 14:18:48.543728 MEST"))."\n"; +echo gmdate('Y-m-d H:i:s', strtotime("2002-06-25 14:18:48.543728 EDT"))."\n"; +echo gmdate('Y-m-d H:i:s', strtotime("2002-06-25 14:18:48.543728-00"))."\n"; +echo gmdate('Y-m-d H:i:s', strtotime("2002-06-25 14:18:48.543728+00"))."\n"; +echo gmdate('Y-m-d H:i:s', strtotime("2002-06-25 14:18:48.543728-04"))."\n"; +echo gmdate('Y-m-d H:i:s', strtotime("2002-06-25 14:18:48.543728+04"))."\n"; +echo gmdate('Y-m-d H:i:s', strtotime("2002-06-25 14:18:48.543728-0300"))."\n"; +echo gmdate('Y-m-d H:i:s', strtotime("2002-06-25 14:18:48.543728+0300"))."\n"; +echo gmdate('Y-m-d H:i:s', strtotime("2002-06-25 14:18:48.543728-0330"))."\n"; +echo gmdate('Y-m-d H:i:s', strtotime("2002-06-25 14:18:48.543728+0330"))."\n"; +?> +--EXPECT-- +2002-06-25 14:18:48 +2002-06-25 14:18:48 +2002-06-25 13:18:48 +2002-06-25 12:18:48 +2002-06-25 18:18:48 +2002-06-25 14:18:48 +2002-06-25 14:18:48 +2002-06-25 18:18:48 +2002-06-25 10:18:48 +2002-06-25 17:18:48 +2002-06-25 11:18:48 +2002-06-25 17:48:48 +2002-06-25 10:48:48 |
