pike.git
/
lib
/
modules
/
Calendar.pmod
/
TZnames.pmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/lib/modules/Calendar.pmod/TZnames.pmod:1:
// ---------------------------------------------------------------- // Timezone names // // this file is created half-manually // ----------------------------------------------------------------
-
//!
This
module
is a mapping of the names of
-
//!
all the geographical (political)
-
//!
based
timezones.
It
looks
mainly like
-
//! @pre{
-
//! (["Europe":({"Stockholm","Paris",...}),
-
//! "America":({"Chicago","Panama",...}),
-
//! ...
-
//! ])
-
//! @}
-
//!
-
//! It is mainly there for easy and reliable ways
-
//!
of
making
user interfaces to select timezone.
-
//!
-
//! The Posix and standard
timezones
(like CET
,
PST8PDT, etc)
-
//!
are
not
listed.
+
//! module
Calendar
+
//!
submodule
TZnames
+
//!
This
module
contains
listnings
of
available
timezones
,
+
//!
in
some
different
ways
#pike __REAL_VERSION__
-
//!
@decl
string _zone_tab()
-
//!
@decl
array(array) zone_tab()
-
//!
These
return
the raw respectively parsed zone tab file
+
//!
method
string _zone_tab()
+
//!
method
array(array) zone_tab()
+
//!
This
returns
the raw respectively parsed zone tab file
//! from the timezone data files. //! //! The parsed format is an array of zone tab line arrays,
-
//!
@code{
+
//!
<pre>
//! ({ string country_code, //! string position, //! string zone_name, //! string comment })
-
//!
@}
+
//!
</pre>
//!
-
//! To convert the position to a
@[
Geography.Position
]
, simply
+
//! To convert the position to a Geography.Position, simply
//! feed it to the constructor. static string raw_zone_tab=0; string _zone_tab() { return raw_zone_tab || (raw_zone_tab = Stdio.read_bytes( combine_path(__FILE__,"..","tzdata/zone.tab"))); }
pike.git/lib/modules/Calendar.pmod/TZnames.pmod:59:
else { array v=s/"\t"; if (sizeof(v)==3) return v+=({""}); else return v; } }) -({0})); }
-
//!
@decl
array(string) zonenames()
+
//!
method
array(string) zonenames()
//! This reads the zone.tab file and returns name of all
-
//! standard timezones, like
@tt{
"Europe/Belgrade"
@}
.
+
//! standard timezones, like "Europe/Belgrade".
static array(string) zone_names=0; array(string) zonenames() { return zone_names || (zone_names=column(zone_tab(),2)); }
-
+
//! constant mapping(string:array(string)) zones
//! This constant is a mapping that can be //! used to loop over to get all the region-based //! timezones. //! //! It looks like this:
-
//!
@code{
+
//!
<pre>
//! ([ "America": ({ "Los_Angeles", "Chicago", <i>[...]</i> }), //! "Europe": ({ "Stockholm", <i>[...]</i> }), //! <i>[...]</i> }),
-
//!
@}
+
//!
</pre>
//! //! Please note that loading all the timezones can take some //! time, since they are generated and compiled on the fly.
-
mapping
(string:array(string))
zones
=
+
+
mapping zones=
([ "America": ({"Scoresbysund","Godthab","Thule","New_York","Chicago", "Denver","Los_Angeles","Juneau","Yakutat","Anchorage", "Nome","Adak","Phoenix","Boise","Indianapolis", "Indiana/Marengo","Indiana/Knox","Indiana/Vevay", "Louisville","Detroit","Menominee","St_Johns","Goose_Bay", "Halifax","Glace_Bay","Montreal","Thunder_Bay","Nipigon", "Rainy_River","Winnipeg","Regina","Swift_Current", "Edmonton","Vancouver","Dawson_Creek","Pangnirtung", "Iqaluit","Rankin_Inlet","Cambridge_Bay","Yellowknife",
pike.git/lib/modules/Calendar.pmod/TZnames.pmod:163:
"Ashkhabad","Dubai","Samarkand","Tashkent","Saigon", "Aden","Yekaterinburg","Omsk","Novosibirsk","Krasnoyarsk", "Irkutsk","Yakutsk","Vladivostok","Magadan","Kamchatka", "Anadyr"}), "Australia": ({"Darwin","Perth","Brisbane","Lindeman","Adelaide", "Hobart","Melbourne","Sydney","Broken_Hill","Lord_Howe"}), ]); // this is used to dwim timezone
+
//! constant mapping(string:array(string)) abbr2zones
//! This mapping is used to look up abbreviation //! to the possible regional zones. //! //! It looks like this:
-
//!
@code{
-
//! ([ "CET": ({ "Europe/Stockholm",
@i{
[...]
@}
}),
-
//! "CST": ({ "America/Chicago", "Australia/Adelaide",
@i{
[...]
@}
}),
-
//!
@i{
[...]
@}
}),
-
//!
@}
+
//!
<pre>
+
//! ([ "CET": ({ "Europe/Stockholm",
<i>
[...]
</i>
}),
+
//! "CST": ({ "America/Chicago", "Australia/Adelaide",
<i>
[...]
</i>
}),
+
//!
<i>
[...]
</i>
}),
+
//!
</pre>
//!
-
//! Note this: Just because it's noted
@tt{
"CST"
@}
doesn't mean it's a
-
//! unique timezone. There
are
about 7 *different* timezones that
-
//!
use
@tt{
"CST"
@}
as abbreviation; not at the same time,
+
//! Note this: Just because it's noted "CST" doesn't mean it's a
+
//! unique timezone. There
is
about 7 *different* timezones that
+
//!
uses
"CST" as abbreviation; not at the same time,
//! though, so the DWIM routines checks this before //! it's satisfied. Same with some other timezones. //! //! For most timezones, there is a number of region timezones that for the //! given time are equal. This is because region timezones include rules //! about local summer time shifts and possible historic shifts. //!
-
//! The
@[
YMD.parse
]
functions can handle timezone abbreviations
+
//! The
<ref>
YMD.parse
</ref>
functions can handle timezone abbreviations
//! by guessing.
-
mapping
(string:array(string))
abbr2zones=
+
+
mapping abbr2zones=
([ "ACST": ({"America/Porto_Acre"}), "ACT": ({"America/Porto_Acre"}), "ADDT": ({"America/Pangnirtung"}), "ADMT": ({"Africa/Asmera", "Africa/Addis_Ababa"}), "ADT": ({"Atlantic/Bermuda", "Asia/Baghdad", "America/Thule", "America/Goose_Bay", "America/Halifax", "America/Glace_Bay", "America/Pangnirtung", "America/Barbados", "America/Martinique"}), "AFT": ({"Asia/Kabul"}), "AHDT": ({"America/Anchorage"}),