line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
|
|
|
|
|
|
# vi:sts=4:shiftwidth=4 |
3
|
|
|
|
|
|
|
# -*- Mode: perl -*- |
4
|
|
|
|
|
|
|
#====================================================================== |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This package is free software and is provided "as is" without |
7
|
|
|
|
|
|
|
# express or implied warranty. It may be used, redistributed and/or |
8
|
|
|
|
|
|
|
# modified under the same terms as perl itself. ( Either the Artistic |
9
|
|
|
|
|
|
|
# License or the GPL. ) |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# $Id: Timezone.pm,v 1.4 2001/08/04 05:43:32 srl Exp $ |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# (C) COPYRIGHT 2000-2001, Reefknot developers. |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# See the AUTHORS file included in the distribution for a full list. |
16
|
|
|
|
|
|
|
#====================================================================== |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Net::ICal::Timezone -- class for representing VTIMEZONEs |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
package Net::ICal::Timezone; |
25
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
6
|
use base qw(Net::ICal::Component); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
106
|
|
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
82
|
|
30
|
1
|
|
|
1
|
|
6
|
use Net::ICal::Property; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
31
|
1
|
|
|
1
|
|
36
|
use Net::ICal::Util qw(:all); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
497
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This module represents VTIMEZONEs, which detail important information |
36
|
|
|
|
|
|
|
about timezones. For any timezone, you need to know some important |
37
|
|
|
|
|
|
|
factors related to it, namely: |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=over 4 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item * What UTC offset it's in now ('8 hours before GMT') |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item * What UTC offset it'll be in at the next daylight/standard time shift |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item * When the shifts to and from daylight savings time take place |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=back |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This object represents those concepts with arrays of Net::ICal::Standard and |
50
|
|
|
|
|
|
|
Net::ICal::Daylight objects. For more detail on why, see RFC2445 4.6.5. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
If you want some real data to test this module against, see |
53
|
|
|
|
|
|
|
http://primates.ximian.com/~damon/icalendar/zoneinfo.tgz , which |
54
|
|
|
|
|
|
|
is a set of VTIMEZONE files that aims to describe every timezone |
55
|
|
|
|
|
|
|
in the world. We'll be relying on those files in a future release |
56
|
|
|
|
|
|
|
as a master timezone database. They're a translation of the Olsen |
57
|
|
|
|
|
|
|
timezone database found on Unix systems. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 SYNOPSIS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
use Net::ICal::Timezone; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# we know this works |
64
|
|
|
|
|
|
|
my $tz = Net::ICal::Timezone->new_from_ical($ical_text); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# we haven't tested this yet, patches welcome |
67
|
|
|
|
|
|
|
my $tz = Net::ICal::Timezone->new( |
68
|
|
|
|
|
|
|
tzid => 'America/New_York', |
69
|
|
|
|
|
|
|
standards => [ |
70
|
|
|
|
|
|
|
(Net::ICal::Standard objects) |
71
|
|
|
|
|
|
|
], |
72
|
|
|
|
|
|
|
daylights => [ |
73
|
|
|
|
|
|
|
(Net::ICal::Daylight objects) |
74
|
|
|
|
|
|
|
] |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 METHODS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 new(%args) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Makes a new Timezone object. Permissible arguments are: |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=over 4 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * tzid - a unique identifier for this timezone |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * lastmod - the last date/time this timezone info was updated |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * tzurl - an URL where you can find a newer version of this infi |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * standards - an array of Net::ICal::Timezone::Standard objects. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * daylights - an array of N::I::Timezone::Daylight objects. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=begin testing |
99
|
|
|
|
|
|
|
TODO: { |
100
|
|
|
|
|
|
|
local $TODO = "write tests for N::I::Timezone"; |
101
|
|
|
|
|
|
|
ok(0, "TODO: write tests for this module"); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
}; |
104
|
|
|
|
|
|
|
=end testing |
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
#============================================================================ |
107
|
|
|
|
|
|
|
sub new { |
108
|
0
|
|
|
0
|
1
|
0
|
my ($class, %args) = @_; |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
0
|
my $self = &_create ($class, %args); |
111
|
|
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
0
|
return undef unless (defined $self); |
113
|
|
|
|
|
|
|
|
114
|
0
|
0
|
|
|
|
0
|
return undef unless ($self->validate); |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
0
|
return $self; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
#================================================================================= |
120
|
|
|
|
|
|
|
=head2 new_from_ical ($text) |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Takes iCalendar text as a parameter; returns a Net::ICal::Timezone object. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# THIS IS INHERITED FROM Net::ICal::Component |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
#================================================================================== |
129
|
|
|
|
|
|
|
# make sure that this object has the bare minimum requirements specified by the RFC |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 INTERNAL METHODS ONLY |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Use these outside this module at your own peril. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 validate($self) |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This routine validates the creation arguments we were given |
138
|
|
|
|
|
|
|
to make sure that we have all the necessary elements to create |
139
|
|
|
|
|
|
|
a valid VTIMEZONE. |
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
sub validate { |
142
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# TODO: fill in validation here |
145
|
|
|
|
|
|
|
|
146
|
1
|
|
|
|
|
8
|
return $self->SUPER::validate ($self); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 create($class, %args) |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This is an internal function that sets up the object. |
152
|
|
|
|
|
|
|
It mainly establishes a Class::MethodMapper data map |
153
|
|
|
|
|
|
|
and hands off creation of the object to Net::ICal::Component. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
sub _create { |
157
|
1
|
|
|
1
|
|
3
|
my ($class, %args) = @_; |
158
|
|
|
|
|
|
|
|
159
|
1
|
|
|
|
|
28
|
my $map = { # RFC2445 4.6.5 describes VTIMEZONE |
160
|
|
|
|
|
|
|
tzid => { # RFC2445 4.8.3.1 - REQUIRED, only once |
161
|
|
|
|
|
|
|
type => 'parameter', |
162
|
|
|
|
|
|
|
doc => 'unique identifier for this timezone', |
163
|
|
|
|
|
|
|
domain => 'param', |
164
|
|
|
|
|
|
|
value => undef, |
165
|
|
|
|
|
|
|
options => [], |
166
|
|
|
|
|
|
|
}, |
167
|
|
|
|
|
|
|
lastmod => { # RFC2445 ? - optional, 1x only in VTIMEZONE |
168
|
|
|
|
|
|
|
type => 'parameter', |
169
|
|
|
|
|
|
|
doc => 'last time this item was modified', |
170
|
|
|
|
|
|
|
domain => 'param', |
171
|
|
|
|
|
|
|
value => undef, |
172
|
|
|
|
|
|
|
options => [], |
173
|
|
|
|
|
|
|
}, |
174
|
|
|
|
|
|
|
tzurl => { # RFC2445 4.8.3.5 - optional, 1x only in VTIMEZONE |
175
|
|
|
|
|
|
|
type => 'parameter', |
176
|
|
|
|
|
|
|
doc => 'a URL for finding the latest version of this VTIMEZONE', |
177
|
|
|
|
|
|
|
domain => 'param', |
178
|
|
|
|
|
|
|
value => undef, |
179
|
|
|
|
|
|
|
options => [], |
180
|
|
|
|
|
|
|
}, |
181
|
|
|
|
|
|
|
standards => { # RFC2445 4.6.5 - required >=1x in VTIMEZONE |
182
|
|
|
|
|
|
|
type => 'parameter', |
183
|
|
|
|
|
|
|
doc => 'a set of standard timezone info', |
184
|
|
|
|
|
|
|
value => undef, |
185
|
|
|
|
|
|
|
domain => 'ref', |
186
|
|
|
|
|
|
|
options => 'ARRAY', |
187
|
|
|
|
|
|
|
}, |
188
|
|
|
|
|
|
|
daylights => { # RFC2445 4.6.5 - required >=1x in VTIMEZONE |
189
|
|
|
|
|
|
|
type => 'parameter', |
190
|
|
|
|
|
|
|
doc => 'a set of daylight timezone info', |
191
|
|
|
|
|
|
|
value => undef, |
192
|
|
|
|
|
|
|
domain => 'ref', |
193
|
|
|
|
|
|
|
options => 'ARRAY', |
194
|
|
|
|
|
|
|
}, |
195
|
|
|
|
|
|
|
dtstart => { # RFC2445 4.6.5? - optional in VTIMEZONE, |
196
|
|
|
|
|
|
|
type => 'parameter', |
197
|
|
|
|
|
|
|
doc => '', |
198
|
|
|
|
|
|
|
domain => 'ref', |
199
|
|
|
|
|
|
|
# TODO, BUG 424114: needs to be in UTC. how to enforce? |
200
|
|
|
|
|
|
|
options => 'Net::ICal::Time', |
201
|
|
|
|
|
|
|
value => undef, |
202
|
|
|
|
|
|
|
}, |
203
|
|
|
|
|
|
|
comment => { # RFC2445 ? - optional multiple times in VTIMEZONE |
204
|
|
|
|
|
|
|
type => 'parameter', |
205
|
|
|
|
|
|
|
doc => 'comment about this timezone', |
206
|
|
|
|
|
|
|
domain => 'param', |
207
|
|
|
|
|
|
|
options => [], |
208
|
|
|
|
|
|
|
value => undef, |
209
|
|
|
|
|
|
|
}, |
210
|
|
|
|
|
|
|
tzname => { # RFC2445 4.8.3.2 - optional multiple times in VTIMEZONE |
211
|
|
|
|
|
|
|
type => 'parameter', |
212
|
|
|
|
|
|
|
doc => 'a name for this timezone', |
213
|
|
|
|
|
|
|
domain => 'param', |
214
|
|
|
|
|
|
|
options => [], |
215
|
|
|
|
|
|
|
value => undef, |
216
|
|
|
|
|
|
|
}, |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
# FIXME: handle x-properties. |
219
|
|
|
|
|
|
|
}; |
220
|
|
|
|
|
|
|
|
221
|
1
|
|
|
|
|
11
|
my $self = $class->SUPER::new ('VTIMEZONE', $map, %args); |
222
|
|
|
|
|
|
|
|
223
|
1
|
|
|
|
|
6
|
return $self; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
1; |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head1 SEE ALSO |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
More documentation pointers can be found in L. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=cut |