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
|
|
39497
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
88
|
|
6
|
3
|
|
|
3
|
|
11
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
109
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.49'; |
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
11
|
use Carp; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
185
|
|
11
|
3
|
|
|
3
|
|
2173
|
use DateTime; |
|
3
|
|
|
|
|
284677
|
|
|
3
|
|
|
|
|
140
|
|
12
|
|
|
|
|
|
|
use Module::Pluggable |
13
|
3
|
|
|
|
|
20
|
search_path => 'Media::DateTime', |
14
|
|
|
|
|
|
|
require => 1, |
15
|
3
|
|
|
3
|
|
1530
|
sub_name => 'matchers'; |
|
3
|
|
|
|
|
24145
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
1
|
|
|
1
|
1
|
2701
|
my $that = shift; |
19
|
1
|
|
33
|
|
|
5
|
my $class = ref($that) || $that; # Enables use to call $instance->new() |
20
|
1
|
|
|
|
|
3
|
return bless {}, $class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub datetime { |
24
|
10
|
|
|
10
|
1
|
31959
|
my ( $self, $f ) = @_; |
25
|
10
|
|
|
|
|
57
|
for my $class ( $self->matchers ) { |
26
|
10
|
100
|
|
|
|
11981
|
if ( $class->match($f) ) { |
27
|
8
|
|
|
|
|
24
|
my $v = $class->datetime($f); |
28
|
8
|
100
|
|
|
|
77
|
return $v if defined $v; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
8
|
|
|
|
|
43
|
return $self->_datetime_from_filesystem_stamp($f); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _datetime_from_filesystem_stamp { |
35
|
8
|
|
|
8
|
|
16
|
my ( $self, $f ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
8
|
|
|
|
|
193
|
my $c_date = ( stat($f) )[9]; |
38
|
8
|
|
|
|
|
64
|
return DateTime->from_epoch( epoch => $c_date, time_zone => 'local' ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |