← Index
NYTProf Performance Profile   « line view »
For /usr/local/libexec/sympa/task_manager-debug.pl
  Run on Tue Jun 1 22:32:51 2021
Reported on Tue Jun 1 22:35:06 2021

Filename/usr/local/lib/perl5/site_perl/DateTime/TimeZone/OlsonDB/Change.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sDateTime::TimeZone::OlsonDB::Change::::BEGIN@3DateTime::TimeZone::OlsonDB::Change::BEGIN@3
0000s0sDateTime::TimeZone::OlsonDB::Change::::BEGIN@4DateTime::TimeZone::OlsonDB::Change::BEGIN@4
0000s0sDateTime::TimeZone::OlsonDB::Change::::BEGIN@5DateTime::TimeZone::OlsonDB::Change::BEGIN@5
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;
2
3use strict;
4use warnings;
5use namespace::autoclean;
6
7our $VERSION = '2.47';
8
9sub new {
10 my $class = shift;
11 my %p = @_;
12
13 # These are almost always mutually exclusive, except when adding
14 # an observance change and the last rule has no offset, but the
15 # new observance has an anonymous rule. In that case, prefer the
16 # offset from std defined in the observance to that in the
17 # previous rule (what a mess!).
18 if ( $p{type} eq 'observance' ) {
19 $p{offset_from_std} = $p{rule}->offset_from_std if defined $p{rule};
20 $p{offset_from_std} = $p{observance}->offset_from_std
21 if $p{observance}->offset_from_std;
22 $p{offset_from_std} ||= 0;
23 }
24 else {
25 $p{offset_from_std} = $p{observance}->offset_from_std;
26 $p{offset_from_std} = $p{rule}->offset_from_std if defined $p{rule};
27 }
28
29 $p{offset_from_utc} = $p{observance}->offset_from_utc;
30
31 $p{is_dst} = 0;
32 $p{is_dst} = 1 if $p{rule} && $p{rule}->offset_from_std;
33 $p{is_dst} = 1 if $p{observance}->offset_from_std;
34
35 if ( $p{short_name} =~ m{([\-\+\w]+)/([\-\+\w]+)} ) {
36 $p{short_name} = $p{is_dst} ? $2 : $1;
37 }
38
39 return bless \%p, $class;
40}
41
42sub utc_start_datetime { $_[0]->{utc_start_datetime} }
43sub local_start_datetime { $_[0]->{local_start_datetime} }
44sub short_name { $_[0]->{short_name} }
45sub is_dst { $_[0]->{is_dst} }
46sub observance { $_[0]->{observance} }
47sub rule { $_[0]->{rule} }
48sub offset_from_utc { $_[0]->{offset_from_utc} }
49sub offset_from_std { $_[0]->{offset_from_std} }
50sub total_offset { $_[0]->offset_from_utc + $_[0]->offset_from_std }
51
52sub two_changes_as_span {
53 my ( $c1, $c2 ) = @_;
54
55 my ( $utc_start, $local_start );
56
57 if ( defined $c1->utc_start_datetime ) {
58 $utc_start = $c1->utc_start_datetime->utc_rd_as_seconds;
59 $local_start = $c1->local_start_datetime->utc_rd_as_seconds;
60 }
61 else {
62 $utc_start = $local_start = '-inf';
63 }
64
65 my $utc_end = $c2->utc_start_datetime->utc_rd_as_seconds;
66 my $local_end = $utc_end + $c1->total_offset;
67
68 return {
69 utc_start => $utc_start,
70 utc_end => $utc_end,
71 local_start => $local_start,
72 local_end => $local_end,
73 short_name => $c1->short_name,
74 offset => $c1->total_offset,
75 is_dst => $c1->is_dst,
76 };
77}
78
79## no critic (Subroutines::ProhibitUnusedPrivateSubroutines, InputOutput::RequireCheckedSyscalls)
80sub _debug_output {
81 my $self = shift;
82
83 my $obs = $self->observance;
84
85 if ( $self->utc_start_datetime ) {
86 print ' UTC: ', $self->utc_start_datetime->datetime, "\n";
87 print ' Local: ', $self->local_start_datetime->datetime, "\n";
88 }
89 else {
90 print " First change (starts at -inf)\n";
91 }
92
93 print ' Short name: ', $self->short_name, "\n";
94 print ' UTC offset: ', $obs->offset_from_utc, "\n";
95
96 if ( $obs->offset_from_std || $self->rule ) {
97 if ( $obs->offset_from_std ) {
98 print ' Std offset: ', $obs->offset_from_std, "\n";
99 }
100
101 if ( $self->rule ) {
102 print ' Std offset: ', $self->rule->offset_from_std, ' - ',
103 $self->rule->name, " rule\n";
104 }
105 }
106 else {
107 print " Std offset: 0 - no rule\n";
108 }
109
110 print "\n";
111}
112## use critic
113
1141;