xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Time/gmtime.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 $hasgm;
10*0Sstevel@tonic-gate    eval { my $n = gmtime 0 };
11*0Sstevel@tonic-gate    $hasgm = 1 unless $@ && $@ =~ /unimplemented/;
12*0Sstevel@tonic-gate    unless ($hasgm) { print "1..0 # Skip: no gmtime\n"; exit 0 }
13*0Sstevel@tonic-gate}
14*0Sstevel@tonic-gate
15*0Sstevel@tonic-gateBEGIN {
16*0Sstevel@tonic-gate    our @gmtime = gmtime 0; # This is the function gmtime.
17*0Sstevel@tonic-gate    unless (@gmtime) { print "1..0 # Skip: gmtime 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::gmtime;
23*0Sstevel@tonic-gate
24*0Sstevel@tonic-gateprint "ok 1\n";
25*0Sstevel@tonic-gate
26*0Sstevel@tonic-gatemy $gmtime = gmtime 0 ; # This is the OO gmtime.
27*0Sstevel@tonic-gate
28*0Sstevel@tonic-gateprint "not " unless $gmtime->sec   == $gmtime[0];
29*0Sstevel@tonic-gateprint "ok 2\n";
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gateprint "not " unless $gmtime->min   == $gmtime[1];
32*0Sstevel@tonic-gateprint "ok 3\n";
33*0Sstevel@tonic-gate
34*0Sstevel@tonic-gateprint "not " unless $gmtime->hour  == $gmtime[2];
35*0Sstevel@tonic-gateprint "ok 4\n";
36*0Sstevel@tonic-gate
37*0Sstevel@tonic-gateprint "not " unless $gmtime->mday  == $gmtime[3];
38*0Sstevel@tonic-gateprint "ok 5\n";
39*0Sstevel@tonic-gate
40*0Sstevel@tonic-gateprint "not " unless $gmtime->mon   == $gmtime[4];
41*0Sstevel@tonic-gateprint "ok 6\n";
42*0Sstevel@tonic-gate
43*0Sstevel@tonic-gateprint "not " unless $gmtime->year  == $gmtime[5];
44*0Sstevel@tonic-gateprint "ok 7\n";
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gateprint "not " unless $gmtime->wday  == $gmtime[6];
47*0Sstevel@tonic-gateprint "ok 8\n";
48*0Sstevel@tonic-gate
49*0Sstevel@tonic-gateprint "not " unless $gmtime->yday  == $gmtime[7];
50*0Sstevel@tonic-gateprint "ok 9\n";
51*0Sstevel@tonic-gate
52*0Sstevel@tonic-gateprint "not " unless $gmtime->isdst == $gmtime[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