in reply to Candle Time
my $Y = $C . (join "", @bits[ 1,2]); ... $Y-1900,
Well, that seems wrong, if $Y is first 3 chars, just get it that way , no need for append/add/subtract..
Also,
If your year isn't 4 digits, are you sure your month is off-by-one?1130508154533613 = 2013-05-08 15:45:33.613 c:20 y:2013 M:05 D:08 h:15 m:45 s:33 Wed May 8 15:45:33 2013
I get
#!/usr/bin/perl -- use strict; use warnings; Fudge('1130508154533613'); sub Fudge { use POSIX(); my( $Y , $M, $D, $h, $m, $s , $ms ) = $_[-1] =~ m{^(.{3})(..)(..)( +..)(..)(..)(...)$}; my $epoch = POSIX::mktime( $s, $m, $h, $D, $M, $Y, -1, -1, -1 ); print "$epoch = ", POSIX::strftime('%Y-%m-%d %H:%M:%S', $s, $m, $h, $D, $M, $Y, - +1, -1, -1 ), ".$ms" , $/; print scalar localtime $epoch; print $/; } __END__ 1370731533 = 2013-06-08 15:45:33.613 Sat Jun 8 15:45:33 2013
|
|---|