added extra validation to the year. need my own routine.
[spider.git] / perl / DXUtil.pm
index f5263a271f55d20d9fd49b811bf389ff0d03ec3b..fe82721e16c04e5bdf0095eb56f347b5a3e6609d 100644 (file)
@@ -64,10 +64,12 @@ sub cltounix
 {
        my $date = shift;
        my $time = shift;
+       my ($thisyear) = (gmtime)[5] + 1900;
 
-       return 0 unless /^\s*(\d+)-(\w\w\w)-([12][90]\d\d)$/;
+       return 0 unless $date =~ /^\s*(\d+)-(\w\w\w)-([12][90]\d\d)$/;
+       return 0 unless abs($thisyear-$3) <= 1;
        $date = "$1 $2 $3";
-       return 0 unless /^(\d\d)(\d\d)Z$/;
+       return 0 unless $time =~ /^([012]\d)([012345]\d)Z$/;
        $time = "$1:$2 +0000";
        return str2time("$date $time");
 }