Skip to content

Commit 4f078b8

Browse files
committed
tzset
1 parent edc90cb commit 4f078b8

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

ext/POSIX/t/time.t

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ use Test::More tests => 49;
1616
# Those with a working tzset() should be able to use the TZ below.
1717
$ENV{TZ} = "EST5EDT";
1818

19+
# It looks like POSIX.xs claims that only VMS and Mac OS traditional
20+
# don't have tzset(). Win32 works to call the function, but it doesn't
21+
# actually do anything. Cygwin works in some places, but not others. The
22+
# other Win32's below are guesses.
23+
my $has_tzset = $^O ne "VMS" && $^O ne "cygwin"
24+
&& $^O ne "MSWin32" && $^O ne "interix";
25+
1926
SKIP: {
20-
# It looks like POSIX.xs claims that only VMS and Mac OS traditional
21-
# don't have tzset(). Win32 works to call the function, but it doesn't
22-
# actually do anything. Cygwin works in some places, but not others. The
23-
# other Win32's below are guesses.
24-
skip "No tzset()", 1
25-
if $^O eq "VMS" || $^O eq "cygwin" ||
26-
$^O eq "MSWin32" || $^O eq "interix";
27+
skip "No tzset()", 1 unless $has_tzset;
2728
tzset();
2829
SKIP: {
2930
my @tzname = tzname();
@@ -42,9 +43,7 @@ SKIP: {
4243
$ENV{TZ} = "UTC0UTC";
4344

4445
SKIP: {
45-
skip "No tzset()", 2
46-
if $^O eq "VMS" || $^O eq "cygwin" ||
47-
$^O eq "MSWin32" || $^O eq "interix";
46+
skip "No tzset()", 1 unless $has_tzset;
4847
tzset();
4948
my @tzname = tzname();
5049
like($tzname[0], qr/(GMT|UTC)/i, "tzset() to GMT/UTC");
@@ -237,7 +236,7 @@ SKIP: { # GH #23878; test that dst fall back works properly
237236
skip "No mktime()", $skip_count if $Config{d_mktime} ne 'define';
238237
my $locale = "Europe/Paris";
239238
$ENV{TZ} = $locale;
240-
tzset();
239+
tzset() if $has_tzset;
241240

242241
skip "'$locale' not understood", $skip_count
243242
if POSIX::strftime("%H", localtime($reference_time)) != 19;
@@ -267,15 +266,17 @@ SKIP: { # GH #23878: test that dst spring forward works properly; use a
267266

268267
my $locale = "PST8PDT";
269268
$ENV{TZ} = $locale;
269+
tzset() if $has_tzset;
270+
270271
skip "'$locale' not understood", $skip_count if
271272
POSIX::strftime("%H", localtime($reference_time)) != 10;
272273

273274
my $t = 1741510800; # an hour before time should have changed
274275

275276
my @spring = (
276-
[ -1, "2025-03-09 00:59:59-0800", "Chg -1 hr, 1 sec" ],
277+
[ -1, "2025-03-09 00:59:59-0800", "Chg -1 hr,-1 sec" ],
277278
[ 0, "2025-03-09 01:00:00-0800", "Chg -1 hr, 0 sec" ],
278-
[ 1, "2025-03-09 01:00:01-0800", "Chg -59 min, 59 sec" ],
279+
[ 1, "2025-03-09 01:00:01-0800", "Chg -59 min,-59 sec" ],
279280
[ 3599, "2025-03-09 01:59:59-0800", "Chg -1 sec" ],
280281
[ 3600, "2025-03-09 03:00:00-0700",
281282
"At Redmond DST spring forward" ],

0 commit comments

Comments
 (0)