| Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DateTime/TimeZone/OffsetOnly.pm |
| Statements | Executed 22 statements in 464µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 197µs | 253µs | DateTime::TimeZone::OffsetOnly::BEGIN@11 |
| 1 | 1 | 1 | 12µs | 14µs | DateTime::TimeZone::OffsetOnly::BEGIN@6 |
| 1 | 1 | 1 | 9µs | 62µs | DateTime::TimeZone::OffsetOnly::BEGIN@12 |
| 1 | 1 | 1 | 8µs | 33µs | DateTime::TimeZone::OffsetOnly::BEGIN@9 |
| 1 | 1 | 1 | 6µs | 13µs | DateTime::TimeZone::OffsetOnly::BEGIN@7 |
| 4 | 2 | 1 | 4µs | 4µs | DateTime::TimeZone::OffsetOnly::is_utc |
| 0 | 0 | 0 | 0s | 0s | DateTime::TimeZone::OffsetOnly::STORABLE_freeze |
| 0 | 0 | 0 | 0s | 0s | DateTime::TimeZone::OffsetOnly::STORABLE_thaw |
| 0 | 0 | 0 | 0s | 0s | DateTime::TimeZone::OffsetOnly::category |
| 0 | 0 | 0 | 0s | 0s | DateTime::TimeZone::OffsetOnly::is_dst_for_datetime |
| 0 | 0 | 0 | 0s | 0s | DateTime::TimeZone::OffsetOnly::new |
| 0 | 0 | 0 | 0s | 0s | DateTime::TimeZone::OffsetOnly::offset_for_datetime |
| 0 | 0 | 0 | 0s | 0s | DateTime::TimeZone::OffsetOnly::offset_for_local_datetime |
| 0 | 0 | 0 | 0s | 0s | DateTime::TimeZone::OffsetOnly::short_name_for_datetime |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package DateTime::TimeZone::OffsetOnly; | ||||
| 2 | { | ||||
| 3 | 2 | 1µs | $DateTime::TimeZone::OffsetOnly::VERSION = '1.46'; | ||
| 4 | } | ||||
| 5 | |||||
| 6 | 3 | 17µs | 2 | 16µs | # spent 14µs (12+2) within DateTime::TimeZone::OffsetOnly::BEGIN@6 which was called:
# once (12µs+2µs) by parent::import at line 6 # spent 14µs making 1 call to DateTime::TimeZone::OffsetOnly::BEGIN@6
# spent 2µs making 1 call to strict::import |
| 7 | 3 | 18µs | 2 | 20µs | # spent 13µs (6+7) within DateTime::TimeZone::OffsetOnly::BEGIN@7 which was called:
# once (6µs+7µs) by parent::import at line 7 # spent 13µs making 1 call to DateTime::TimeZone::OffsetOnly::BEGIN@7
# spent 7µs making 1 call to warnings::import |
| 8 | |||||
| 9 | 3 | 21µs | 2 | 33µs | # spent 33µs (8+24) within DateTime::TimeZone::OffsetOnly::BEGIN@9 which was called:
# once (8µs+24µs) by parent::import at line 9 # spent 33µs making 1 call to DateTime::TimeZone::OffsetOnly::BEGIN@9
# spent 24µs making 1 call to parent::import, recursion: max depth 1, sum of overlapping time 24µs |
| 10 | |||||
| 11 | 3 | 81µs | 1 | 253µs | # spent 253µs (197+56) within DateTime::TimeZone::OffsetOnly::BEGIN@11 which was called:
# once (197µs+56µs) by parent::import at line 11 # spent 253µs making 1 call to DateTime::TimeZone::OffsetOnly::BEGIN@11 |
| 12 | 3 | 314µs | 2 | 116µs | # spent 62µs (9+53) within DateTime::TimeZone::OffsetOnly::BEGIN@12 which was called:
# once (9µs+53µs) by parent::import at line 12 # spent 62µs making 1 call to DateTime::TimeZone::OffsetOnly::BEGIN@12
# spent 53µs making 1 call to Exporter::import |
| 13 | |||||
| 14 | sub new { | ||||
| 15 | my $class = shift; | ||||
| 16 | my %p = validate( | ||||
| 17 | @_, { | ||||
| 18 | offset => { type => SCALAR }, | ||||
| 19 | } | ||||
| 20 | ); | ||||
| 21 | |||||
| 22 | my $offset = DateTime::TimeZone::offset_as_seconds( $p{offset} ); | ||||
| 23 | |||||
| 24 | die "Invalid offset: $p{offset}\n" unless defined $offset; | ||||
| 25 | |||||
| 26 | return DateTime::TimeZone::UTC->new unless $offset; | ||||
| 27 | |||||
| 28 | my $self = { | ||||
| 29 | name => DateTime::TimeZone::offset_as_string($offset), | ||||
| 30 | offset => $offset, | ||||
| 31 | }; | ||||
| 32 | |||||
| 33 | return bless $self, $class; | ||||
| 34 | } | ||||
| 35 | |||||
| 36 | sub is_dst_for_datetime {0} | ||||
| 37 | |||||
| 38 | sub offset_for_datetime { $_[0]->{offset} } | ||||
| 39 | sub offset_for_local_datetime { $_[0]->{offset} } | ||||
| 40 | |||||
| 41 | 4 | 10µs | # spent 4µs within DateTime::TimeZone::OffsetOnly::is_utc which was called 4 times, avg 925ns/call:
# 2 times (2µs+0s) by DateTime::_calc_utc_rd at line 372 of DateTime.pm, avg 1µs/call
# 2 times (1µs+0s) by DateTime::_calc_local_rd at line 413 of DateTime.pm, avg 600ns/call | ||
| 42 | |||||
| 43 | sub short_name_for_datetime { $_[0]->name } | ||||
| 44 | |||||
| 45 | sub category {undef} | ||||
| 46 | |||||
| 47 | sub STORABLE_freeze { | ||||
| 48 | my $self = shift; | ||||
| 49 | |||||
| 50 | return $self->name; | ||||
| 51 | } | ||||
| 52 | |||||
| 53 | sub STORABLE_thaw { | ||||
| 54 | my $self = shift; | ||||
| 55 | my $cloning = shift; | ||||
| 56 | my $serialized = shift; | ||||
| 57 | |||||
| 58 | my $class = ref $self || $self; | ||||
| 59 | |||||
| 60 | my $obj; | ||||
| 61 | if ( $class->isa(__PACKAGE__) ) { | ||||
| 62 | $obj = __PACKAGE__->new( offset => $serialized ); | ||||
| 63 | } | ||||
| 64 | else { | ||||
| 65 | $obj = $class->new( offset => $serialized ); | ||||
| 66 | } | ||||
| 67 | |||||
| 68 | %$self = %$obj; | ||||
| 69 | |||||
| 70 | return $self; | ||||
| 71 | } | ||||
| 72 | |||||
| 73 | 1 | 2µs | 1; | ||
| 74 | |||||
| 75 | # ABSTRACT: A DateTime::TimeZone object that just contains an offset | ||||
| 76 | |||||
| - - | |||||
| 79 | =pod | ||||
| 80 | |||||
| 81 | =head1 NAME | ||||
| 82 | |||||
| 83 | DateTime::TimeZone::OffsetOnly - A DateTime::TimeZone object that just contains an offset | ||||
| 84 | |||||
| 85 | =head1 VERSION | ||||
| 86 | |||||
| 87 | version 1.46 | ||||
| 88 | |||||
| 89 | =head1 SYNOPSIS | ||||
| 90 | |||||
| 91 | my $offset_tz = DateTime::TimeZone->new( name => '-0300' ); | ||||
| 92 | |||||
| 93 | =head1 DESCRIPTION | ||||
| 94 | |||||
| 95 | This class is used to provide the DateTime::TimeZone API needed by | ||||
| 96 | DateTime.pm, but with a fixed offset. An object in this class always | ||||
| 97 | returns the same offset as was given in its constructor, regardless of | ||||
| 98 | the date. | ||||
| 99 | |||||
| 100 | =head1 USAGE | ||||
| 101 | |||||
| 102 | This class has the same methods as a real time zone object, but the | ||||
| 103 | C<category()> method returns undef. | ||||
| 104 | |||||
| 105 | =head2 DateTime::TimeZone::OffsetOnly->new ( offset => $offset ) | ||||
| 106 | |||||
| 107 | The value given to the offset parameter must be a string such as | ||||
| 108 | "+0300". Strings will be converted into numbers by the | ||||
| 109 | C<DateTime::TimeZone::offset_as_seconds()> function. | ||||
| 110 | |||||
| 111 | =head2 $tz->offset_for_datetime( $datetime ) | ||||
| 112 | |||||
| 113 | No matter what date is given, the offset provided to the constructor | ||||
| 114 | is always used. | ||||
| 115 | |||||
| 116 | =head2 $tz->name() | ||||
| 117 | |||||
| 118 | =head2 $tz->short_name_for_datetime() | ||||
| 119 | |||||
| 120 | Both of these methods return the offset in string form. | ||||
| 121 | |||||
| 122 | =head1 AUTHOR | ||||
| 123 | |||||
| 124 | Dave Rolsky <autarch@urth.org> | ||||
| 125 | |||||
| 126 | =head1 COPYRIGHT AND LICENSE | ||||
| 127 | |||||
| 128 | This software is copyright (c) 2012 by Dave Rolsky. | ||||
| 129 | |||||
| 130 | This is free software; you can redistribute it and/or modify it under | ||||
| 131 | the same terms as the Perl 5 programming language system itself. | ||||
| 132 | |||||
| 133 | =cut | ||||
| 134 | |||||
| 135 | |||||
| 136 | __END__ |