Update some docs to explain that Perl no longer has a 2038 bug.
[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 # Since Perl's localtime() still uses the system localtime, don't try
29 # to do negative times.  The system might not support it.
30 for my $time (0, 2**31-1, 2**33, time) {
31     my $localtime = localtime $time;          # This is the OO localtime.
32     my @localtime = CORE::localtime $time;    # This is the localtime function
33
34     for my $method (qw(sec min hour mday mon year wday yday isdst)) {
35         is $localtime->$method, shift @localtime, "localtime($time)->$method";
36     }
37 }