This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
RE: [perl #26136] localtime(3) calls tzset(3), but localtime_r(3) may not.
[perl5.git] / t / op / time.t
index 2105e9d..2f01c7a 100755 (executable)
@@ -1,12 +1,10 @@
 #!./perl
 
-# $RCSfile: time.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:32 $
-
 if ( $does_gmtime = gmtime(time) ) { 
-    print "1..7\n" 
+    print "1..8\n" 
 }
 else { 
-    print "1..4\n" 
+    print "1..5\n" 
 }
 
 
@@ -54,6 +52,13 @@ ok(localtime() =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat)[ ]
    'localtime(), scalar context'
   );
 
+# check that localtime respects changes to $ENV{TZ}
+$ENV{TZ} = "GMT-5";
+($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($beg);
+$ENV{TZ} = "GMT+5";
+($sec,$min,$hour2,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($beg);
+ok($hour != $hour2,                             'changes to $ENV{TZ} respected');
+
 exit 0 unless $does_gmtime;
 
 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($beg);