From 77729f89dd15b3b52263638dbf4e46f8299551c8 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Sat, 16 Aug 2003 20:55:28 +0000 Subject: [PATCH] - Fixed bug #17988: strtotime fails to parse timestamp from postgresql #- This is actually a feature request --- NEWS | 1 + ext/standard/parsedate.y | 21 +++++++++++++++++ ext/standard/tests/time/bug17988.phpt | 33 +++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 ext/standard/tests/time/bug17988.phpt diff --git a/NEWS b/NEWS index 017ea71aaf..29f2e52161 100644 --- a/NEWS +++ b/NEWS @@ -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-- + +--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 -- 2.40.0