10 # Set up time values to test
13 #year,mon,day,hour,min,sec
14 [1970, 1, 1, 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 print "1..", @time * 2 + 5, "\n";
26 my($year, $mon, $mday, $hour, $min, $sec) = @$_;
29 my $time = timelocal($sec,$min,$hour,$mday,$mon,$year);
30 # print scalar(localtime($time)), "\n";
31 my($s,$m,$h,$D,$M,$Y) = localtime($time);
42 print "not ok $count\n";
46 # Test gmtime function
47 $time = timegm($sec,$min,$hour,$mday,$mon,$year);
48 ($s,$m,$h,$D,$M,$Y) = gmtime($time);
59 print "not ok $count\n";
64 #print "Testing that the differences between a few dates makes sence...\n";
66 timelocal(0,0,1,1,0,90) - timelocal(0,0,0,1,0,90) == 3600
68 print "ok ", $count++, "\n";
70 timelocal(1,2,3,1,0,100) - timelocal(1,2,3,31,11,99) == 24 * 3600
72 print "ok ", $count++, "\n";
74 # Diff beween Jan 1, 1970 and Mar 1, 1970 = (31 + 28 = 59 days)
75 timegm(0,0,0, 1, 2, 70) - timegm(0,0,0, 1, 0, 70) == 59 * 24 * 3600
77 print "ok ", $count++, "\n";
80 #print "Testing timelocal.pl module too...\n";
82 require 'timelocal.pl';
83 timegm(0,0,0,1,0,70) == main::timegm(0,0,0,1,0,70) or print "not ";
84 print "ok ", $main::count++, "\n";
86 timelocal(1,2,3,4,5,78) == main::timelocal(1,2,3,4,5,78) or print "not ";
87 print "ok ", $main::count++, "\n";