Skip to content

Commit cdc4e49

Browse files
committed
Make strftime tests musl compatible
* 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.
1 parent f16c1dc commit cdc4e49

File tree

6 files changed

+19
-29
lines changed

6 files changed

+19
-29
lines changed

ext/date/tests/009.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ $t = mktime(0,0,0, 6, 27, 2006);
1313
var_dump(strftime(""));
1414
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));
1515
var_dump(strftime("%%q %%a", $t));
16-
var_dump(strftime("%q", $t));
1716
var_dump(strftime("blah", $t));
1817

1918
var_dump(gmstrftime(""));
2019
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));
2120
var_dump(gmstrftime("%%q %%a", $t));
22-
var_dump(gmstrftime("%q", $t));
2321
var_dump(gmstrftime("blah", $t));
2422

2523
echo "Done\n";
@@ -29,12 +27,10 @@ bool(false)
2927
string(%d) "Tue Tuesday Jun June Tue Jun 27 00:00:00 2006 %s
3028
%s %"
3129
string(5) "%q %a"
32-
string(%d) "%s"
3330
string(4) "blah"
3431
bool(false)
3532
string(%d) "Mon Monday Jun June Mon Jun 26 21:00:00 2006 %s
3633
%s %"
3734
string(5) "%q %a"
38-
string(%d) "%s"
3935
string(4) "blah"
4036
Done

ext/date/tests/bug27780.phpt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
--TEST--
22
Bug #27780 (strtotime(+1 xxx) returns a wrong date/time)
3-
--SKIPIF--
4-
<?php
5-
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
6-
die("skip. Not the same TZ on windows.");
7-
}
83
--FILE--
94
<?php
105
$timezones = array (
@@ -35,7 +30,7 @@ foreach ($timezones as $timezone) {
3530
foreach ($timestrings as $timestring) {
3631
$time = strtotime($timestring);
3732

38-
echo $time, strftime(" [%Y-%m-%d %H:%M:%S %Z]", $time), " [$timestring]\n";
33+
echo $time, date(" [Y-m-d H:i:s T]", $time), " [$timestring]\n";
3934
}
4035

4136
echo "\n";

ext/date/tests/bug32555.phpt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
--TEST--
22
Bug #32555 (strtotime("tomorrow") can return false)
3-
--SKIPIF--
4-
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') die('skip strftime uses system TZ');
6-
?>
73
--INI--
84
date.timezone=US/Eastern
95
--FILE--
106
<?php
117
$stamp = 1112427000;
12-
print strftime('%c %Z',strtotime('now',$stamp)) ."\n";
13-
print strftime('%c %Z',strtotime('tomorrow',$stamp)) ."\n";
14-
print strftime('%c %Z',strtotime('+1 day',$stamp)) ."\n";
15-
print strftime('%c %Z',strtotime('+2 day',$stamp)) ."\n";
8+
print date('r', strtotime('now',$stamp)) ."\n";
9+
print date('r', strtotime('tomorrow',$stamp)) ."\n";
10+
print date('r', strtotime('+1 day',$stamp)) ."\n";
11+
print date('r', strtotime('+2 day',$stamp)) ."\n";
1612
?>
1713
--EXPECT--
18-
Sat Apr 2 02:30:00 2005 EST
19-
Sun Apr 3 00:00:00 2005 EST
20-
Sun Apr 3 03:30:00 2005 EDT
21-
Mon Apr 4 02:30:00 2005 EDT
14+
Sat, 02 Apr 2005 02:30:00 -0500
15+
Sun, 03 Apr 2005 00:00:00 -0500
16+
Sun, 03 Apr 2005 03:30:00 -0400
17+
Mon, 04 Apr 2005 02:30:00 -0400

ext/date/tests/bug33532.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ date.timezone=UTC
66
--SKIPIF--
77
<?php
88
if(PHP_OS == 'Darwin' || defined('PHP_WINDOWS_VERSION_MAJOR')) die("skip strftime uses system TZ on Darwin and Windows");
9+
if (!strftime('%Z')) die('skip strftime does not support %Z');
910
?>
1011
--FILE--
1112
<?php

ext/standard/tests/time/strptime_basic.phpt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
Test strptime() function : basic functionality
33
--SKIPIF--
44
<?php
5-
if (!function_exists('strptime')) {
6-
die("skip - strptime() function not available in this build");
7-
}
8-
if(PHP_OS == 'Darwin') die("skip - strptime() behaves differently on Darwin");
5+
if (!function_exists('strptime')) {
6+
die("skip - strptime() function not available in this build");
7+
}
8+
if (PHP_OS == 'Darwin') die("skip - strptime() behaves differently on Darwin");
9+
if (!strftime('%Z')) die('skip strftime does not support %Z');
910
?>
1011
--FILE--
1112
<?php

ext/standard/tests/time/strptime_parts.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
Test strptime() function : basic functionality
33
--SKIPIF--
44
<?php
5-
if (!function_exists('strptime')) {
6-
die("skip - strptime() function not available in this build");
7-
}
5+
if (!function_exists('strptime')) {
6+
die("skip - strptime() function not available in this build");
7+
}
8+
if (!strftime('%Z')) die('skip strftime does not support %Z');
89
?>
910
--FILE--
1011
<?php

0 commit comments

Comments
 (0)