Skip to content

Commit 0272c12

Browse files
committed
gmtime
1 parent 4697edf commit 0272c12

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

ext/POSIX/t/time.t

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ SKIP: { # GH #23878: test that dst spring forward works properly; use a
271271
print STDERR __FILE__, ": ", __LINE__, ": about to call tzset\n";
272272
POSIX::tzset();
273273
print STDERR __FILE__, ": ", __LINE__, ": finished with tzset\n";
274-
my $t = 1741510800; # an hour before time should have changed
274+
my $from_gmt = 8 * 60 * 60;
275+
my $t = 1741510800 - $from_gmt; # an hour before time should have changed
275276
my $t_minus_12_hours = $t - 12 * 60 * 60;;
276277
print STDERR __FILE__, ": ", __LINE__, ": calling offset for $t_minus_12_hours\n";
277278
use Data::Dumper;
@@ -298,8 +299,17 @@ SKIP: { # GH #23878: test that dst spring forward works properly; use a
298299
);
299300
$^D |= 0x04000000|0x00100000 ;
300301
for (my $i = 0; $i < @spring; $i++) {
301-
print STDERR __FILE__, ": ", __LINE__, ": calling strftime with\n", Dumper $spring[$i], localtime $t + $spring[$i][0];
302-
is(POSIX::strftime("%F %T%z", localtime $t + $spring[$i][0]),
302+
my @gmtime = gmtime($t + $spring[$i][0]);
303+
print STDERR __FILE__, ": ", __LINE__, ": calling strftime with\n", Dumper $spring[$i], \@gmtime;
304+
$gmtime[-1] = -1;
305+
my $returned_name = POSIX::strftime("%Z", @gmtime);
306+
print STDERR __FILE__, ": ", __LINE__, ": zone=$zone_name, returned=$returned_name\n";
307+
if ($zone_name ne $returned_name) {
308+
@gmtime = gmtime($t + 3600 + $spring[$i][0]);
309+
$gmtime[-1] = 1;
310+
}
311+
print STDERR __FILE__, ": ", __LINE__, ": calling strftime with\n", Dumper $spring[$i], \@gmtime;
312+
is(POSIX::strftime("%F %T%z", @gmtime),
303313
$spring[$i][1], $spring[$i][2]);
304314
}
305315
$^D &= ~(67108864|1048576 );

0 commit comments

Comments
 (0)