| 1 | package DateTime::Format::WindowsFileTime; | ||||||||||
| 2 | 1 | ▶ | use DateTime; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use Math::BigInt; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use 5.008005; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | our $VERSION = '0.02'; | |||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | sub parse_datetime { | ||||||||
|
Subroutine
parse_datetime: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 11 | 1 | my($class, $winfiletime) = @_; | |||||||||
| 12 | 1 | ▶ | $winfiletime =~ /[a-fA-F0-9]{16}/ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | or die "Must pass 16 character hex string to parse_datetime"; | ||||||||||
| 14 | |||||||||||
| 15 | 1 | $winfiletime = "0x$winfiletime"; # prepend 0x so perl sees it as hex value | |||||||||
| 16 | 1 | my $bint = Math::BigInt->new( $winfiletime ); | |||||||||
| 17 | 1 | $bint = $bint / 10000; # was centi-nanoseconds, now it's not | |||||||||
| 18 | 1 | $bint -= 11644473600000; # the difference between epochs | |||||||||
| 19 | 1 | my $seconds = $bint / 1000; | |||||||||
| 20 | 1 | my $dt = DateTime->from_epoch( epoch => $seconds->numify ); | |||||||||
| 21 | 1 | return $dt; | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | 1 | 1; | |||||||||
| 25 | |||||||||||
| 26 | __END__ | ||||||||||