← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 17:10:45 2013
Reported on Tue Oct 15 17:11:59 2013

Filename/usr/share/perl5/DateTime/Format/DateParse.pm
StatementsExecuted 20 statements in 592µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111941µs4.17msDateTime::Format::DateParse::::BEGIN@14DateTime::Format::DateParse::BEGIN@14
11126µs32µsDateTime::Format::DateParse::::BEGIN@7DateTime::Format::DateParse::BEGIN@7
11122µs70µsDateTime::Format::DateParse::::BEGIN@9DateTime::Format::DateParse::BEGIN@9
11115µs16µsDateTime::Format::DateParse::::BEGIN@13DateTime::Format::DateParse::BEGIN@13
11113µs15µsDateTime::Format::DateParse::::BEGIN@12DateTime::Format::DateParse::BEGIN@12
11112µs58µsDateTime::Format::DateParse::::BEGIN@15DateTime::Format::DateParse::BEGIN@15
0000s0sDateTime::Format::DateParse::::parse_datetimeDateTime::Format::DateParse::parse_datetime
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package DateTime::Format::DateParse;
2
3# Copyright (C) 2005-6 Joshua Hoblitt
4#
5# $Id: DateParse.pm 4429 2010-04-10 19:14:33Z jhoblitt $
6
7389µs238µs
# spent 32µs (26+6) within DateTime::Format::DateParse::BEGIN@7 which was called: # once (26µs+6µs) by Koha::DateUtils::BEGIN@23 at line 7
use strict;
# spent 32µs making 1 call to DateTime::Format::DateParse::BEGIN@7 # spent 6µs making 1 call to strict::import
8
9350µs2118µs
# spent 70µs (22+48) within DateTime::Format::DateParse::BEGIN@9 which was called: # once (22µs+48µs) by Koha::DateUtils::BEGIN@23 at line 9
use vars qw($VERSION);
# spent 70µs making 1 call to DateTime::Format::DateParse::BEGIN@9 # spent 48µs making 1 call to vars::import
101700ns$VERSION = '0.05';
11
12326µs217µs
# spent 15µs (13+2) within DateTime::Format::DateParse::BEGIN@12 which was called: # once (13µs+2µs) by Koha::DateUtils::BEGIN@23 at line 12
use DateTime;
# spent 15µs making 1 call to DateTime::Format::DateParse::BEGIN@12 # spent 2µs making 1 call to UNIVERSAL::import
13330µs217µs
# spent 16µs (15+1) within DateTime::Format::DateParse::BEGIN@13 which was called: # once (15µs+1µs) by Koha::DateUtils::BEGIN@23 at line 13
use DateTime::TimeZone;
# spent 16µs making 1 call to DateTime::Format::DateParse::BEGIN@13 # spent 1µs making 1 call to UNIVERSAL::import
143138µs24.23ms
# spent 4.17ms (941µs+3.23) within DateTime::Format::DateParse::BEGIN@14 which was called: # once (941µs+3.23ms) by Koha::DateUtils::BEGIN@23 at line 14
use Date::Parse qw( strptime );
# spent 4.17ms making 1 call to DateTime::Format::DateParse::BEGIN@14 # spent 54µs making 1 call to Exporter::import
153253µs2103µs
# spent 58µs (12+46) within DateTime::Format::DateParse::BEGIN@15 which was called: # once (12µs+46µs) by Koha::DateUtils::BEGIN@23 at line 15
use Time::Zone qw( tz_offset );
# spent 58µs making 1 call to DateTime::Format::DateParse::BEGIN@15 # spent 46µs making 1 call to Exporter::import
16
17sub parse_datetime {
18 my ($class, $date, $zone) = @_;
19
20 # str2time() calls strptime() internally so it's more efficent to use
21 # strptime() directly. However, the extra validation done by using
22 # DateTime->new() instad of DateTime->from_epoch() may make it into a net
23 # loss. In the end, it turns out that strptime()'s offset information is
24 # needed anyways.
25 my @t = strptime( $date, $zone );
26
27 return undef unless @t;
28
29 my ($ss, $mm, $hh, $day, $month, $year, $offset) = @t;
30
31 my %p;
32 if ( $ss ) {
33 my $fraction = $ss - int( $ss );
34 if ($fraction) {
35 my $nano = $fraction * 1e9;
36 if ( $nano != int( $nano ) ) {
37 $nano++ if $nano - int( $nano ) >= 0.5;
38 }
39 $p{ nanosecond } = int( $nano );
40 }
41 $p{ second } = int $ss;
42 }
43 $p{ minute } = $mm if $mm;
44 $p{ hour } = $hh if $hh;
45 $p{ day } = $day if $day;
46 $p{ month } = $month + 1 if $month;
47 $p{ year } = $year ? $year + 1900 : DateTime->now->year;
48
49 # unless there is an explict ZONE, Date::Parse seems to parse date only
50 # formats, eg. "1995-01-24", as being in the 'local' timezone.
51 unless ( defined $zone || defined $offset ) {
52 return DateTime->new(
53 %p,
54 time_zone => 'local',
55 );
56 }
57
58 if ( $zone ) {
59 if ( DateTime::TimeZone->is_valid_name( $zone ) ) {
60 return DateTime->new(
61 %p,
62 time_zone => $zone,
63 );
64 } else {
65 # attempt to convert Time::Zone tz's into an offset
66 return DateTime->new(
67 %p,
68 time_zone =>
69 # not an Olson timezone, no DST info
70 DateTime::TimeZone::offset_as_string( tz_offset( $zone ) ),
71 );
72 }
73 }
74
75 return DateTime->new(
76 %p,
77 time_zone =>
78 # not an Olson timezone, no DST info
79 DateTime::TimeZone::offset_as_string( $offset ),
80 );
81}
82
8314µs1;
84
85__END__