← Index
NYTProf Performance Profile   « line view »
For -e
  Run on Thu Jun 30 16:16:00 2016
Reported on Thu Jun 30 16:16:08 2016

Filename/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/DateTime/TimeZone/OlsonDB/Change.pm
StatementsExecuted 8 statements in 918µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11122µs26µsDateTime::TimeZone::OlsonDB::Change::::BEGIN@3DateTime::TimeZone::OlsonDB::Change::BEGIN@3
11113µs20µsDateTime::TimeZone::OlsonDB::Change::::BEGIN@4DateTime::TimeZone::OlsonDB::Change::BEGIN@4
11111µs68µsDateTime::TimeZone::OlsonDB::Change::::BEGIN@6DateTime::TimeZone::OlsonDB::Change::BEGIN@6
0000s0sDateTime::TimeZone::OlsonDB::Change::::_debug_outputDateTime::TimeZone::OlsonDB::Change::_debug_output
0000s0sDateTime::TimeZone::OlsonDB::Change::::is_dstDateTime::TimeZone::OlsonDB::Change::is_dst
0000s0sDateTime::TimeZone::OlsonDB::Change::::local_start_datetimeDateTime::TimeZone::OlsonDB::Change::local_start_datetime
0000s0sDateTime::TimeZone::OlsonDB::Change::::newDateTime::TimeZone::OlsonDB::Change::new
0000s0sDateTime::TimeZone::OlsonDB::Change::::observanceDateTime::TimeZone::OlsonDB::Change::observance
0000s0sDateTime::TimeZone::OlsonDB::Change::::offset_from_stdDateTime::TimeZone::OlsonDB::Change::offset_from_std
0000s0sDateTime::TimeZone::OlsonDB::Change::::offset_from_utcDateTime::TimeZone::OlsonDB::Change::offset_from_utc
0000s0sDateTime::TimeZone::OlsonDB::Change::::ruleDateTime::TimeZone::OlsonDB::Change::rule
0000s0sDateTime::TimeZone::OlsonDB::Change::::short_nameDateTime::TimeZone::OlsonDB::Change::short_name
0000s0sDateTime::TimeZone::OlsonDB::Change::::total_offsetDateTime::TimeZone::OlsonDB::Change::total_offset
0000s0sDateTime::TimeZone::OlsonDB::Change::::two_changes_as_spanDateTime::TimeZone::OlsonDB::Change::two_changes_as_span
0000s0sDateTime::TimeZone::OlsonDB::Change::::utc_start_datetimeDateTime::TimeZone::OlsonDB::Change::utc_start_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::TimeZone::OlsonDB::Change;
21700ns$DateTime::TimeZone::OlsonDB::Change::VERSION = '1.98';
3232µs230µs
# spent 26µs (22+3) within DateTime::TimeZone::OlsonDB::Change::BEGIN@3 which was called: # once (22µs+3µs) by DateTime::TimeZone::BEGIN@12 at line 3
use strict;
# spent 26µs making 1 call to DateTime::TimeZone::OlsonDB::Change::BEGIN@3 # spent 4µs making 1 call to strict::import
4235µs227µs
# spent 20µs (13+7) within DateTime::TimeZone::OlsonDB::Change::BEGIN@4 which was called: # once (13µs+7µs) by DateTime::TimeZone::BEGIN@12 at line 4
use warnings;
# spent 20µs making 1 call to DateTime::TimeZone::OlsonDB::Change::BEGIN@4 # spent 7µs making 1 call to warnings::import
5
62846µs2124µs
# spent 68µs (11+56) within DateTime::TimeZone::OlsonDB::Change::BEGIN@6 which was called: # once (11µs+56µs) by DateTime::TimeZone::BEGIN@12 at line 6
use Params::Validate qw( validate SCALAR UNDEF OBJECT );
# spent 68µs making 1 call to DateTime::TimeZone::OlsonDB::Change::BEGIN@6 # spent 56µs making 1 call to Exporter::import
7
8sub new {
9 my $class = shift;
10 my %p = validate(
11 @_, {
12 utc_start_datetime => { type => UNDEF | OBJECT },
13 local_start_datetime => { type => UNDEF | OBJECT },
14 short_name => { type => SCALAR },
15 observance => { type => OBJECT },
16 rule => { type => OBJECT, default => undef },
17 type => {
18 type => SCALAR,
19 regex => qr/^(?:observance|rule)$/
20 },
21 }
22 );
23
24 # These are almost always mutually exclusive, except when adding
25 # an observance change and the last rule has no offset, but the
26 # new observance has an anonymous rule. In that case, prefer the
27 # offset from std defined in the observance to that in the
28 # previous rule (what a mess!).
29 if ( $p{type} eq 'observance' ) {
30 $p{offset_from_std} = $p{rule}->offset_from_std if defined $p{rule};
31 $p{offset_from_std} = $p{observance}->offset_from_std
32 if $p{observance}->offset_from_std;
33 $p{offset_from_std} ||= 0;
34 }
35 else {
36 $p{offset_from_std} = $p{observance}->offset_from_std;
37 $p{offset_from_std} = $p{rule}->offset_from_std if defined $p{rule};
38 }
39
40 $p{offset_from_utc} = $p{observance}->offset_from_utc;
41
42 $p{is_dst} = 0;
43 $p{is_dst} = 1 if $p{rule} && $p{rule}->offset_from_std;
44 $p{is_dst} = 1 if $p{observance}->offset_from_std;
45
46 if ( $p{short_name} =~ m{([\-\+\w]+)/([\-\+\w]+)} ) {
47 $p{short_name} = $p{is_dst} ? $2 : $1;
48 }
49
50 return bless \%p, $class;
51}
52
53sub utc_start_datetime { $_[0]->{utc_start_datetime} }
54sub local_start_datetime { $_[0]->{local_start_datetime} }
55sub short_name { $_[0]->{short_name} }
56sub is_dst { $_[0]->{is_dst} }
57sub observance { $_[0]->{observance} }
58sub rule { $_[0]->{rule} }
59sub offset_from_utc { $_[0]->{offset_from_utc} }
60sub offset_from_std { $_[0]->{offset_from_std} }
61sub total_offset { $_[0]->offset_from_utc + $_[0]->offset_from_std }
62
63sub two_changes_as_span {
64 my ( $c1, $c2, $last_total_offset ) = @_;
65
66 my ( $utc_start, $local_start );
67
68 if ( defined $c1->utc_start_datetime ) {
69 $utc_start = $c1->utc_start_datetime->utc_rd_as_seconds;
70 $local_start = $c1->local_start_datetime->utc_rd_as_seconds;
71 }
72 else {
73 $utc_start = $local_start = '-inf';
74 }
75
76 my $utc_end = $c2->utc_start_datetime->utc_rd_as_seconds;
77 my $local_end = $utc_end + $c1->total_offset;
78
79 return {
80 utc_start => $utc_start,
81 utc_end => $utc_end,
82 local_start => $local_start,
83 local_end => $local_end,
84 short_name => $c1->short_name,
85 offset => $c1->total_offset,
86 is_dst => $c1->is_dst,
87 };
88}
89
90sub _debug_output {
91 my $self = shift;
92
93 my $obs = $self->observance;
94
95 if ( $self->utc_start_datetime ) {
96 print " UTC: ", $self->utc_start_datetime->datetime, "\n";
97 print " Local: ", $self->local_start_datetime->datetime, "\n";
98 }
99 else {
100 print " First change (starts at -inf)\n";
101 }
102
103 print " Short name: ", $self->short_name, "\n";
104 print " UTC offset: ", $obs->offset_from_utc, "\n";
105
106 if ( $obs->offset_from_std || $self->rule ) {
107 if ( $obs->offset_from_std ) {
108 print " Std offset: ", $obs->offset_from_std, "\n";
109 }
110
111 if ( $self->rule ) {
112 print " Std offset: ", $self->rule->offset_from_std, ' - ',
113 $self->rule->name, " rule\n";
114 }
115 }
116 else {
117 print " Std offset: 0 - no rule\n";
118 }
119
120 print "\n";
121}
122
12314µs1;