| 1 | package Win32::UrlCache::FileTimePP; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use base qw( Exporter ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | our @EXPORT = qw( filetime ); | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Math::BigInt try => 'GMP'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use DateTime; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use DateTime::Duration; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 2 | ▶ | sub filetime { | ||||||||||||||||||||||||||
|
Subroutine
filetime: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 2 | my $filetime = shift; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | my @bytes; | |||||||||||||||||||||||||||
| 17 | 2 | ▶ | if ( length( $filetime ) == 18 && substr( $filetime, 0, 2 ) eq '0x' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
length $filetime == 18 and substr($filetime, 0, 2) eq "0x"
MC/DC50%1/2
length $filetime == 18 and substr($filetime, 0, 2) eq "0x"
length $filetime == 18
substr($filetime, 0, 2) eq "0x"
Truth table66%2/3
A and B
A= length $filetime == 18B= substr($filetime, 0, 2) eq "0x"
| |||||||||||||||||||||||||||||
| 18 | 1 | @bytes = map { chr(hex($_)) } | |||||||||||||||||||||||||||
| 19 | substr( $filetime, 2 ) =~ /(..)/g; | ||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | else { | ||||||||||||||||||||||||||||
| 22 | 1 | @bytes = split //, $filetime; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 2 | my $hundred_nanoseconds = ( | |||||||||||||||||||||||||||
| 26 | ord( $bytes[7] ) * ( 256 ** 7 ) + | ||||||||||||||||||||||||||||
| 27 | ord( $bytes[6] ) * ( 256 ** 6 ) + | ||||||||||||||||||||||||||||
| 28 | ord( $bytes[5] ) * ( 256 ** 5 ) + | ||||||||||||||||||||||||||||
| 29 | ord( $bytes[4] ) * ( 256 ** 4 ) + | ||||||||||||||||||||||||||||
| 30 | ord( $bytes[3] ) * ( 256 ** 3 ) + | ||||||||||||||||||||||||||||
| 31 | ord( $bytes[2] ) * ( 256 ** 2 ) + | ||||||||||||||||||||||||||||
| 32 | ord( $bytes[1] ) * ( 256 ** 1 ) + | ||||||||||||||||||||||||||||
| 33 | ord( $bytes[0] ) * ( 256 ** 0 ) | ||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 2 | my $seconds = $hundred_nanoseconds / 10000000; | |||||||||||||||||||||||||||
| 37 | 2 | my $minutes = $seconds / 60; | |||||||||||||||||||||||||||
| 38 | 2 | my $hours = $minutes / 60; | |||||||||||||||||||||||||||
| 39 | 2 | my $days = $hours / 24; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 2 | my $start = DateTime->new( | |||||||||||||||||||||||||||
| 42 | year => 1601, | ||||||||||||||||||||||||||||
| 43 | month => 1, | ||||||||||||||||||||||||||||
| 44 | day => 1, | ||||||||||||||||||||||||||||
| 45 | hour => 0, | ||||||||||||||||||||||||||||
| 46 | minute => 0, | ||||||||||||||||||||||||||||
| 47 | second => 0, | ||||||||||||||||||||||||||||
| 48 | time_zone => 'GMT', | ||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | # explicitly stringify to unbless | ||||||||||||||||||||||||||||
| 52 | 2 | my $duration = DateTime::Duration->new( | |||||||||||||||||||||||||||
| 53 | days => "$days", | ||||||||||||||||||||||||||||
| 54 | hours => "".($hours % 24), | ||||||||||||||||||||||||||||
| 55 | minutes => "".($minutes % 60), | ||||||||||||||||||||||||||||
| 56 | seconds => "".($seconds % 60), | ||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 2 | my $date = $start + $duration; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 2 | 1; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||||||||||||