← 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 11:58:52 2013
Reported on Tue Oct 15 12:01:35 2013

Filename/usr/share/perl5/DateTime/Format/DateParse.pm
StatementsExecuted 20 statements in 897µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.15ms4.74msDateTime::Format::DateParse::::BEGIN@14DateTime::Format::DateParse::BEGIN@14
11119µs23µsDateTime::Format::DateParse::::BEGIN@7DateTime::Format::DateParse::BEGIN@7
11115µs15µsDateTime::Format::DateParse::::BEGIN@13DateTime::Format::DateParse::BEGIN@13
11112µs64µsDateTime::Format::DateParse::::BEGIN@15DateTime::Format::DateParse::BEGIN@15
1119µs34µsDateTime::Format::DateParse::::BEGIN@9DateTime::Format::DateParse::BEGIN@9
1117µs7µsDateTime::Format::DateParse::::BEGIN@12DateTime::Format::DateParse::BEGIN@12
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
7331µs227µs
# spent 23µs (19+4) within DateTime::Format::DateParse::BEGIN@7 which was called: # once (19µs+4µs) by Koha::DateUtils::BEGIN@23 at line 7
use strict;
# spent 23µs making 1 call to DateTime::Format::DateParse::BEGIN@7 # spent 4µs making 1 call to strict::import
8
93310µs259µs
# spent 34µs (9+25) within DateTime::Format::DateParse::BEGIN@9 which was called: # once (9µs+25µs) by Koha::DateUtils::BEGIN@23 at line 9
use vars qw($VERSION);
# spent 34µs making 1 call to DateTime::Format::DateParse::BEGIN@9 # spent 25µs making 1 call to vars::import
101900ns$VERSION = '0.05';
11
12327µs17µs
# spent 7µs within DateTime::Format::DateParse::BEGIN@12 which was called: # once (7µs+0s) by Koha::DateUtils::BEGIN@23 at line 12
use DateTime;
# spent 7µs making 1 call to DateTime::Format::DateParse::BEGIN@12
13366µs115µs
# spent 15µs within DateTime::Format::DateParse::BEGIN@13 which was called: # once (15µs+0s) by Koha::DateUtils::BEGIN@23 at line 13
use DateTime::TimeZone;
# spent 15µs making 1 call to DateTime::Format::DateParse::BEGIN@13
143186µs24.81ms
# spent 4.74ms (1.15+3.59) within DateTime::Format::DateParse::BEGIN@14 which was called: # once (1.15ms+3.59ms) by Koha::DateUtils::BEGIN@23 at line 14
use Date::Parse qw( strptime );
# spent 4.74ms making 1 call to DateTime::Format::DateParse::BEGIN@14 # spent 74µs making 1 call to Exporter::import
153271µs2117µs
# spent 64µs (12+53) within DateTime::Format::DateParse::BEGIN@15 which was called: # once (12µs+53µs) by Koha::DateUtils::BEGIN@23 at line 15
use Time::Zone qw( tz_offset );
# spent 64µs making 1 call to DateTime::Format::DateParse::BEGIN@15 # spent 53µ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
8315µs1;
84
85__END__