xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Time/localtime.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateBEGIN {
4*0Sstevel@tonic-gate    chdir 't' if -d 't';
5*0Sstevel@tonic-gate    @INC = '../lib';
6*0Sstevel@tonic-gate}
7*0Sstevel@tonic-gate
8*0Sstevel@tonic-gateBEGIN {
9*0Sstevel@tonic-gate    our $haslocal;
10*0Sstevel@tonic-gate    eval { my $n = localtime 0 };
11*0Sstevel@tonic-gate    $haslocal = 1 unless $@ && $@ =~ /unimplemented/;
12*0Sstevel@tonic-gate    unless ($haslocal) { print "1..0 # Skip: no localtime\n"; exit 0 }
13*0Sstevel@tonic-gate}
14*0Sstevel@tonic-gate
15*0Sstevel@tonic-gateBEGIN {
16*0Sstevel@tonic-gate    our @localtime = localtime 0; # This is the function localtime.
17*0Sstevel@tonic-gate    unless (@localtime) { print "1..0 # Skip: localtime failed\n"; exit 0 }
18*0Sstevel@tonic-gate}
19*0Sstevel@tonic-gate
20*0Sstevel@tonic-gateprint "1..10\n";
21*0Sstevel@tonic-gate
22*0Sstevel@tonic-gateuse Time::localtime;
23*0Sstevel@tonic-gate
24*0Sstevel@tonic-gateprint "ok 1\n";
25*0Sstevel@tonic-gate
26*0Sstevel@tonic-gatemy $localtime = localtime 0 ; # This is the OO localtime.
27*0Sstevel@tonic-gate
28*0Sstevel@tonic-gateprint "not " unless $localtime->sec   == $localtime[0];
29*0Sstevel@tonic-gateprint "ok 2\n";
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gateprint "not " unless $localtime->min   == $localtime[1];
32*0Sstevel@tonic-gateprint "ok 3\n";
33*0Sstevel@tonic-gate
34*0Sstevel@tonic-gateprint "not " unless $localtime->hour  == $localtime[2];
35*0Sstevel@tonic-gateprint "ok 4\n";
36*0Sstevel@tonic-gate
37*0Sstevel@tonic-gateprint "not " unless $localtime->mday  == $localtime[3];
38*0Sstevel@tonic-gateprint "ok 5\n";
39*0Sstevel@tonic-gate
40*0Sstevel@tonic-gateprint "not " unless $localtime->mon   == $localtime[4];
41*0Sstevel@tonic-gateprint "ok 6\n";
42*0Sstevel@tonic-gate
43*0Sstevel@tonic-gateprint "not " unless $localtime->year  == $localtime[5];
44*0Sstevel@tonic-gateprint "ok 7\n";
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gateprint "not " unless $localtime->wday  == $localtime[6];
47*0Sstevel@tonic-gateprint "ok 8\n";
48*0Sstevel@tonic-gate
49*0Sstevel@tonic-gateprint "not " unless $localtime->yday  == $localtime[7];
50*0Sstevel@tonic-gateprint "ok 9\n";
51*0Sstevel@tonic-gate
52*0Sstevel@tonic-gateprint "not " unless $localtime->isdst == $localtime[8];
53*0Sstevel@tonic-gateprint "ok 10\n";
54*0Sstevel@tonic-gate
55*0Sstevel@tonic-gate
56*0Sstevel@tonic-gate
57*0Sstevel@tonic-gate
58