line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Media::DateTime; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: A simple module to extract the timestamp from media files in an flexible manner. |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
93074
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
136
|
|
6
|
3
|
|
|
3
|
|
19
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
151
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.48'; |
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
19
|
use Carp; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
301
|
|
11
|
3
|
|
|
3
|
|
4309
|
use DateTime; |
|
3
|
|
|
|
|
656066
|
|
|
3
|
|
|
|
|
166
|
|
12
|
|
|
|
|
|
|
use Module::Pluggable |
13
|
3
|
|
|
|
|
25
|
search_path => 'Media::DateTime', |
14
|
|
|
|
|
|
|
require => 1, |
15
|
3
|
|
|
3
|
|
3286
|
sub_name => 'matchers'; |
|
3
|
|
|
|
|
34461
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
1
|
|
|
1
|
1
|
11901
|
my $that = shift; |
19
|
1
|
|
33
|
|
|
12
|
my $class = ref($that) || $that; # Enables use to call $instance->new() |
20
|
1
|
|
|
|
|
6
|
return bless {}, $class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub datetime { |
24
|
10
|
|
|
10
|
1
|
171223
|
my ( $self, $f ) = @_; |
25
|
10
|
|
|
|
|
121
|
for my $class ( $self->matchers ) { |
26
|
10
|
100
|
|
|
|
18472
|
if ( $class->match($f) ) { |
27
|
8
|
|
|
|
|
34
|
my $v = $class->datetime($f); |
28
|
8
|
100
|
|
|
|
72
|
return $v if defined $v; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
8
|
|
|
|
|
51
|
return $self->_datetime_from_filesystem_stamp($f); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _datetime_from_filesystem_stamp { |
35
|
8
|
|
|
8
|
|
21
|
my ( $self, $f ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
8
|
|
|
|
|
248
|
my $c_date = ( stat($f) )[9]; |
38
|
8
|
|
|
|
|
71
|
return DateTime->from_epoch( epoch => $c_date, time_zone => 'local' ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |