line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::Format::Builder::Parser::Strptime; |
2
|
|
|
|
|
|
|
|
3
|
24
|
|
|
24
|
|
161
|
use strict; |
|
24
|
|
|
|
|
51
|
|
|
24
|
|
|
|
|
673
|
|
4
|
24
|
|
|
24
|
|
120
|
use warnings; |
|
24
|
|
|
|
|
41
|
|
|
24
|
|
|
|
|
1116
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.82'; |
7
|
|
|
|
|
|
|
|
8
|
24
|
|
|
24
|
|
13757
|
use DateTime::Format::Strptime 1.04; |
|
24
|
|
|
|
|
1744468
|
|
|
24
|
|
|
|
|
155
|
|
9
|
24
|
|
|
24
|
|
2053
|
use Params::Validate qw( validate SCALAR HASHREF ); |
|
24
|
|
|
|
|
60
|
|
|
24
|
|
|
|
|
1468
|
|
10
|
|
|
|
|
|
|
|
11
|
24
|
|
|
24
|
|
164
|
use parent 'DateTime::Format::Builder::Parser::generic'; |
|
24
|
|
|
|
|
55
|
|
|
24
|
|
|
|
|
179
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
__PACKAGE__->valid_params( |
14
|
|
|
|
|
|
|
strptime => { |
15
|
|
|
|
|
|
|
type => SCALAR |
16
|
|
|
|
|
|
|
| HASHREF, # straight pattern or options to DTF::Strptime |
17
|
|
|
|
|
|
|
}, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub create_parser { |
21
|
29
|
|
|
29
|
0
|
86
|
my ( $self, %args ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Arguments to DTF::Strptime |
24
|
29
|
|
|
|
|
62
|
my $pattern = $args{strptime}; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Create our strptime parser |
27
|
29
|
50
|
|
|
|
129
|
my $strptime = DateTime::Format::Strptime->new( |
28
|
|
|
|
|
|
|
( ref $pattern ? %$pattern : ( pattern => $pattern ) ), |
29
|
|
|
|
|
|
|
); |
30
|
29
|
50
|
|
|
|
38101
|
unless ( ref $self ) { |
31
|
29
|
|
|
|
|
171
|
$self = $self->new(%args); |
32
|
|
|
|
|
|
|
} |
33
|
29
|
|
|
|
|
84
|
$self->{strptime} = $strptime; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Create our parser |
36
|
|
|
|
|
|
|
return $self->generic_parser( |
37
|
|
|
|
|
|
|
( |
38
|
116
|
50
|
|
|
|
336
|
map { exists $args{$_} ? ( $_ => $args{$_} ) : () } |
39
|
|
|
|
|
|
|
qw( |
40
|
|
|
|
|
|
|
on_match on_fail preprocess postprocess |
41
|
|
|
|
|
|
|
) |
42
|
|
|
|
|
|
|
), |
43
|
|
|
|
|
|
|
label => $args{label}, |
44
|
29
|
|
|
|
|
72
|
); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub do_match { |
48
|
43
|
|
|
43
|
1
|
72
|
my $self = shift; |
49
|
43
|
|
|
|
|
65
|
my $date = shift; |
50
|
43
|
|
|
|
|
125
|
local $^W; # bizarre bug |
51
|
|
|
|
|
|
|
# Do the match! |
52
|
43
|
|
|
|
|
74
|
my $dt = eval { $self->{strptime}->parse_datetime($date) }; |
|
43
|
|
|
|
|
116
|
|
53
|
43
|
50
|
|
|
|
10898
|
return $@ ? undef : $dt; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub post_match { |
57
|
14
|
|
|
14
|
1
|
33
|
return $_[2]; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# ABSTRACT: strptime based date parsing |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=pod |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=encoding UTF-8 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 NAME |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
DateTime::Format::Builder::Parser::Strptime - strptime based date parsing |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 VERSION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
version 0.82 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SYNOPSIS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $parser = DateTime::Format::Builder->create_parser( |
81
|
|
|
|
|
|
|
strptime => '%e/%b/%Y:%H:%M:%S %z', |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SPECIFICATION |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=over 4 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
B<strptime> takes as its argument a strptime string. |
91
|
|
|
|
|
|
|
See L<DateTime::Format::Strptime> for more information |
92
|
|
|
|
|
|
|
on valid patterns. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SEE ALSO |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
C<datetime@perl.org> mailing list. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
http://datetime.perl.org/ |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
L<perl>, L<DateTime>, |
103
|
|
|
|
|
|
|
L<DateTime::Format::Builder> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SUPPORT |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Bugs may be submitted at L<http://rt.cpan.org/Public/Dist/Display.html?Name=DateTime-Format-Builder> or via email to L<bug-datetime-format-builder@rt.cpan.org|mailto:bug-datetime-format-builder@rt.cpan.org>. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 SOURCE |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The source code repository for DateTime-Format-Builder can be found at L<https://github.com/houseabsolute/DateTime-Format-Builder>. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 AUTHORS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over 4 |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Iain Truskett |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=back |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This software is Copyright (c) 2019 by Dave Rolsky. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This is free software, licensed under: |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
The full text of the license can be found in the |
138
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |