line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::TimeZone::OffsetOnly; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
104644
|
use strict; |
|
3
|
|
|
|
|
16
|
|
|
3
|
|
|
|
|
82
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
70
|
|
5
|
3
|
|
|
3
|
|
505
|
use namespace::autoclean; |
|
3
|
|
|
|
|
17710
|
|
|
3
|
|
|
|
|
13
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '2.60'; |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
755
|
use parent 'DateTime::TimeZone'; |
|
3
|
|
|
|
|
303
|
|
|
3
|
|
|
|
|
35
|
|
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
1079
|
use DateTime::TimeZone::UTC; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
118
|
|
12
|
3
|
|
|
3
|
|
967
|
use Params::ValidationCompiler 0.13 qw( validation_for ); |
|
3
|
|
|
|
|
49491
|
|
|
3
|
|
|
|
|
183
|
|
13
|
3
|
|
|
3
|
|
880
|
use Specio::Library::String; |
|
3
|
|
|
|
|
205392
|
|
|
3
|
|
|
|
|
27
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
my $validator = validation_for( |
17
|
|
|
|
|
|
|
name => '_check_new_params', |
18
|
|
|
|
|
|
|
name_is_optional => 1, |
19
|
|
|
|
|
|
|
params => { |
20
|
|
|
|
|
|
|
offset => { |
21
|
|
|
|
|
|
|
type => t('NonEmptyStr'), |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
1
|
|
|
1
|
1
|
10
|
my $class = shift; |
28
|
1
|
|
|
|
|
24
|
my %p = $validator->(@_); |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
42
|
my $offset = DateTime::TimeZone::offset_as_seconds( $p{offset} ); |
31
|
|
|
|
|
|
|
|
32
|
1
|
50
|
|
|
|
4
|
die "Invalid offset: $p{offset}\n" unless defined $offset; |
33
|
|
|
|
|
|
|
|
34
|
1
|
50
|
|
|
|
4
|
return DateTime::TimeZone::UTC->new unless $offset; |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
3
|
my $self = { |
37
|
|
|
|
|
|
|
name => DateTime::TimeZone::offset_as_string($offset), |
38
|
|
|
|
|
|
|
offset => $offset, |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
5
|
return bless $self, $class; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
1
|
|
sub is_dst_for_datetime {0} |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
0
|
1
|
|
sub offset_for_datetime { $_[0]->{offset} } |
48
|
0
|
|
|
0
|
1
|
|
sub offset_for_local_datetime { $_[0]->{offset} } |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
0
|
1
|
|
sub is_utc {0} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
0
|
1
|
|
sub short_name_for_datetime { $_[0]->name } |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
0
|
1
|
|
sub category {undef} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub STORABLE_freeze { |
57
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
return $self->name; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub STORABLE_thaw { |
63
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
64
|
0
|
|
|
|
|
|
shift; |
65
|
0
|
|
|
|
|
|
my $serialized = shift; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
0
|
|
|
|
my $class = ref $self || $self; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $obj; |
70
|
0
|
0
|
|
|
|
|
if ( $class->isa(__PACKAGE__) ) { |
71
|
0
|
|
|
|
|
|
$obj = __PACKAGE__->new( offset => $serialized ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else { |
74
|
0
|
|
|
|
|
|
$obj = $class->new( offset => $serialized ); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
%$self = %$obj; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return $self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# ABSTRACT: A DateTime::TimeZone object that just contains an offset |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=pod |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=encoding UTF-8 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 NAME |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
DateTime::TimeZone::OffsetOnly - A DateTime::TimeZone object that just contains an offset |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 VERSION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
version 2.60 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SYNOPSIS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $offset_tz = DateTime::TimeZone->new( name => '-0300' ); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 DESCRIPTION |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This class is used to provide the DateTime::TimeZone API needed by DateTime.pm, |
107
|
|
|
|
|
|
|
but with a fixed offset. An object in this class always returns the same |
108
|
|
|
|
|
|
|
offset as was given in its constructor, regardless of the date. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 USAGE |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This class has the same methods as a real time zone object, but the |
113
|
|
|
|
|
|
|
C<category()> method returns undef. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 DateTime::TimeZone::OffsetOnly->new ( offset => $offset ) |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
The value given to the offset parameter must be a string such as "+0300". |
118
|
|
|
|
|
|
|
Strings will be converted into numbers by the |
119
|
|
|
|
|
|
|
C<DateTime::TimeZone::offset_as_seconds()> function. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 $tz->offset_for_datetime( $datetime ) |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
No matter what date is given, the offset provided to the constructor is always |
124
|
|
|
|
|
|
|
used. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 $tz->name() |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 $tz->short_name_for_datetime() |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Both of these methods return the offset in string form. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 SUPPORT |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/DateTime-TimeZone/issues>. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 SOURCE |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The source code repository for DateTime-TimeZone can be found at L<https://github.com/houseabsolute/DateTime-TimeZone>. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 AUTHOR |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This software is copyright (c) 2023 by Dave Rolsky. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
149
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
The full text of the license can be found in the |
152
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |