5 unshift @INC, '../lib';
10 # Set up time values to test
13 #year,mon,day,hour,min,sec
14 [1970, 1, 2, 00, 00, 00],
15 [1980, 2, 28, 12, 00, 00],
16 [1980, 2, 29, 12, 00, 00],
17 [1999, 12, 31, 23, 59, 59],
18 [2000, 1, 1, 00, 00, 00],
19 [2010, 10, 12, 14, 13, 12],
22 # use vmsish 'time' makes for oddness around the Unix epoch
23 if ($^O eq 'VMS') { $time[0][2]++ }
25 print "1..", @time * 2 + 5, "\n";
29 my($year, $mon, $mday, $hour, $min, $sec) = @$_;
32 my $time = timelocal($sec,$min,$hour,$mday,$mon,$year);
33 # print scalar(localtime($time)), "\n";
34 my($s,$m,$h,$D,$M,$Y) = localtime($time);
45 print "not ok $count\n";
49 # Test gmtime function
50 $time = timegm($sec,$min,$hour,$mday,$mon,$year);
51 ($s,$m,$h,$D,$M,$Y) = gmtime($time);
62 print "not ok $count\n";
67 #print "Testing that the differences between a few dates makes sence...\n";
69 timelocal(0,0,1,1,0,90) - timelocal(0,0,0,1,0,90) == 3600
71 print "ok ", $count++, "\n";
73 timelocal(1,2,3,1,0,100) - timelocal(1,2,3,31,11,99) == 24 * 3600
75 print "ok ", $count++, "\n";
77 # Diff beween Jan 1, 1970 and Mar 1, 1970 = (31 + 28 = 59 days)
78 timegm(0,0,0, 1, 2, 70) - timegm(0,0,0, 1, 0, 70) == 59 * 24 * 3600
80 print "ok ", $count++, "\n";
83 #print "Testing timelocal.pl module too...\n";
85 require 'timelocal.pl';
86 timegm(0,0,0,1,0,70) == main::timegm(0,0,0,1,0,70) or print "not ";
87 print "ok ", $main::count++, "\n";
89 timelocal(1,2,3,4,5,78) == main::timelocal(1,2,3,4,5,78) or print "not ";
90 print "ok ", $main::count++, "\n";