| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Astro::App::Satpass2::ParseTime::Date::Manip::v6; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2139
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
31
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
44
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Astro::Coord::ECI::Utils 0.112 qw{ looks_like_number }; |
|
|
1
|
|
|
|
|
17
|
|
|
|
1
|
|
|
|
|
50
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use parent qw{ Astro::App::Satpass2::ParseTime::Date::Manip }; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
62
|
use Astro::App::Satpass2::Utils qw{ load_package @CARP_NOT }; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
354
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.052'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $invalid; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
BEGIN { |
|
17
|
1
|
50
|
50
|
1
|
|
4
|
eval { |
|
18
|
1
|
50
|
|
|
|
5
|
load_package( 'Date::Manip' ) |
|
19
|
|
|
|
|
|
|
or return; |
|
20
|
0
|
0
|
|
|
|
0
|
load_package( 'Date::Manip::Date' ) |
|
21
|
|
|
|
|
|
|
or return; |
|
22
|
0
|
|
|
|
|
0
|
my $ver = Date::Manip->VERSION(); |
|
23
|
0
|
|
|
|
|
0
|
$ver =~ s/ _ //smxg; |
|
24
|
|
|
|
|
|
|
$ver >= 6 |
|
25
|
0
|
0
|
0
|
|
|
0
|
and do { |
|
26
|
0
|
|
|
|
|
0
|
Date::Manip->import(); |
|
27
|
0
|
|
|
|
|
0
|
1; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
or $invalid = sprintf |
|
30
|
|
|
|
|
|
|
'%s assumes a Date::Manip version >= 6. You have %s', |
|
31
|
|
|
|
|
|
|
__PACKAGE__, Date::Manip->VERSION(); |
|
32
|
|
|
|
|
|
|
$ver >= 6.49 |
|
33
|
|
|
|
|
|
|
and *_normalize_zone = sub { |
|
34
|
0
|
|
|
|
|
0
|
$_[0] =~ s/ \A (?: gmt | ut ) \z /UT/smxi; |
|
35
|
0
|
0
|
|
|
|
0
|
}; |
|
36
|
0
|
|
|
|
|
0
|
1; |
|
37
|
|
|
|
|
|
|
} or $invalid = ( $@ || 'Unable to load Date::Manip' ); |
|
38
|
|
|
|
|
|
|
__PACKAGE__->can( '_normalize_zone' ) |
|
39
|
1
|
50
|
|
0
|
|
693
|
or *_normalize_zone = sub{}; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub delegate { |
|
43
|
0
|
|
|
0
|
1
|
|
return __PACKAGE__; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub dmd_err { |
|
47
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
|
48
|
0
|
|
|
|
|
|
return $self->_get_dm_field( 'object' )->err(); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub dmd_zone { |
|
52
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
|
53
|
0
|
|
|
|
|
|
return scalar $self->_get_dm_field( 'object' )->tz->zone(); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub parse_time_absolute { |
|
57
|
0
|
|
|
0
|
1
|
|
my ( $self, $string ) = @_; |
|
58
|
0
|
0
|
|
|
|
|
$invalid and $self->wail( $invalid ); |
|
59
|
0
|
|
|
|
|
|
my $dm = $self->_get_dm_field( 'object' ); |
|
60
|
0
|
0
|
|
|
|
|
$dm->parse( $string ) and return; |
|
61
|
0
|
|
|
|
|
|
return $dm->secs_since_1970_GMT() - $self->__epoch_offset(); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub use_perltime { |
|
65
|
0
|
|
|
0
|
1
|
|
return 0; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub tz { |
|
69
|
0
|
|
|
0
|
1
|
|
my ( $self, @args ) = @_; |
|
70
|
0
|
0
|
|
|
|
|
$invalid and $self->wail( $invalid ); |
|
71
|
0
|
0
|
|
|
|
|
if ( @args ) { |
|
72
|
0
|
|
|
|
|
|
my $zone = $args[0]; |
|
73
|
0
|
|
|
|
|
|
my $dm = $self->_get_dm_field( 'object' ); |
|
74
|
0
|
0
|
0
|
|
|
|
defined $zone and '' ne $zone |
|
75
|
|
|
|
|
|
|
or $zone = $self->_get_dm_field( 'default_zone' ); |
|
76
|
0
|
|
|
|
|
|
_normalize_zone( $zone ); |
|
77
|
0
|
|
|
|
|
|
$dm->config( setdate => "zone,$zone" ); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
0
|
|
|
|
|
|
return $self->SUPER::tz( @args ); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub __back_end_validate { |
|
83
|
0
|
|
|
0
|
|
|
my ( $self, $cls ) = @_; |
|
84
|
0
|
0
|
|
|
|
|
$cls->can( 'parse' ) |
|
85
|
|
|
|
|
|
|
or $self->wail( "$cls does not have a parse() method" ); |
|
86
|
0
|
|
|
|
|
|
return; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub __set_back_end_location { |
|
90
|
0
|
|
|
0
|
|
|
my ( $self, $location ) = @_; |
|
91
|
0
|
0
|
|
|
|
|
if ( my $dm = $self->_get_dm_field( 'object' ) ) { |
|
92
|
|
|
|
|
|
|
# NOTE that we have no way to introspect Date::Manip::Date (or |
|
93
|
|
|
|
|
|
|
# any other back end) to see if it has the 'location' config, so |
|
94
|
|
|
|
|
|
|
# since Date::Manip uses warn() to report errors, we just |
|
95
|
|
|
|
|
|
|
# blindly set it and swallow the possible warning. |
|
96
|
0
|
|
|
0
|
|
|
local $SIG{__WARN__} = sub {}; |
|
97
|
0
|
|
|
|
|
|
$dm->config( location => $location ); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
0
|
|
|
|
|
|
return; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub _get_dm_field { |
|
103
|
0
|
|
|
0
|
|
|
my ( $self, $field ) = @_; |
|
104
|
0
|
|
0
|
|
|
|
my $info = $self->{+__PACKAGE__} ||= $self->_make_dm_hash(); |
|
105
|
0
|
|
|
|
|
|
return $info->{$field}; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _make_dm_hash { |
|
109
|
0
|
|
|
0
|
|
|
my ( $self ) = @_; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# Workaround for bug (well, _I_ think it's a bug) introduced into |
|
112
|
|
|
|
|
|
|
# Date::Manip with 6.34, while fixing RT #78566. My bug report is RT |
|
113
|
|
|
|
|
|
|
# #80435. |
|
114
|
0
|
|
|
|
|
|
my $path = $ENV{PATH}; |
|
115
|
0
|
|
|
|
|
|
local $ENV{PATH} = $path; |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
|
0
|
|
|
|
my $back_end = $self->back_end() || 'Date::Manip::Date'; |
|
118
|
0
|
|
|
|
|
|
my $dm = $back_end->new(); |
|
119
|
|
|
|
|
|
|
return { |
|
120
|
0
|
|
|
|
|
|
default_zone => scalar $dm->tz->zone(), |
|
121
|
|
|
|
|
|
|
object => $dm, |
|
122
|
|
|
|
|
|
|
}; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 NAME |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Astro::App::Satpass2::ParseTime::Date::Manip::v6 - Astro::App::Satpass2 wrapper for Date::Manip v6 or greater |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
No user-serviceable parts inside. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 DETAILS |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This class wraps the L object from |
|
138
|
|
|
|
|
|
|
L version 6.0 or higher, and uses it to parse |
|
139
|
|
|
|
|
|
|
dates. It ignores the C mechanism. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
B the L configuration mechanism (used |
|
142
|
|
|
|
|
|
|
to set the time zone) reports errors using the C built-in, rather |
|
143
|
|
|
|
|
|
|
than by returning a bad status or throwing an exception. Yes, I could |
|
144
|
|
|
|
|
|
|
use the C<$SIG{__WARN__}> hook to trap this, but I would rather hope |
|
145
|
|
|
|
|
|
|
that Mr. Beck will provide a more friendly mechanism. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 METHODS |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This class supports the following public methods over and above those |
|
150
|
|
|
|
|
|
|
documented in its superclass |
|
151
|
|
|
|
|
|
|
L. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 dmd_err |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
my $error_string = $pt->dmd_err(); |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This method wraps the L object's |
|
158
|
|
|
|
|
|
|
C method, and returns whatever that method |
|
159
|
|
|
|
|
|
|
returns. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 dmd_zone |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
my $zone_name = $pt->dmd_zone(); |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This method wraps the L object's |
|
166
|
|
|
|
|
|
|
C method, calling it in scalar context to |
|
167
|
|
|
|
|
|
|
get the default zone name, and returning the result. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Note that unlike the inherited C method, this is an accessor |
|
170
|
|
|
|
|
|
|
only, and, it is possible that C<< $pt->dmd_zone() >> will not return |
|
171
|
|
|
|
|
|
|
the same thing that C<< $pt->tz() >> does. For example, |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$pt->tz( 'EST5EDT' ); |
|
174
|
|
|
|
|
|
|
print '$pt->tz(): ', $pt->tz(), "\n"; |
|
175
|
|
|
|
|
|
|
print '$pt->dmd_zone(): ', $pt->dmd_zone(), "\n"; |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
prints |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
$pt->tz(): EST5EDT |
|
180
|
|
|
|
|
|
|
$pt->dmd_zone(): America/New_York |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This is because C<< $pt->tz() >> returns the last setting, whereas C<< |
|
183
|
|
|
|
|
|
|
$pt->dmd_zone() >> returns the name of the time zone in the Olson |
|
184
|
|
|
|
|
|
|
zoneinfo database, which is typically something like C, |
|
185
|
|
|
|
|
|
|
even though the time zone was set using an alias, abbreviation or |
|
186
|
|
|
|
|
|
|
offset. See L for the gory details. |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Another difference is the if the time zone has never been set, |
|
189
|
|
|
|
|
|
|
C<< $pt->tz() >> will return C, whereas |
|
190
|
|
|
|
|
|
|
C<< $pt->dmd_zone() >> will actually return the name of the default |
|
191
|
|
|
|
|
|
|
zone. |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 SUPPORT |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Support is by the author. Please file bug reports at |
|
196
|
|
|
|
|
|
|
L, |
|
197
|
|
|
|
|
|
|
L, or in |
|
198
|
|
|
|
|
|
|
electronic mail to the author. |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 AUTHOR |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Thomas R. Wyant, III F |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Copyright (C) 2009-2023 by Thomas R. Wyant, III |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
209
|
|
|
|
|
|
|
under the same terms as Perl 5.10.0. For more details, see the full text |
|
210
|
|
|
|
|
|
|
of the licenses in the directory LICENSES. |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but |
|
213
|
|
|
|
|
|
|
without any warranty; without even the implied warranty of |
|
214
|
|
|
|
|
|
|
merchantability or fitness for a particular purpose. |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=cut |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
__END__ |