blib/lib/DateTime/Format/WindowsFileTime.pm

filter: Statementstmt 100% 25 / 25 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 97.0% 33 / 34 CC 2 SCAR 2.5
CC
2
Cov
96%
parse_datetime
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
↑ Summary
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
BranchTrueFalseTotal
$winfiletime =~ /[a-fA-F0-9]{16}/ or die "Must pass 16 character hex string to parse_datetime" 1 0 1
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__
↑ Summary