If you know the format, grind away on it a bit and feed it to Time::Local.
| [reply] |
my $stamp = "100117104030";
my ($YY, $MM, $DD, $hh, $mm, $ss) = ($stamp =~ /^(\d{2})(\d{2})(\d{2})
+(\d{2})(\d{2})(\d{2})/);
| [reply] [d/l] |
>perl -wMstrict -le
"my $stamp = '100117104030';
my ($YY, $MM, $DD, $hh, $mm, $ss) = $stamp =~ m{ \d{2} }xmsg;
print $stamp;
print qq{$YY $MM $DD $hh $mm $ss};
"
100117104030
10 01 17 10 40 30
| [reply] [d/l] [select] |
| [reply] |
| [reply] [d/l] [select] |
use DateTime;
$dt = DateTime->new(
year => 2010,
month => 2,
day => 3,
hour => 8,
minute => 15,
second => 0,
nanosecond => 0,
time_zone => 'UTC',
);
print $dt->epoch;
Output: 1265184900Parsing your input string is left as an exercise for the reader.
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
| [reply] [d/l] |