use strict; use warnings; use Time::Piece; my $time_str = shift; print c2e($time_str); sub c2e{ $time_str = shift; $time_str =~ m/^([a-z]+) +([a-z]+) +(\d+) (\d{2}:\d{2}:\d{2}) .*(\d{4})/i or die "invalid format"; return Time::Piece->strptime("$1 $2 $3 $4 $5", "%a %b %d %T %Y")->epoch - 32400; }
手動でJST-9のタイムゾーンの修正を入れているのが何ともアレですが・・・。Cygwinだから?それと何かもうまい方法があるのでしょうか。そしてこの投げやりな正規表現。
まあ、動くからOKということで。
$ perl c2e.pl "Fri Jun 18 14:15:53 2010" 1276838153 $ perl -le 'print scalar localtime 1276838153' Fri Jun 18 14:15:53 2010