]> granicus.if.org Git - php/commitdiff
Make strftime tests musl compatible
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 12 Aug 2020 15:06:02 +0000 (17:06 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 13 Aug 2020 10:02:27 +0000 (12:02 +0200)
 * Remove usage of strftime() in favor of date() in cases where
   we are not specifically testing strftime(). We implement
   date() ourselves, and as such are insulated from implementation-
   defined behavior.
 * Add skipif for broken strftime() %Z support. We have decided
   not to work around the issue for musl using manual expansion,
   as people should not be using this function anyway, and it is
   slated for future deprecation.
 * Don't test strftime() with invalid format specifier. The
   behavior is implementation-dependent.

ext/date/tests/009.phpt
ext/date/tests/bug27780.phpt
ext/date/tests/bug32555.phpt
ext/date/tests/bug33532.phpt
ext/standard/tests/time/strptime_basic.phpt
ext/standard/tests/time/strptime_parts.phpt

index 9d77a552ccfc0d953ad7ebf3c86b80378fc83c2b..624b2d5f66d7db61f1211b67a3c6ba301229826d 100644 (file)
@@ -13,13 +13,11 @@ $t = mktime(0,0,0, 6, 27, 2006);
 var_dump(strftime(""));
 var_dump(strftime("%a %A %b %B %c %C %d %D %e %g %G %h %H %I %j %m %M %n %p %r %R %S %t %T %u %U %V %W %w %x %X %y %Y %Z %z %%", $t));
 var_dump(strftime("%%q %%a", $t));
-var_dump(strftime("%q", $t));
 var_dump(strftime("blah", $t));
 
 var_dump(gmstrftime(""));
 var_dump(gmstrftime("%a %A %b %B %c %C %d %D %e %g %G %h %H %I %j %m %M %n %p %r %R %S %t %T %u %U %V %W %w %x %X %y %Y %Z %z %%", $t));
 var_dump(gmstrftime("%%q %%a", $t));
-var_dump(gmstrftime("%q", $t));
 var_dump(gmstrftime("blah", $t));
 
 echo "Done\n";
@@ -29,12 +27,10 @@ bool(false)
 string(%d) "Tue Tuesday Jun June Tue Jun 27 00:00:00 2006 %s
 %s %"
 string(5) "%q %a"
-string(%d) "%s"
 string(4) "blah"
 bool(false)
 string(%d) "Mon Monday Jun June Mon Jun 26 21:00:00 2006 %s
 %s %"
 string(5) "%q %a"
-string(%d) "%s"
 string(4) "blah"
 Done
index f6f21e4185129a74d43f3adafd425687db3eec29..52387b08bbe3273b84983b4f980a1322a392f38c 100644 (file)
@@ -1,10 +1,5 @@
 --TEST--
 Bug #27780 (strtotime(+1 xxx) returns a wrong date/time)
---SKIPIF--
-<?php
-if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
-       die("skip. Not the same TZ on windows.");
-}
 --FILE--
 <?php
 $timezones = array (
@@ -35,7 +30,7 @@ foreach ($timezones as $timezone) {
     foreach ($timestrings as $timestring) {
         $time = strtotime($timestring);
 
-        echo $time, strftime(" [%Y-%m-%d %H:%M:%S %Z]", $time), " [$timestring]\n";
+        echo $time, date(" [Y-m-d H:i:s T]", $time), " [$timestring]\n";
     }
 
     echo "\n";
index 03ed09fab49c399c128b7c1bea823ac8ffa71563..02b2ca06e70398581ef1222b1435441dbb39c520 100644 (file)
@@ -1,21 +1,17 @@
 --TEST--
 Bug #32555 (strtotime("tomorrow") can return false)
---SKIPIF--
-<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') die('skip strftime uses system TZ');
-?>
 --INI--
 date.timezone=US/Eastern
 --FILE--
 <?php
 $stamp = 1112427000;
-print strftime('%c %Z',strtotime('now',$stamp)) ."\n";
-print strftime('%c %Z',strtotime('tomorrow',$stamp)) ."\n";
-print strftime('%c %Z',strtotime('+1 day',$stamp)) ."\n";
-print strftime('%c %Z',strtotime('+2 day',$stamp)) ."\n";
+print date('r', strtotime('now',$stamp)) ."\n";
+print date('r', strtotime('tomorrow',$stamp)) ."\n";
+print date('r', strtotime('+1 day',$stamp)) ."\n";
+print date('r', strtotime('+2 day',$stamp)) ."\n";
 ?>
 --EXPECT--
-Sat Apr  2 02:30:00 2005 EST
-Sun Apr  3 00:00:00 2005 EST
-Sun Apr  3 03:30:00 2005 EDT
-Mon Apr  4 02:30:00 2005 EDT
+Sat, 02 Apr 2005 02:30:00 -0500
+Sun, 03 Apr 2005 00:00:00 -0500
+Sun, 03 Apr 2005 03:30:00 -0400
+Mon, 04 Apr 2005 02:30:00 -0400
index 5323e8c8db18ed0a78a58d81bb052ab7418888bc..80b87f7e6d87d3f027ab7762c1f59a457086273e 100644 (file)
@@ -6,6 +6,7 @@ date.timezone=UTC
 --SKIPIF--
 <?php
 if(PHP_OS == 'Darwin' || defined('PHP_WINDOWS_VERSION_MAJOR')) die("skip strftime uses system TZ on Darwin and Windows");
+if (!strftime('%Z')) die('skip strftime does not support %Z');
 ?>
 --FILE--
 <?php
index 7be1e75c001370936965eb490d525b82b1788ea0..8e942ff498398ee68bb6205964ada5d44d30bc68 100644 (file)
@@ -2,10 +2,11 @@
 Test strptime() function : basic functionality
 --SKIPIF--
 <?php
-       if (!function_exists('strptime')) {
-               die("skip - strptime() function not available in this build");
-       }
-        if(PHP_OS == 'Darwin') die("skip - strptime() behaves differently on Darwin");
+if (!function_exists('strptime')) {
+    die("skip - strptime() function not available in this build");
+}
+if (PHP_OS == 'Darwin') die("skip - strptime() behaves differently on Darwin");
+if (!strftime('%Z')) die('skip strftime does not support %Z');
 ?>
 --FILE--
 <?php
index 1905e1af350f02f6a46331902f755f0ec0de8b2f..fcf74d2eb5c0336fb13307571a10c2b9ba693ff0 100644 (file)
@@ -2,9 +2,10 @@
 Test strptime() function : basic functionality
 --SKIPIF--
 <?php
-       if (!function_exists('strptime')) {
-               die("skip - strptime() function not available in this build");
-       }
+if (!function_exists('strptime')) {
+    die("skip - strptime() function not available in this build");
+}
+if (!strftime('%Z')) die('skip strftime does not support %Z');
 ?>
 --FILE--
 <?php