File Coverage

blib/lib/DateTime/Format/WindowsFileTime.pm
Criterion Covered Total %
statement 24 24 100.0
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 32 33 96.9


line stmt bran cond sub pod time code
1             package DateTime::Format::WindowsFileTime;
2 1     1   27116 use DateTime;
  1         281575  
  1         39  
3 1     1   1719 use Math::BigInt;
  1         41600  
  1         10  
4              
5 1     1   20272 use 5.008005;
  1         12  
  1         35  
6 1     1   5 use strict;
  1         1  
  1         35  
7 1     1   5 use warnings;
  1         2  
  1         187  
8             our $VERSION = '0.02';
9              
10             sub parse_datetime {
11 1     1 1 16 my($class, $winfiletime) = @_;
12 1 50       7 $winfiletime =~ /[a-fA-F0-9]{16}/
13             or die "Must pass 16 character hex string to parse_datetime";
14              
15 1         4 $winfiletime = "0x$winfiletime"; # prepend 0x so perl sees it as hex value
16 1         13 my $bint = Math::BigInt->new( $winfiletime );
17 1         340 $bint = $bint / 10000; # was centi-nanoseconds, now it's not
18 1         271 $bint -= 11644473600000; # the difference between epochs
19 1         208 my $seconds = $bint / 1000;
20 1         174 my $dt = DateTime->from_epoch( epoch => $seconds->numify );
21 1         466 return $dt;
22             }
23              
24             1;
25              
26             __END__