package timegm; require Exporter; @ISA =qw(Exporter); @EXPORT=qw(timegm); use strict; # Returns number of GMT seconds since 1970-01-01Z00:00:00. # Basically it's the opposite of the gmtime function. sub timegm(@) { my ($sec,$min,$hour,$mday,$month,$year)=@_; $year+=1900; my $days=365*($year-1970) +(int($year/4 )-int(1970/4)) -(int($year/100)-int(1970/100)) +(int($year/400)-int(1970/400)); for(my $i=0;$i<$month;$i++) { $days+=(31,28,31,30,31,30,31,31,30,31,30,31)[$i]; } $days-- if($month<2 and 0==($year%4?1:0)-($year%100?1:0)+($year%400?1:0)); $days+=$mday-1; return $sec+60*$min+3600*$hour+86400*$days; } 1;