Cleaning up the Time::gmtime and Time::localtime tests and make them go past 2038.
[p5sagit/p5-mst-13.2.git] / lib / Time / localtime.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6
7     require "./test.pl";
8 }
9
10 BEGIN {
11     my $haslocal;
12     eval { my $n = localtime 0 };
13     $haslocal = 1 unless $@ && $@ =~ /unimplemented/;
14
15     skip_all("no localtime") unless $haslocal;
16 }
17
18 BEGIN {
19     my @localtime = CORE::localtime 0; # This is the function localtime.
20
21     skip_all("localtime failed") unless @localtime;
22 }
23
24 BEGIN { plan tests => 37; }
25
26 BEGIN { use_ok Time::localtime; }
27
28 for my $time (0, 2**31-1, 2**33, time) {
29     my $localtime = localtime $time;          # This is the OO localtime.
30     my @localtime = CORE::localtime $time;    # This is the localtime function
31
32     for my $method (qw(sec min hour mday mon year wday yday isdst)) {
33         is $localtime->$method, shift @localtime, "localtime($time)->$method";
34     }
35 }