]> granicus.if.org Git - php/commitdiff
- Fix for bugs #9640 and #13789
authorDerick Rethans <derick@php.net>
Sat, 27 Oct 2001 17:50:26 +0000 (17:50 +0000)
committerDerick Rethans <derick@php.net>
Sat, 27 Oct 2001 17:50:26 +0000 (17:50 +0000)
ext/standard/parsedate.y
ext/standard/tests/time/002.phpt

index 6cd7ba38d8f1bfedcb711a6c4728efec190a3022..45357d9fbd53dcbd1b077d0569ec5272bb952417 100644 (file)
@@ -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;
+               }
        }
        ;
 
index 57325af4c4b5103640062391d01b9a9b946b3e75..eba00b074b6a39322594cabe0cd806695f14d347 100644 (file)
@@ -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