File Coverage

blib/lib/Time/OlsonTZ/Data.pm
Criterion Covered Total %
statement 48 48 100.0
branch 11 14 78.5
condition 6 11 54.5
subroutine 14 14 100.0
pod 6 6 100.0
total 85 93 91.4


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