File Coverage

blib/lib/Win32/IEFavorites/DateTime.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             package Win32::IEFavorites::DateTime;
2              
3 1     1   5 use strict;
  1         2  
  1         36  
4 1     1   6 use warnings;
  1         3  
  1         45  
5              
6             our $VERSION = '0.06';
7              
8 1     1   6 use base qw( DateTime );
  1         2  
  1         1502  
9 1     1   639227 use Win32::FileTime;
  0            
  0            
10              
11             sub new {
12             my ($class, $filetime) = @_;
13              
14             my $self = $class->SUPER::new( &_filetime_hash($filetime) );
15              
16             $self;
17             }
18              
19             sub _filetime_hash {
20             my $filetime_str = shift;
21              
22             # Can safely omit the last two digit of the string.
23             # See http://www.cyanwerks.com/file-format-url.html
24             # and especially his VB6 demo there.
25              
26             my @hexes = unpack('a2a2a2a2a2a2a2a2',$filetime_str);
27             my $filetime = pack(
28             'LL',
29             hex(join('', reverse @hexes[0..3] )),
30             hex(join('', reverse @hexes[4..7] )),
31             );
32              
33             my @systimes = Win32::FileTime->getTime($filetime);
34              
35             return (
36             year => $systimes[0],
37             month => $systimes[1],
38             # dayofweek => $systimes[2],
39             day => $systimes[3],
40             hour => $systimes[4],
41             minute => $systimes[5],
42             second => $systimes[6],
43             );
44             }
45              
46             1;
47             __END__