3 $does_gmtime = gmtime(time);
13 ($beguser,$begsys) = times;
17 while (($now = time) == $beg) { sleep 1 }
19 ok($now > $beg && $now - $beg < 10, 'very basic time test');
21 for ($i = 0; $i < 1_000_000; $i++) {
22 for my $j (1..100) {}; # burn some user cycles
23 ($nowuser, $nowsys) = times;
24 $i = 2_000_000 if $nowuser > $beguser && ( $nowsys >= $begsys ||
25 (!$nowsys && !$begsys));
26 last if time - $beg > 20;
29 ok($i >= 2_000_000, 'very basic times test');
31 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($beg);
32 ($xsec,$foo) = localtime($now);
35 ok($sec != $xsec && $mday && $year, 'localtime() list context');
37 ok(localtime() =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat)[ ]
38 (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[ ]
39 ([ \d]\d)\ (\d\d):(\d\d):(\d\d)\ (\d{4})$
41 'localtime(), scalar context'
45 # This conditional of "No tzset()" is stolen from ext/POSIX/t/time.t
47 if $^O eq "MacOS" || $^O eq "VMS" || $^O eq "cygwin" ||
48 $^O eq "djgpp" || $^O eq "MSWin32" || $^O eq "dos" ||
51 # check that localtime respects changes to $ENV{TZ}
53 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($beg);
55 ($sec,$min,$hour2,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($beg);
56 ok($hour != $hour2, 'changes to $ENV{TZ} respected');
60 skip "No gmtime()", 3 unless $does_gmtime;
62 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($beg);
63 ($xsec,$foo) = localtime($now);
65 ok($sec != $xsec && $mday && $year, 'gmtime() list context');
67 my $day_diff = $localyday - $yday;
68 ok( grep({ $day_diff == $_ } (0, 1, -1, 364, 365, -364, -365)),
69 'gmtime() and localtime() agree what day of year');
72 # This could be stricter.
73 ok(gmtime() =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat)[ ]
74 (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[ ]
75 ([ \d]\d)\ (\d\d):(\d\d):(\d\d)\ (\d{4})$
77 'gmtime(), scalar context'