Data.pm

filter: Statementstmt 100% 57 / 57 Branchbran 83.3% 10 / 12 Conditioncond 53.8% 7 / 13 MC/DCmcdc 14.2% 1 / 7 Subroutinesub 100% 14 / 14 Podpod 100% 6 / 6 totaltotal 87.1% 95 / 109 CC 13 SCAR 9.7
CC
13
Cov
90%
olson_country_selection
5.5
olson_canonical_names
3.0
olson_links
3.0
CRAP 2.6
↑ Summary Data/country_selection.tzp »
1 =head1 NAME
2  
3 Time::OlsonTZ::Data - Olson timezone data
4  
5 =head1 SYNOPSIS
6  
7 use Time::OlsonTZ::Data qw(olson_version);
8  
9 $version = olson_version;
10  
11 use Time::OlsonTZ::Data qw(
12 olson_canonical_names olson_link_names olson_all_names
13 olson_links olson_country_selection);
14  
15 $names = olson_canonical_names;
16 $names = olson_link_names;
17 $names = olson_all_names;
18 $links = olson_links;
19 $countries = olson_country_selection;
20  
21 use Time::OlsonTZ::Data qw(olson_tzfile);
22  
23 $filename = olson_tzfile("America/New_York");
24  
25 =head1 DESCRIPTION
26  
27 This module encapsulates the Olson timezone database, providing binary
28 tzfiles and ancillary data. Each version of this module encapsulates
29 a particular version of the timezone database. It is intended to be
30 regularly updated, as the timezone database changes.
31  
32 =cut
33  
34 package Time::OlsonTZ::Data;
35  
36 9 ▶{ use 5.006; }
Subroutine BEGIN: called CC=1 SCAR=0.0
37 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 9 our $VERSION = "0.202606";
41  
42 9 ▶use parent "Exporter";
Subroutine BEGIN: called CC=1 SCAR=0.0
43 9 our @EXPORT_OK = qw(
44 olson_version olson_code_version olson_data_version
45 olson_canonical_names olson_link_names olson_all_names
46 olson_links
47 olson_country_selection
48 olson_tzfile
49 );
50  
51 9 my($datavol, $datadir);
52 1197 ▶sub _data_file($) {
Subroutine _data_file: called CC=2 SCAR=6.9
53 1197 my($upath) = @_;
54 1197 ▶ unless(defined $datadir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $datadir) 4 1193 1197
55 4 require File::Spec;
56 ($datavol, $datadir, undef) =
57 4 File::Spec->splitpath($INC{"Time/OlsonTZ/Data.pm"});
58 }
59 1197 my @nameparts = split(/\//, $upath);
60 1197 my $filename = pop(@nameparts);
61 1197 return File::Spec->catpath($datavol,
62 File::Spec->catdir($datadir, "Data", @nameparts), $filename);
63 }
64  
65 =head1 FUNCTIONS
66  
67 =head2 Basic information
68  
69 =over
70  
71 =item olson_version
72  
73 Returns the version number of the database that this module encapsulates.
74 Version numbers for the Olson database currently consist of a year number
75 and a lowercase letter, such as "C<2010k>"; they are not guaranteed to
76 retain this format in the future.
77  
78 =cut
79  
80 9 ▶use constant olson_version => "2026f";
Subroutine BEGIN: called CC=1 SCAR=0.0
81  
82 =item olson_code_version
83  
84 Returns the version number of the code part of the database that this
85 module encapsulates. This is now always the same as the value returned
86 by L</olson_version>. Until late 2012 the database was distributed in
87 two parts, each with their own version number, so this was a distinct
88 piece of information.
89  
90 =cut
91  
92 9 ▶use constant olson_code_version => "2026f";
Subroutine BEGIN: called CC=1 SCAR=0.0
93  
94 =item olson_data_version
95  
96 Returns the version number of the data part of the database that this
97 module encapsulates. This is now always the same as the value returned
98 by L</olson_version>. Until late 2012 the database was distributed in
99 two parts, each with their own version number, so this was a distinct
100 piece of information.
101  
102 =cut
103  
104 9 ▶use constant olson_data_version => "2026f";
Subroutine BEGIN: called CC=1 SCAR=0.0
105  
106 =back
107  
108 =head2 Zone metadata
109  
110 =over
111  
112 =item olson_canonical_names
113  
114 Returns the set of timezone names that this version of the database
115 defines as canonical. These are the timezone names that are directly
116 associated with a set of observance data. The return value is a reference
117 to a hash, in which the keys are the canonical timezone names and the
118 values are all C<undef>.
119  
120 =cut
121  
122 9 my $cn = q(+{ map { ($_ => undef) } qw(
123 Africa/Abidjan Africa/Algiers Africa/Bissau Africa/Cairo
124 Africa/Casablanca Africa/Ceuta Africa/El_Aaiun Africa/Johannesburg
125 Africa/Juba Africa/Khartoum Africa/Lagos Africa/Maputo Africa/Monrovia
126 Africa/Nairobi Africa/Ndjamena Africa/Sao_Tome Africa/Tripoli
127 Africa/Tunis Africa/Windhoek America/Adak America/Anchorage
128 America/Araguaina America/Argentina/Buenos_Aires
129 America/Argentina/Catamarca America/Argentina/Cordoba
130 America/Argentina/Jujuy America/Argentina/La_Rioja
131 America/Argentina/Mendoza America/Argentina/Rio_Gallegos
132 America/Argentina/Salta America/Argentina/San_Juan
133 America/Argentina/San_Luis America/Argentina/Tucuman
134 America/Argentina/Ushuaia America/Asuncion America/Bahia
135 America/Bahia_Banderas America/Barbados America/Belem America/Belize
136 America/Boa_Vista America/Bogota America/Boise America/Cambridge_Bay
137 America/Campo_Grande America/Cancun America/Caracas America/Cayenne
138 America/Chicago America/Chihuahua America/Ciudad_Juarez
139 America/Costa_Rica America/Coyhaique America/Cuiaba America/Danmarkshavn
140 America/Dawson America/Dawson_Creek America/Denver America/Detroit
141 America/Edmonton America/Eirunepe America/El_Salvador
142 America/Fort_Nelson America/Fortaleza America/Glace_Bay
143 America/Goose_Bay America/Grand_Turk America/Guatemala America/Guayaquil
144 America/Guyana America/Halifax America/Havana America/Hermosillo
145 America/Indiana/Indianapolis America/Indiana/Knox
146 America/Indiana/Marengo America/Indiana/Petersburg
147 America/Indiana/Tell_City America/Indiana/Vevay
148 America/Indiana/Vincennes America/Indiana/Winamac America/Inuvik
149 America/Iqaluit America/Jamaica America/Juneau
150 America/Kentucky/Louisville America/Kentucky/Monticello America/La_Paz
151 America/Lima America/Los_Angeles America/Maceio America/Managua
152 America/Manaus America/Martinique America/Matamoros America/Mazatlan
153 America/Menominee America/Merida America/Metlakatla America/Mexico_City
154 America/Miquelon America/Moncton America/Monterrey America/Montevideo
155 America/New_York America/Nome America/Noronha
156 America/North_Dakota/Beulah America/North_Dakota/Center
157 America/North_Dakota/New_Salem America/Nuuk America/Ojinaga
158 America/Panama America/Paramaribo America/Phoenix America/Port-au-Prince
159 America/Porto_Velho America/Puerto_Rico America/Punta_Arenas
160 America/Rankin_Inlet America/Recife America/Regina America/Resolute
161 America/Rio_Branco America/Santarem America/Santiago
162 America/Santo_Domingo America/Sao_Paulo America/Scoresbysund
163 America/Sitka America/St_Johns America/Swift_Current America/Tegucigalpa
164 America/Thule America/Tijuana America/Toronto America/Vancouver
165 America/Whitehorse America/Winnipeg America/Yakutat Antarctica/Casey
166 Antarctica/Davis Antarctica/Macquarie Antarctica/Mawson
167 Antarctica/Palmer Antarctica/Rothera Antarctica/Troll Antarctica/Vostok
168 Asia/Almaty Asia/Amman Asia/Anadyr Asia/Aqtau Asia/Aqtobe Asia/Ashgabat
169 Asia/Atyrau Asia/Baghdad Asia/Baku Asia/Bangkok Asia/Barnaul Asia/Beirut
170 Asia/Bishkek Asia/Chita Asia/Colombo Asia/Damascus Asia/Dhaka Asia/Dili
171 Asia/Dubai Asia/Dushanbe Asia/Famagusta Asia/Gaza Asia/Hebron
172 Asia/Ho_Chi_Minh Asia/Hong_Kong Asia/Hovd Asia/Irkutsk Asia/Jakarta
173 Asia/Jayapura Asia/Jerusalem Asia/Kabul Asia/Kamchatka Asia/Karachi
174 Asia/Kathmandu Asia/Khandyga Asia/Kolkata Asia/Krasnoyarsk Asia/Kuching
175 Asia/Macau Asia/Magadan Asia/Makassar Asia/Manila Asia/Nicosia
176 Asia/Novokuznetsk Asia/Novosibirsk Asia/Omsk Asia/Oral Asia/Pontianak
177 Asia/Pyongyang Asia/Qatar Asia/Qostanay Asia/Qyzylorda Asia/Riyadh
178 Asia/Sakhalin Asia/Samarkand Asia/Seoul Asia/Shanghai Asia/Singapore
179 Asia/Srednekolymsk Asia/Taipei Asia/Tashkent Asia/Tbilisi Asia/Tehran
180 Asia/Thimphu Asia/Tokyo Asia/Tomsk Asia/Ulaanbaatar Asia/Urumqi
181 Asia/Ust-Nera Asia/Vladivostok Asia/Yakutsk Asia/Yangon
182 Asia/Yekaterinburg Asia/Yerevan Atlantic/Azores Atlantic/Bermuda
183 Atlantic/Canary Atlantic/Cape_Verde Atlantic/Faroe Atlantic/Madeira
184 Atlantic/South_Georgia Atlantic/Stanley Australia/Adelaide
185 Australia/Brisbane Australia/Broken_Hill Australia/Darwin
186 Australia/Eucla Australia/Hobart Australia/Lindeman Australia/Lord_Howe
187 Australia/Melbourne Australia/Perth Australia/Sydney CST6CDT EST5EDT
188 Etc/GMT Etc/GMT+1 Etc/GMT+10 Etc/GMT+11 Etc/GMT+12 Etc/GMT+2 Etc/GMT+3
189 Etc/GMT+4 Etc/GMT+5 Etc/GMT+6 Etc/GMT+7 Etc/GMT+8 Etc/GMT+9 Etc/GMT-1
190 Etc/GMT-10 Etc/GMT-11 Etc/GMT-12 Etc/GMT-13 Etc/GMT-14 Etc/GMT-2
191 Etc/GMT-3 Etc/GMT-4 Etc/GMT-5 Etc/GMT-6 Etc/GMT-7 Etc/GMT-8 Etc/GMT-9
192 Etc/UTC Europe/Andorra Europe/Astrakhan Europe/Athens Europe/Belgrade
193 Europe/Berlin Europe/Brussels Europe/Bucharest Europe/Budapest
194 Europe/Chisinau Europe/Dublin Europe/Gibraltar Europe/Helsinki
195 Europe/Istanbul Europe/Kaliningrad Europe/Kirov Europe/Kyiv
196 Europe/Lisbon Europe/London Europe/Madrid Europe/Malta Europe/Minsk
197 Europe/Moscow Europe/Paris Europe/Prague Europe/Riga Europe/Rome
198 Europe/Samara Europe/Saratov Europe/Simferopol Europe/Sofia
199 Europe/Tallinn Europe/Tirane Europe/Ulyanovsk Europe/Vienna
200 Europe/Vilnius Europe/Volgograd Europe/Warsaw Europe/Zurich Factory
201 Indian/Chagos Indian/Maldives Indian/Mauritius MST7MDT PST8PDT
202 Pacific/Apia Pacific/Auckland Pacific/Bougainville Pacific/Chatham
203 Pacific/Easter Pacific/Efate Pacific/Fakaofo Pacific/Fiji
204 Pacific/Galapagos Pacific/Gambier Pacific/Guadalcanal Pacific/Guam
205 Pacific/Honolulu Pacific/Kanton Pacific/Kiritimati Pacific/Kosrae
206 Pacific/Kwajalein Pacific/Marquesas Pacific/Nauru Pacific/Niue
207 Pacific/Norfolk Pacific/Noumea Pacific/Pago_Pago Pacific/Palau
208 Pacific/Pitcairn Pacific/Port_Moresby Pacific/Rarotonga Pacific/Tahiti
209 Pacific/Tarawa Pacific/Tongatapu
210 ) });
211 1205 ▶sub olson_canonical_names() {
Subroutine olson_canonical_names: called CC=3 SCAR=11.1
Pod documented
212 1205 ▶ $cn = eval($cn) || die $@ if ref($cn) eq "";
Branch: 1 branch
BranchTrueFalseTotal
if ref $cn eq "" 7 1198 1205
Condition50%1/2
eval $cn || die($@)
l!l
70
MC/DC0%0/1
eval $cn || die($@)
eval $cn
Truth table50%1/2
A
A= eval $cn
Aresult
11
00
213 1205 return $cn;
214 }
215  
216 =item olson_link_names
217  
218 Returns the set of timezone names that this version of the database
219 defines as links. These are the timezone names that are aliases for
220 other names. The return value is a reference to a hash, in which the
221 keys are the link timezone names and the values are all C<undef>.
222  
223 =cut
224  
225 sub olson_links();
226  
227 9 my $ln;
228 4 ▶sub olson_link_names() {
Subroutine olson_link_names: called CC=2 SCAR=6.9
Pod documented
229 4 ▶ return $ln ||= { map { ($_ => undef) } keys %{olson_links()} };
Condition100%2/2
$ln ||= {map({$_, undef;} keys %{&olson_links();})}
l!l
13
MC/DC100%1/1
$ln ||= {map({$_, undef;} keys %{&olson_links();})}
$ln
Truth table100%2/2
A
A= $ln
Aresult
11
00
230 }
231  
232 =item olson_all_names
233  
234 Returns the set of timezone names that this version of the
235 database defines. These are the L</olson_canonical_names> and the
236 L</olson_link_names>. The return value is a reference to a hash, in
237 which the keys are the timezone names and the values are all C<undef>.
238  
239 =cut
240  
241 my $an;
242 2 ▶sub olson_all_names() {
Subroutine olson_all_names: called CC=2 SCAR=7.1
Pod documented
243 return $an ||= {
244 2 %{olson_canonical_names()},
245 2 ▶ %{olson_link_names()},
Condition50%1/2
$an ||= {%{&olson_canonical_names();}, %{&olson_link_names();}}
l!l
02
MC/DC0%0/1
$an ||= {%{&olson_canonical_names();}, %{&olson_link_names();}}
$an
Truth table50%1/2
A
A= $an
Aresult
11
00
246 };
247 }
248  
249 =item olson_links
250  
251 Returns details of the timezone name links in this version of the
252 database. Each link defines one timezone name as an alias for some
253 other timezone name. The return value is a reference to a hash, in
254 which the keys are the aliases and each value is the canonical name of
255 the timezone to which that alias refers. All such canonical names can
256 be found in the L</olson_canonical_names> hash.
257  
258 =cut
259  
260 9 my $li = q(+{
261 "Africa/Accra" => "Africa/Abidjan",
262 "Africa/Addis_Ababa" => "Africa/Nairobi",
263 "Africa/Asmara" => "Africa/Nairobi",
264 "Africa/Asmera" => "Africa/Nairobi",
265 "Africa/Bamako" => "Africa/Abidjan",
266 "Africa/Bangui" => "Africa/Lagos",
267 "Africa/Banjul" => "Africa/Abidjan",
268 "Africa/Blantyre" => "Africa/Maputo",
269 "Africa/Brazzaville" => "Africa/Lagos",
270 "Africa/Bujumbura" => "Africa/Maputo",
271 "Africa/Conakry" => "Africa/Abidjan",
272 "Africa/Dakar" => "Africa/Abidjan",
273 "Africa/Dar_es_Salaam" => "Africa/Nairobi",
274 "Africa/Djibouti" => "Africa/Nairobi",
275 "Africa/Douala" => "Africa/Lagos",
276 "Africa/Freetown" => "Africa/Abidjan",
277 "Africa/Gaborone" => "Africa/Maputo",
278 "Africa/Harare" => "Africa/Maputo",
279 "Africa/Kampala" => "Africa/Nairobi",
280 "Africa/Kigali" => "Africa/Maputo",
281 "Africa/Kinshasa" => "Africa/Lagos",
282 "Africa/Libreville" => "Africa/Lagos",
283 "Africa/Lome" => "Africa/Abidjan",
284 "Africa/Luanda" => "Africa/Lagos",
285 "Africa/Lubumbashi" => "Africa/Maputo",
286 "Africa/Lusaka" => "Africa/Maputo",
287 "Africa/Malabo" => "Africa/Lagos",
288 "Africa/Maseru" => "Africa/Johannesburg",
289 "Africa/Mbabane" => "Africa/Johannesburg",
290 "Africa/Mogadishu" => "Africa/Nairobi",
291 "Africa/Niamey" => "Africa/Lagos",
292 "Africa/Nouakchott" => "Africa/Abidjan",
293 "Africa/Ouagadougou" => "Africa/Abidjan",
294 "Africa/Porto-Novo" => "Africa/Lagos",
295 "Africa/Timbuktu" => "Africa/Abidjan",
296 "America/Anguilla" => "America/Puerto_Rico",
297 "America/Antigua" => "America/Puerto_Rico",
298 "America/Argentina/ComodRivadavia" => "America/Argentina/Catamarca",
299 "America/Aruba" => "America/Puerto_Rico",
300 "America/Atikokan" => "America/Panama",
301 "America/Atka" => "America/Adak",
302 "America/Blanc-Sablon" => "America/Puerto_Rico",
303 "America/Buenos_Aires" => "America/Argentina/Buenos_Aires",
304 "America/Catamarca" => "America/Argentina/Catamarca",
305 "America/Cayman" => "America/Panama",
306 "America/Coral_Harbour" => "America/Panama",
307 "America/Cordoba" => "America/Argentina/Cordoba",
308 "America/Creston" => "America/Phoenix",
309 "America/Curacao" => "America/Puerto_Rico",
310 "America/Dominica" => "America/Puerto_Rico",
311 "America/Ensenada" => "America/Tijuana",
312 "America/Fort_Wayne" => "America/Indiana/Indianapolis",
313 "America/Godthab" => "America/Nuuk",
314 "America/Grenada" => "America/Puerto_Rico",
315 "America/Guadeloupe" => "America/Puerto_Rico",
316 "America/Indianapolis" => "America/Indiana/Indianapolis",
317 "America/Jujuy" => "America/Argentina/Jujuy",
318 "America/Knox_IN" => "America/Indiana/Knox",
319 "America/Kralendijk" => "America/Puerto_Rico",
320 "America/Louisville" => "America/Kentucky/Louisville",
321 "America/Lower_Princes" => "America/Puerto_Rico",
322 "America/Marigot" => "America/Puerto_Rico",
323 "America/Mendoza" => "America/Argentina/Mendoza",
324 "America/Montreal" => "America/Toronto",
325 "America/Montserrat" => "America/Puerto_Rico",
326 "America/Nassau" => "America/Toronto",
327 "America/Nipigon" => "America/Toronto",
328 "America/Pangnirtung" => "America/Iqaluit",
329 "America/Port_of_Spain" => "America/Puerto_Rico",
330 "America/Porto_Acre" => "America/Rio_Branco",
331 "America/Rainy_River" => "America/Winnipeg",
332 "America/Rosario" => "America/Argentina/Cordoba",
333 "America/Santa_Isabel" => "America/Tijuana",
334 "America/Shiprock" => "America/Denver",
335 "America/St_Barthelemy" => "America/Puerto_Rico",
336 "America/St_Kitts" => "America/Puerto_Rico",
337 "America/St_Lucia" => "America/Puerto_Rico",
338 "America/St_Thomas" => "America/Puerto_Rico",
339 "America/St_Vincent" => "America/Puerto_Rico",
340 "America/Thunder_Bay" => "America/Toronto",
341 "America/Tortola" => "America/Puerto_Rico",
342 "America/Virgin" => "America/Puerto_Rico",
343 "America/Yellowknife" => "America/Edmonton",
344 "Antarctica/DumontDUrville" => "Pacific/Port_Moresby",
345 "Antarctica/McMurdo" => "Pacific/Auckland",
346 "Antarctica/South_Pole" => "Pacific/Auckland",
347 "Antarctica/Syowa" => "Asia/Riyadh",
348 "Arctic/Longyearbyen" => "Europe/Berlin",
349 "Asia/Aden" => "Asia/Riyadh",
350 "Asia/Ashkhabad" => "Asia/Ashgabat",
351 "Asia/Bahrain" => "Asia/Qatar",
352 "Asia/Brunei" => "Asia/Kuching",
353 "Asia/Calcutta" => "Asia/Kolkata",
354 "Asia/Choibalsan" => "Asia/Ulaanbaatar",
355 "Asia/Chongqing" => "Asia/Shanghai",
356 "Asia/Chungking" => "Asia/Shanghai",
357 "Asia/Dacca" => "Asia/Dhaka",
358 "Asia/Harbin" => "Asia/Shanghai",
359 "Asia/Istanbul" => "Europe/Istanbul",
360 "Asia/Kashgar" => "Asia/Urumqi",
361 "Asia/Katmandu" => "Asia/Kathmandu",
362 "Asia/Kuala_Lumpur" => "Asia/Singapore",
363 "Asia/Kuwait" => "Asia/Riyadh",
364 "Asia/Macao" => "Asia/Macau",
365 "Asia/Muscat" => "Asia/Dubai",
366 "Asia/Phnom_Penh" => "Asia/Bangkok",
367 "Asia/Rangoon" => "Asia/Yangon",
368 "Asia/Saigon" => "Asia/Ho_Chi_Minh",
369 "Asia/Tel_Aviv" => "Asia/Jerusalem",
370 "Asia/Thimbu" => "Asia/Thimphu",
371 "Asia/Ujung_Pandang" => "Asia/Makassar",
372 "Asia/Ulan_Bator" => "Asia/Ulaanbaatar",
373 "Asia/Vientiane" => "Asia/Bangkok",
374 "Atlantic/Faeroe" => "Atlantic/Faroe",
375 "Atlantic/Jan_Mayen" => "Europe/Berlin",
376 "Atlantic/Reykjavik" => "Africa/Abidjan",
377 "Atlantic/St_Helena" => "Africa/Abidjan",
378 "Australia/ACT" => "Australia/Sydney",
379 "Australia/Canberra" => "Australia/Sydney",
380 "Australia/Currie" => "Australia/Hobart",
381 "Australia/LHI" => "Australia/Lord_Howe",
382 "Australia/NSW" => "Australia/Sydney",
383 "Australia/North" => "Australia/Darwin",
384 "Australia/Queensland" => "Australia/Brisbane",
385 "Australia/South" => "Australia/Adelaide",
386 "Australia/Tasmania" => "Australia/Hobart",
387 "Australia/Victoria" => "Australia/Melbourne",
388 "Australia/West" => "Australia/Perth",
389 "Australia/Yancowinna" => "Australia/Broken_Hill",
390 "Brazil/Acre" => "America/Rio_Branco",
391 "Brazil/DeNoronha" => "America/Noronha",
392 "Brazil/East" => "America/Sao_Paulo",
393 "Brazil/West" => "America/Manaus",
394 CET => "Europe/Brussels",
395 "Canada/Atlantic" => "America/Halifax",
396 "Canada/Central" => "America/Winnipeg",
397 "Canada/Eastern" => "America/Toronto",
398 "Canada/Mountain" => "America/Edmonton",
399 "Canada/Newfoundland" => "America/St_Johns",
400 "Canada/Pacific" => "America/Vancouver",
401 "Canada/Saskatchewan" => "America/Regina",
402 "Canada/Yukon" => "America/Whitehorse",
403 "Chile/Continental" => "America/Santiago",
404 "Chile/EasterIsland" => "Pacific/Easter",
405 Cuba => "America/Havana",
406 EET => "Europe/Athens",
407 EST => "America/Panama",
408 Egypt => "Africa/Cairo",
409 Eire => "Europe/Dublin",
410 "Etc/GMT+0" => "Etc/GMT",
411 "Etc/GMT-0" => "Etc/GMT",
412 "Etc/GMT0" => "Etc/GMT",
413 "Etc/Greenwich" => "Etc/GMT",
414 "Etc/UCT" => "Etc/UTC",
415 "Etc/Universal" => "Etc/UTC",
416 "Etc/Zulu" => "Etc/UTC",
417 "Europe/Amsterdam" => "Europe/Brussels",
418 "Europe/Belfast" => "Europe/London",
419 "Europe/Bratislava" => "Europe/Prague",
420 "Europe/Busingen" => "Europe/Zurich",
421 "Europe/Copenhagen" => "Europe/Berlin",
422 "Europe/Guernsey" => "Europe/London",
423 "Europe/Isle_of_Man" => "Europe/London",
424 "Europe/Jersey" => "Europe/London",
425 "Europe/Kiev" => "Europe/Kyiv",
426 "Europe/Ljubljana" => "Europe/Belgrade",
427 "Europe/Luxembourg" => "Europe/Brussels",
428 "Europe/Mariehamn" => "Europe/Helsinki",
429 "Europe/Monaco" => "Europe/Paris",
430 "Europe/Nicosia" => "Asia/Nicosia",
431 "Europe/Oslo" => "Europe/Berlin",
432 "Europe/Podgorica" => "Europe/Belgrade",
433 "Europe/San_Marino" => "Europe/Rome",
434 "Europe/Sarajevo" => "Europe/Belgrade",
435 "Europe/Skopje" => "Europe/Belgrade",
436 "Europe/Stockholm" => "Europe/Berlin",
437 "Europe/Tiraspol" => "Europe/Chisinau",
438 "Europe/Uzhgorod" => "Europe/Kyiv",
439 "Europe/Vaduz" => "Europe/Zurich",
440 "Europe/Vatican" => "Europe/Rome",
441 "Europe/Zagreb" => "Europe/Belgrade",
442 "Europe/Zaporozhye" => "Europe/Kyiv",
443 GB => "Europe/London",
444 "GB-Eire" => "Europe/London",
445 GMT => "Etc/GMT",
446 "GMT+0" => "Etc/GMT",
447 "GMT-0" => "Etc/GMT",
448 GMT0 => "Etc/GMT",
449 Greenwich => "Etc/GMT",
450 HST => "Pacific/Honolulu",
451 Hongkong => "Asia/Hong_Kong",
452 Iceland => "Africa/Abidjan",
453 "Indian/Antananarivo" => "Africa/Nairobi",
454 "Indian/Christmas" => "Asia/Bangkok",
455 "Indian/Cocos" => "Asia/Yangon",
456 "Indian/Comoro" => "Africa/Nairobi",
457 "Indian/Kerguelen" => "Indian/Maldives",
458 "Indian/Mahe" => "Asia/Dubai",
459 "Indian/Mayotte" => "Africa/Nairobi",
460 "Indian/Reunion" => "Asia/Dubai",
461 Iran => "Asia/Tehran",
462 Israel => "Asia/Jerusalem",
463 Jamaica => "America/Jamaica",
464 Japan => "Asia/Tokyo",
465 Kwajalein => "Pacific/Kwajalein",
466 Libya => "Africa/Tripoli",
467 MET => "Europe/Brussels",
468 MST => "America/Phoenix",
469 "Mexico/BajaNorte" => "America/Tijuana",
470 "Mexico/BajaSur" => "America/Mazatlan",
471 "Mexico/General" => "America/Mexico_City",
472 NZ => "Pacific/Auckland",
473 "NZ-CHAT" => "Pacific/Chatham",
474 Navajo => "America/Denver",
475 PRC => "Asia/Shanghai",
476 "Pacific/Chuuk" => "Pacific/Port_Moresby",
477 "Pacific/Enderbury" => "Pacific/Kanton",
478 "Pacific/Funafuti" => "Pacific/Tarawa",
479 "Pacific/Johnston" => "Pacific/Honolulu",
480 "Pacific/Majuro" => "Pacific/Tarawa",
481 "Pacific/Midway" => "Pacific/Pago_Pago",
482 "Pacific/Pohnpei" => "Pacific/Guadalcanal",
483 "Pacific/Ponape" => "Pacific/Guadalcanal",
484 "Pacific/Saipan" => "Pacific/Guam",
485 "Pacific/Samoa" => "Pacific/Pago_Pago",
486 "Pacific/Truk" => "Pacific/Port_Moresby",
487 "Pacific/Wake" => "Pacific/Tarawa",
488 "Pacific/Wallis" => "Pacific/Tarawa",
489 "Pacific/Yap" => "Pacific/Port_Moresby",
490 Poland => "Europe/Warsaw",
491 Portugal => "Europe/Lisbon",
492 ROC => "Asia/Taipei",
493 ROK => "Asia/Seoul",
494 Singapore => "Asia/Singapore",
495 Turkey => "Europe/Istanbul",
496 UCT => "Etc/UTC",
497 "US/Alaska" => "America/Anchorage",
498 "US/Aleutian" => "America/Adak",
499 "US/Arizona" => "America/Phoenix",
500 "US/Central" => "America/Chicago",
501 "US/East-Indiana" => "America/Indiana/Indianapolis",
502 "US/Eastern" => "America/New_York",
503 "US/Hawaii" => "Pacific/Honolulu",
504 "US/Indiana-Starke" => "America/Indiana/Knox",
505 "US/Michigan" => "America/Detroit",
506 "US/Mountain" => "America/Denver",
507 "US/Pacific" => "America/Los_Angeles",
508 "US/Samoa" => "Pacific/Pago_Pago",
509 UTC => "Etc/UTC",
510 Universal => "Etc/UTC",
511 "W-SU" => "Europe/Moscow",
512 WET => "Europe/Lisbon",
513 Zulu => "Etc/UTC",
514 });
515 1457 ▶sub olson_links() {
Subroutine olson_links: called CC=3 SCAR=11.1
Pod documented
516 1457 ▶ $li = eval($li) || die $@ if ref($li) eq "";
Branch: 1 branch
BranchTrueFalseTotal
if ref $li eq "" 7 1450 1457
Condition50%1/2
eval $li || die($@)
l!l
70
MC/DC0%0/1
eval $li || die($@)
eval $li
Truth table50%1/2
A
A= eval $li
Aresult
11
00
517 1457 return $li;
518 }
519  
520 =item olson_country_selection
521  
522 Returns information about how timezones relate to countries, intended
523 to aid humans in selecting a geographical timezone. This information
524 is derived from the C<zone.tab> and C<iso3166.tab> files in the database
525 source.
526  
527 The return value is a reference to a hash, keyed by (ISO 3166 alpha-2
528 uppercase) country code. The value for each country is a hash containing
529 these values:
530  
531 =over
532  
533 =item B<alpha2_code>
534  
535 The ISO 3166 alpha-2 uppercase country code.
536  
537 =item B<olson_name>
538  
539 An English name for the country, possibly in a modified form, optimised
540 to help humans find the right entry in alphabetical lists. This is
541 not necessarily identical to the country's standard short or long name.
542 (For other forms of the name, consult a database of countries, keying
543 by the country code.)
544  
545 =item B<regions>
546  
547 Information about the regions of the country that use distinct
548 timezones. This is a hash, keyed by English description of the region.
549 The description is empty if there is only one region. The value for
550 each region is a hash containing these values:
551  
552 =over
553  
554 =item B<olson_description>
555  
556 Brief English description of the region, used to distinguish between
557 the regions of a single country. Empty string if the country has only
558 one region for timezone purposes. (This is the same string used as the
559 key in the B<regions> hash.)
560  
561 =item B<timezone_name>
562  
563 Name of the Olson timezone used in this region. The named timezone is
564 guaranteed to exist in the database, but not necessarily as a canonical
565 name (it may be a link). Typically, where there are aliases or identical
566 canonical zones, a name is chosen that refers to a location in the
567 country of interest.
568  
569 =item B<location_coords>
570  
571 Geographical coordinates of some point within the location referred to in
572 the timezone name. This is a latitude and longitude, in ISO 6709 format.
573  
574 =back
575  
576 =back
577  
578 This data structure is intended to help a human select the appropriate
579 timezone based on political geography, specifically working from a
580 selection of country. It is of essentially no use for any other purpose.
581 It is not strictly guaranteed that every geographical timezone in the
582 database is listed somewhere in this structure, so it is of limited use
583 in providing information about an already-selected timezone. It does
584 not include non-geographic timezones at all. It also does not claim
585 to be a comprehensive list of countries, and does not make any claims
586 regarding the political status of any entity listed: the "country"
587 classification is loose, and used only for identification purposes.
588  
589 =cut
590  
591 9 my $cs;
592 1 ▶sub olson_country_selection() {
Subroutine olson_country_selection: called CC=4 SCAR=17.1
Pod documented
593 1 ▶ return $cs ||= do {
Condition33%1/3
$cs ||= do { my $fn = &_data_file("country_selection.tzp"); $@ = ""; do $fn or die $@ eq "" ? "${fn}: $!" : $@ }
l!l&&r!l&&!r
010
MC/DC0%0/2
$cs ||= do { my $fn = &_data_file("country_selection.tzp"); $@ = ""; do $fn or die $@ eq "" ? "${fn}: $!" : $@ }
$cs do { my $fn = &_data_file("country_selection.tzp"); $@ = ""; do $fn or die $@ eq "" ? "${fn}: $!" : $@ }
Truth table33%1/3
A ||= B
A= $csB= do { my $fn = &_data_file("country_selection.tzp"); $@ = ""; do $fn or die $@ eq "" ? "${fn}: $!" : $@ }
ABresult
1X1
011
000
594 1 my $fn = _data_file("country_selection.tzp");
595 1 ▶ $@ = ""; do($fn) || die($@ eq "" ? "$fn: $!" : $@);
Branch: 1 branch
BranchTrueFalseTotal
$@ eq '' ? : 0 0 0
Condition50%1/2
do $fn || die($@ eq '' ? "${fn}: $!" : $@)
l!l
10
MC/DC0%0/1
do $fn || die($@ eq '' ? "${fn}: $!" : $@)
do $fn
Truth table50%1/2
A
A= do $fn
Aresult
11
00
596 }
597 }
598  
599 =back
600  
601 =head2 Zone data
602  
603 =over
604  
605 =item olson_tzfile(NAME)
606  
607 Returns the pathname of the binary tzfile (in L<tzfile(5)> format)
608 describing the timezone named I<NAME> in the Olson database. C<die>s if
609 the name does not exist in this version of the database. The tzfile
610 is of at least version 2 of the format, and so does not suffer a Y2038
611 (32-bit time_t) problem.
612  
613 =cut
614  
615 1199 ▶sub olson_tzfile($) {
Subroutine olson_tzfile: called CC=3 SCAR=11.0
Pod documented
616 1199 my($tzname) = @_;
617 1199 ▶ $tzname = olson_links()->{$tzname} if exists olson_links()->{$tzname};
Branch: 1 branch
BranchTrueFalseTotal
if exists &olson_links()->{$tzname} 253 946 1199
618 1199 ▶ unless(exists olson_canonical_names()->{$tzname}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists &olson_canonical_names()->{$tzname}) 3 1196 1199
619 3 require Carp;
620 3 Carp::croak("no such timezone `$tzname' ".
621 3 "in the Olson @{[olson_version]} database");
622 }
623 1196 return _data_file($tzname.".tz");
624 }
625  
626 =back
627  
628 =head1 BUGS
629  
630 The Olson timezone database probably contains errors in the older
631 historical data. These will be corrected, as they are discovered,
632 in future versions of the database.
633  
634 Because legislatures commonly change civil timezone rules, in
635 unpredictable ways and often with little advance notice, the current
636 timezone data is liable to get out of date quite quickly. The Olson
637 timezone database is frequently updated to keep it accurate for current
638 dates. Frequently updating installations of this module from CPAN should
639 keep it similarly accurate.
640  
641 For the same reason, the future data in the database is liable to be
642 very inaccurate. The database includes, for each timezone, the current
643 best guess regarding its future behaviour, usually consisting of the
644 current rules being left unchanged indefinitely. (In most cases it is
645 unlikely that the rules will actually never be changed, but the current
646 rules still constitute the best guess available of future behaviour.)
647  
648 Because this module is intended to be frequently updated, long-running
649 programs (such as clock displays) will experience the module being
650 updated while in use. This can happen with any module, but is of
651 particular interest with this one. The behaviour in this situation is
652 not guaranteed, but here is a guide to current behaviour. The running
653 module code is of course not influenced by the C<.pm> file changing.
654 The ancillary data is all currently stored in the module code, and so
655 will be equally unaffected. Tzfiles pointed to by the module, however,
656 will change visibly. Newly reading a tzfile is liable to see a newer
657 version of the zone's data than the module's metadata suggests. A tzfile
658 could also theoretically disappear, if a zone's canonical name changes
659 (so the former canonical name becomes a link). To avoid weirdness,
660 it is recommended to read in all required tzfiles near the start of
661 a program's run, so that it doesn't matter if the files subsequently
662 change due to an update.
663  
664 =head1 SEE ALSO
665  
666 L<App::olson>,
667 L<DateTime::TimeZone::Olson>,
668 L<DateTime::TimeZone::Tzfile>,
669 L<Time::OlsonTZ::Download>,
670 L<tzfile(5)>
671  
672 =head1 AUTHOR
673  
674 The Olson timezone database was compiled by Arthur David Olson, Paul
675 Eggert, and many others. It is maintained by the denizens of the mailing
676 list <tz@iana.org> (formerly <tz@elsie.nci.nih.gov>).
677  
678 The C<Time::OlsonTZ::Data> Perl module wrapper for the database was
679 developed by Andrew Main (Zefram) <zefram@fysh.org>.
680  
681 =head1 COPYRIGHT
682  
683 The Olson timezone database is is the public domain.
684  
685 The C<Time::OlsonTZ::Data> Perl module wrapper for the database is
686 Copyright (C) 2010, 2011, 2012, 2013, 2014, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025
687 Andrew Main (Zefram) <zefram@fysh.org>.
688  
689 =head1 LICENSE
690  
691 No license is required to do anything with public domain materials.
692  
693 This module is free software; you can redistribute it and/or modify it
694 under the same terms as Perl itself.
695  
696 =cut
697  
698 9 1;
↑ Summary Data/country_selection.tzp »