X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXUtil.pm;h=07e3f4cb3bede190e80ae629259be3b8df7da646;hb=ca18864d1264fadfe9869b630f05c950876c2169;hp=994cdd981a735c4753aeedbedac8c46d08b1ea82;hpb=d5b4190c36f130852973121042876af3c5642cd7;p=spider.git diff --git a/perl/DXUtil.pm b/perl/DXUtil.pm index 994cdd98..07e3f4cb 100644 --- a/perl/DXUtil.pm +++ b/perl/DXUtil.pm @@ -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"); }