line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BusyBird::DateTime::Format; |
2
|
2
|
|
|
2
|
|
279518
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
72
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
61
|
|
4
|
2
|
|
|
2
|
|
2229
|
use DateTime::Format::Strptime; |
|
2
|
|
|
|
|
225768
|
|
|
2
|
|
|
|
|
139
|
|
5
|
2
|
|
|
2
|
|
23
|
use Try::Tiny; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
647
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.05"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $preferred = 0; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my %OPT_DEFAULT = ( |
12
|
|
|
|
|
|
|
locale => 'en_US', |
13
|
|
|
|
|
|
|
on_error => 'undef', |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my @FORMATS = ( |
17
|
|
|
|
|
|
|
DateTime::Format::Strptime->new( |
18
|
|
|
|
|
|
|
%OPT_DEFAULT, |
19
|
|
|
|
|
|
|
pattern => '%a %b %d %T %z %Y', |
20
|
|
|
|
|
|
|
), |
21
|
|
|
|
|
|
|
DateTime::Format::Strptime->new( |
22
|
|
|
|
|
|
|
%OPT_DEFAULT, |
23
|
|
|
|
|
|
|
pattern => '%a, %d %b %Y %T %z', |
24
|
|
|
|
|
|
|
), |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
0
|
|
|
0
|
1
|
0
|
my ($class) = @_; |
29
|
0
|
|
|
|
|
0
|
return bless {}, $class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub parse_datetime { |
33
|
10
|
|
|
10
|
1
|
7278
|
my ($class_self, $string) = @_; |
34
|
10
|
|
|
|
|
13
|
my $parsed; |
35
|
10
|
100
|
|
|
|
56
|
return undef if not defined $string; |
36
|
9
|
|
|
|
|
16
|
foreach my $f (@FORMATS) { |
37
|
|
|
|
|
|
|
$parsed = try { |
38
|
13
|
|
|
13
|
|
374
|
$f->parse_datetime($string); |
39
|
|
|
|
|
|
|
}catch { |
40
|
0
|
|
|
0
|
|
0
|
undef; |
41
|
13
|
|
|
|
|
87
|
}; |
42
|
13
|
100
|
|
|
|
8494
|
last if defined($parsed); |
43
|
|
|
|
|
|
|
} |
44
|
9
|
|
|
|
|
22
|
return $parsed; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub format_datetime { |
48
|
5
|
|
|
5
|
1
|
13658
|
my ($class_self, $datetime) = @_; |
49
|
5
|
|
|
|
|
23
|
return $FORMATS[$preferred]->format_datetime($datetime); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
__END__ |