]> granicus.if.org Git - php/commitdiff
Fixed bug #26198 (strtotime() handling of M/F Y date format).
authorIlia Alshanetsky <iliaa@php.net>
Wed, 12 Nov 2003 02:55:03 +0000 (02:55 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 12 Nov 2003 02:55:03 +0000 (02:55 +0000)
ext/standard/parsedate.y
ext/standard/tests/time/bug26198.phpt [new file with mode: 0644]

index 5669b0bcc9768556fbc88979d3c8a2f58a4b96f2..abe77acf690303ff4705ab5a7bd9b52f2fcbe9ac 100644 (file)
@@ -329,7 +329,11 @@ date       : tUNUMBER '/' tUNUMBER {
        }
        | tMONTH tUNUMBER {
            ((struct date_yy *)parm)->yyMonth = $1;
-           ((struct date_yy *)parm)->yyDay = $2;
+           if ($2 > 1000) {
+               ((struct date_yy *)parm)->yyYear = $2;
+           } else {
+               ((struct date_yy *)parm)->yyDay = $2;
+           }
        }
        | tMONTH tUNUMBER ',' tUNUMBER {
            ((struct date_yy *)parm)->yyMonth = $1;
@@ -338,7 +342,11 @@ date       : tUNUMBER '/' tUNUMBER {
        }
        | tUNUMBER tMONTH {
            ((struct date_yy *)parm)->yyMonth = $2;
-           ((struct date_yy *)parm)->yyDay = $1;
+           if ($1 > 1000) {
+               ((struct date_yy *)parm)->yyYear = $1;
+           } else {
+               ((struct date_yy *)parm)->yyDay = $1;
+           }
        }
        | tUNUMBER tMONTH tUNUMBER {
            ((struct date_yy *)parm)->yyMonth = $2;
diff --git a/ext/standard/tests/time/bug26198.phpt b/ext/standard/tests/time/bug26198.phpt
new file mode 100644 (file)
index 0000000..318108d
--- /dev/null
@@ -0,0 +1,10 @@
+--TEST--
+Bug #26198 (strtotime handling of "M Y" and "Y M" format)
+--FILE--
+<?php
+       echo date("F Y\n", strtotime("Oct 2001"));
+       echo date("M Y\n", strtotime("2001 Oct"));
+?>
+--EXPECT--
+October 2001
+Oct 2001