Filename | /usr/share/perl5/DateTime/Format/Builder/Parser/Strptime.pm |
Statements | Executed 18 statements in 981µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 5.24ms | 5.51ms | BEGIN@10 | DateTime::Format::Builder::Parser::Strptime::
1 | 1 | 1 | 11µs | 21µs | BEGIN@7 | DateTime::Format::Builder::Parser::Strptime::
1 | 1 | 1 | 7µs | 34µs | BEGIN@11 | DateTime::Format::Builder::Parser::Strptime::
1 | 1 | 1 | 7µs | 11µs | BEGIN@8 | DateTime::Format::Builder::Parser::Strptime::
1 | 1 | 1 | 6µs | 24µs | BEGIN@9 | DateTime::Format::Builder::Parser::Strptime::
1 | 1 | 1 | 4µs | 4µs | BEGIN@13 | DateTime::Format::Builder::Parser::Strptime::
0 | 0 | 0 | 0s | 0s | create_parser | DateTime::Format::Builder::Parser::Strptime::
0 | 0 | 0 | 0s | 0s | do_match | DateTime::Format::Builder::Parser::Strptime::
0 | 0 | 0 | 0s | 0s | post_match | DateTime::Format::Builder::Parser::Strptime::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package DateTime::Format::Builder::Parser::Strptime; | ||||
2 | { | ||||
3 | 2 | 900ns | $DateTime::Format::Builder::Parser::Strptime::VERSION = '0.81'; | ||
4 | } | ||||
5 | |||||
6 | |||||
7 | 2 | 21µs | 2 | 31µs | # spent 21µs (11+10) within DateTime::Format::Builder::Parser::Strptime::BEGIN@7 which was called:
# once (11µs+10µs) by DateTime::Format::Builder::Parser::BEGIN@1.3 at line 7 # spent 21µs making 1 call to DateTime::Format::Builder::Parser::Strptime::BEGIN@7
# spent 10µs making 1 call to strict::import |
8 | 2 | 21µs | 2 | 16µs | # spent 11µs (7+4) within DateTime::Format::Builder::Parser::Strptime::BEGIN@8 which was called:
# once (7µs+4µs) by DateTime::Format::Builder::Parser::BEGIN@1.3 at line 8 # spent 11µs making 1 call to DateTime::Format::Builder::Parser::Strptime::BEGIN@8
# spent 4µs making 1 call to warnings::import |
9 | 2 | 24µs | 2 | 41µs | # spent 24µs (6+17) within DateTime::Format::Builder::Parser::Strptime::BEGIN@9 which was called:
# once (6µs+17µs) by DateTime::Format::Builder::Parser::BEGIN@1.3 at line 9 # spent 24µs making 1 call to DateTime::Format::Builder::Parser::Strptime::BEGIN@9
# spent 17µs making 1 call to vars::import |
10 | 3 | 706µs | 3 | 5.53ms | # spent 5.51ms (5.24+269µs) within DateTime::Format::Builder::Parser::Strptime::BEGIN@10 which was called:
# once (5.24ms+269µs) by DateTime::Format::Builder::Parser::BEGIN@1.3 at line 10 # spent 5.51ms making 1 call to DateTime::Format::Builder::Parser::Strptime::BEGIN@10
# spent 14µs making 1 call to Exporter::import
# spent 9µs making 1 call to version::_VERSION |
11 | 2 | 23µs | 2 | 61µs | # spent 34µs (7+27) within DateTime::Format::Builder::Parser::Strptime::BEGIN@11 which was called:
# once (7µs+27µs) by DateTime::Format::Builder::Parser::BEGIN@1.3 at line 11 # spent 34µs making 1 call to DateTime::Format::Builder::Parser::Strptime::BEGIN@11
# spent 27µs making 1 call to Exporter::import |
12 | |||||
13 | 2 | 172µs | 1 | 4µs | # spent 4µs within DateTime::Format::Builder::Parser::Strptime::BEGIN@13 which was called:
# once (4µs+0s) by DateTime::Format::Builder::Parser::BEGIN@1.3 at line 13 # spent 4µs making 1 call to DateTime::Format::Builder::Parser::Strptime::BEGIN@13 |
14 | 1 | 5µs | @ISA = qw( DateTime::Format::Builder::Parser::generic ); | ||
15 | |||||
16 | 1 | 5µs | 1 | 8µs | __PACKAGE__->valid_params( # spent 8µs making 1 call to DateTime::Format::Builder::Parser::valid_params |
17 | strptime => { | ||||
18 | type => SCALAR | ||||
19 | | HASHREF, # straight pattern or options to DTF::Strptime | ||||
20 | }, | ||||
21 | ); | ||||
22 | |||||
23 | sub create_parser { | ||||
24 | my ( $self, %args ) = @_; | ||||
25 | |||||
26 | # Arguments to DTF::Strptime | ||||
27 | my $pattern = $args{strptime}; | ||||
28 | |||||
29 | # Create our strptime parser | ||||
30 | my $strptime = DateTime::Format::Strptime->new( | ||||
31 | ( ref $pattern ? %$pattern : ( pattern => $pattern ) ), | ||||
32 | ); | ||||
33 | unless ( ref $self ) { | ||||
34 | $self = $self->new(%args); | ||||
35 | } | ||||
36 | $self->{strptime} = $strptime; | ||||
37 | |||||
38 | # Create our parser | ||||
39 | return $self->generic_parser( | ||||
40 | ( | ||||
41 | map { exists $args{$_} ? ( $_ => $args{$_} ) : () } | ||||
42 | qw( | ||||
43 | on_match on_fail preprocess postprocess | ||||
44 | ) | ||||
45 | ), | ||||
46 | label => $args{label}, | ||||
47 | ); | ||||
48 | } | ||||
49 | |||||
50 | sub do_match { | ||||
51 | my $self = shift; | ||||
52 | my $date = shift; | ||||
53 | local $^W; # bizarre bug | ||||
54 | # Do the match! | ||||
55 | my $dt = eval { $self->{strptime}->parse_datetime($date) }; | ||||
56 | return $@ ? undef : $dt; | ||||
57 | } | ||||
58 | |||||
59 | sub post_match { | ||||
60 | return $_[2]; | ||||
61 | } | ||||
62 | |||||
63 | 1 | 3µs | 1; | ||
64 | |||||
65 | # ABSTRACT: strptime based date parsing | ||||
66 | |||||
67 | __END__ |