]> granicus.if.org Git - php/commitdiff
Fixed bug #13142 (strtotime not handling "M d H:i:s Y" format)
authorIlia Alshanetsky <iliaa@php.net>
Mon, 28 Jul 2003 04:01:32 +0000 (04:01 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 28 Jul 2003 04:01:32 +0000 (04:01 +0000)
ext/standard/parsedate.y
ext/standard/tests/time/bug13142.phpt [new file with mode: 0644]

index 28ba0cd401b8ed638c5eadf118485023b5856f82..6fe1fb1b13971f19590e99a5c07b2a2901fc9fed 100644 (file)
@@ -260,6 +260,17 @@ date       : tUNUMBER '/' tUNUMBER {
            ((struct date_yy *)parm)->yyMonth = $1;
            ((struct date_yy *)parm)->yyDay = $3;
        }
+       | tMONTH tUNUMBER tUNUMBER ':' tUNUMBER ':' tUNUMBER tUNUMBER {
+               ((struct date_yy *)parm)->yyYear = $8;
+               ((struct date_yy *)parm)->yyMonth = $1;
+               ((struct date_yy *)parm)->yyDay = $2;
+
+               ((struct date_yy *)parm)->yyHour = $3;
+               ((struct date_yy *)parm)->yyMinutes = $5;
+               ((struct date_yy *)parm)->yySeconds = $7;
+
+               ((struct date_yy *)parm)->yyHaveTime = 1;
+       }
        | tUNUMBER '/' tUNUMBER '/' tUNUMBER {
          /* Interpret as YYYY/MM/DD if $1 >= 1000, otherwise as MM/DD/YY.
             The goal in recognizing YYYY/MM/DD is solely to support legacy
diff --git a/ext/standard/tests/time/bug13142.phpt b/ext/standard/tests/time/bug13142.phpt
new file mode 100644 (file)
index 0000000..6e2bf87
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Bug #13142 strtotime handling of "M d H:i:s Y" format
+--SKIPIF--
+<?php
+if (!@putenv("TZ=US/Eastern") || getenv("TZ") != 'US/Eastern') {
+       die("skip unable to change TZ enviroment variable\n");
+}
+?>
+--FILE--
+<?php
+echo date("r\n", strtotime("Sep 04 16:39:45 2001"));
+echo date("r\n", strtotime("Sep 04 2001 16:39:45"));   
+?>
+--EXPECT--
+Tue,  4 Sep 2001 16:39:45 -0400
+Tue,  4 Sep 2001 16:39:45 -0400