*** empty log message ***
[spider.git] / perl / DXUtil.pm
index 5c6c51af3a5a556100a6a62c4c6293d7cfcde68a..07e3f4cb3bede190e80ae629259be3b8df7da646 100644 (file)
@@ -46,7 +46,7 @@ sub cldate
        my $t = shift;
        my ($sec,$min,$hour,$mday,$mon,$year) = gmtime((defined $t) ? $t : time);
        $year += 1900;
-       my $buf = sprintf "%02d-%s-%04d", $mday, $month[$mon], $year;
+       my $buf = sprintf "%2d-%s-%04d", $mday, $month[$mon], $year;
        return $buf;
 }
 
@@ -64,8 +64,14 @@ sub cltounix
 {
        my $date = shift;
        my $time = shift;
-       $date =~ s/^\s*(\d+)-(\w\w\w)-(19\d\d)$/$1 $2 $3/;
-       $time =~ s/^(\d\d)(\d\d)Z$/$1:$2 +0000/;
+       my ($thisyear) = (gmtime)[5] + 1900;
+
+       return 0 unless $date =~ /^\s*(\d+)-(\w\w\w)-([12][90]\d\d)$/;
+       return 0 if $3 > 2036;
+       return 0 unless abs($thisyear-$3) <= 1;
+       $date = "$1 $2 $3";
+       return 0 unless $time =~ /^([012]\d)([012345]\d)Z$/;
+       $time = "$1:$2 +0000";
        return str2time("$date $time");
 }