| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DateTime::Format::EXIF; |
|
2
|
|
|
|
|
|
|
$DateTime::Format::EXIF::VERSION = '0.002'; |
|
3
|
1
|
|
|
1
|
|
92659
|
use strict; |
|
|
1
|
|
|
|
|
11
|
|
|
|
1
|
|
|
|
|
26
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
93
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: DateTime parser for EXIF timestamps |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub _make_regex { |
|
11
|
1
|
|
|
1
|
|
2
|
my $date_re = '(\d{4}) : (\d{2}) : (\d{2})'; |
|
12
|
1
|
|
|
|
|
3
|
my $time_re = '(\d{2}) : (\d{2}) : (\d{2} (?: \. \d{1,9})?)'; |
|
13
|
1
|
|
|
|
|
2
|
my $tz_re = '(Z | [\+\-] \d{2} : \d{2})'; |
|
14
|
1
|
|
|
|
|
46
|
return qr/^ $date_re \s $time_re $tz_re? $/xms; |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use DateTime::Format::Builder ( |
|
19
|
1
|
|
|
|
|
8
|
parsers => { |
|
20
|
|
|
|
|
|
|
parse_datetime => [ |
|
21
|
|
|
|
|
|
|
{ |
|
22
|
|
|
|
|
|
|
params => [ qw( year month day hour minute second time_zone ) ], |
|
23
|
|
|
|
|
|
|
regex => _make_regex(), |
|
24
|
|
|
|
|
|
|
postprocess => \&_postprocess, |
|
25
|
|
|
|
|
|
|
}, |
|
26
|
|
|
|
|
|
|
], |
|
27
|
|
|
|
|
|
|
}, |
|
28
|
1
|
|
|
1
|
|
481
|
); |
|
|
1
|
|
|
|
|
483968
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _postprocess { |
|
32
|
7
|
|
|
7
|
|
13257
|
my %args = @_; |
|
33
|
7
|
|
|
|
|
19
|
my ($date, $p) = @args{qw( input parsed )}; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# timezone |
|
36
|
7
|
100
|
|
|
|
22
|
if (!$p->{time_zone}) { |
|
|
|
100
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
6
|
$p->{time_zone} = 'floating'; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
elsif ($p->{time_zone} eq 'Z') { |
|
40
|
2
|
|
|
|
|
4
|
$p->{time_zone} = 'UTC'; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# nanoseconds |
|
44
|
7
|
|
|
|
|
30
|
my ($s, $fs) = split /(?=\.)/x => $p->{second}; |
|
45
|
7
|
|
|
|
|
14
|
$p->{second} = $s; |
|
46
|
7
|
100
|
|
|
|
22
|
$p->{nanosecond} = int($fs * 1e9) if $fs; |
|
47
|
|
|
|
|
|
|
|
|
48
|
7
|
|
|
|
|
21
|
return $date; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=pod |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=encoding UTF-8 |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 NAME |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
DateTime::Format::EXIF - DateTime parser for EXIF timestamps |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 VERSION |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
version 0.002 |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
use Image::ExifTool; |
|
71
|
|
|
|
|
|
|
use DateTime::Format::EXIF; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $image_info = Image::ExifTool::ImageInfo("example.jpg"); |
|
74
|
|
|
|
|
|
|
my $dt = DateTime::Format::EXIF->parse_datetime($image_info->{DateTimeOriginal}); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
DateTime parser for EXIF timestamps |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 AUTHOR |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
liosha <liosha@cpan.org> |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This software is copyright (c) 2019 by liosha. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
89
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |