Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DateTime/Format/Builder/Parser/Strptime.pm |
Statements | Executed 16 statements in 1.82ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 12µs | 15µs | BEGIN@27 | DateTime::Format::Builder::Parser::Strptime::
1 | 1 | 1 | 8µs | 41µs | BEGIN@28 | DateTime::Format::Builder::Parser::Strptime::
1 | 1 | 1 | 6µs | 40µs | BEGIN@29 | DateTime::Format::Builder::Parser::Strptime::
1 | 1 | 1 | 4µs | 4µs | BEGIN@32 | 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 | =head1 NAME | ||||
4 | |||||
5 | DateTime::Format::Builder::Parser::Strptime - strptime based date parsing | ||||
6 | |||||
7 | =head1 SYNOPSIS | ||||
8 | |||||
9 | my $parser = DateTime::Format::Builder->create_parser( | ||||
10 | strptime => '%e/%b/%Y:%H:%M:%S %z', | ||||
11 | ); | ||||
12 | |||||
13 | =head1 SPECIFICATION | ||||
14 | |||||
15 | =over 4 | ||||
16 | |||||
17 | =item * | ||||
18 | |||||
19 | B<strptime> takes as its argument a strptime string. | ||||
20 | See L<DateTime::Format::Strptime> for more information | ||||
21 | on valid patterns. | ||||
22 | |||||
23 | =back | ||||
24 | |||||
25 | =cut | ||||
26 | |||||
27 | 3 | 20µs | 2 | 17µs | # spent 15µs (12+2) within DateTime::Format::Builder::Parser::Strptime::BEGIN@27 which was called:
# once (12µs+2µs) by DateTime::Format::Builder::Parser::BEGIN@1.41 at line 27 # spent 15µs making 1 call to DateTime::Format::Builder::Parser::Strptime::BEGIN@27
# spent 2µs making 1 call to strict::import |
28 | 3 | 21µs | 2 | 74µs | # spent 41µs (8+33) within DateTime::Format::Builder::Parser::Strptime::BEGIN@28 which was called:
# once (8µs+33µs) by DateTime::Format::Builder::Parser::BEGIN@1.41 at line 28 # spent 41µs making 1 call to DateTime::Format::Builder::Parser::Strptime::BEGIN@28
# spent 33µs making 1 call to vars::import |
29 | 3 | 26µs | 2 | 73µs | # spent 40µs (6+33) within DateTime::Format::Builder::Parser::Strptime::BEGIN@29 which was called:
# once (6µs+33µs) by DateTime::Format::Builder::Parser::BEGIN@1.41 at line 29 # spent 40µs making 1 call to DateTime::Format::Builder::Parser::Strptime::BEGIN@29
# spent 33µs making 1 call to Exporter::import |
30 | |||||
31 | 1 | 2µs | $VERSION = '0.77'; | ||
32 | 3 | 1.70ms | 1 | 4µs | # spent 4µs within DateTime::Format::Builder::Parser::Strptime::BEGIN@32 which was called:
# once (4µs+0s) by DateTime::Format::Builder::Parser::BEGIN@1.41 at line 32 # spent 4µs making 1 call to DateTime::Format::Builder::Parser::Strptime::BEGIN@32 |
33 | 1 | 23µs | @ISA = qw( DateTime::Format::Builder::Parser::generic ); | ||
34 | |||||
35 | 1 | 15µs | 1 | 37µs | __PACKAGE__->valid_params( # spent 37µs making 1 call to DateTime::Format::Builder::Parser::valid_params |
36 | strptime => { | ||||
37 | type => SCALAR|HASHREF, # straight pattern or options to DTF::Strptime | ||||
38 | }, | ||||
39 | ); | ||||
40 | |||||
41 | sub create_parser | ||||
42 | { | ||||
43 | my ($self, %args) = @_; | ||||
44 | |||||
45 | # Arguments to DTF::Strptime | ||||
46 | my $pattern = $args{strptime}; | ||||
47 | |||||
48 | # Create our strptime parser | ||||
49 | require DateTime::Format::Strptime; | ||||
50 | my $strptime = DateTime::Format::Strptime->new( | ||||
51 | ( ref $pattern ? %$pattern : ( pattern => $pattern ) ), | ||||
52 | ); | ||||
53 | unless (ref $self) | ||||
54 | { | ||||
55 | $self = $self->new( %args ); | ||||
56 | } | ||||
57 | $self->{strptime} = $strptime; | ||||
58 | |||||
59 | # Create our parser | ||||
60 | return $self->generic_parser( | ||||
61 | ( map { exists $args{$_} ? ( $_ => $args{$_} ) : () } qw( | ||||
62 | on_match on_fail preprocess postprocess | ||||
63 | ) ), | ||||
64 | label => $args{label}, | ||||
65 | ); | ||||
66 | } | ||||
67 | |||||
68 | sub do_match | ||||
69 | { | ||||
70 | my $self = shift; | ||||
71 | my $date = shift; | ||||
72 | local $^W; # bizarre bug | ||||
73 | # Do the match! | ||||
74 | my $dt = eval { $self->{strptime}->parse_datetime( $date ) }; | ||||
75 | return $@ ? undef : $dt; | ||||
76 | } | ||||
77 | |||||
78 | sub post_match | ||||
79 | { | ||||
80 | return $_[2]; | ||||
81 | } | ||||
82 | |||||
83 | 1 | 7µs | 1; | ||
84 | |||||
85 | __END__ |