pike.git/
lib/
modules/
Calendar.pmod/
TZnames.pmod
Branch:
Tag:
Non-build tags
All tags
No tags
2001-01-10
2001-01-10 11:54:05 by Mirar (Pontus Hagland) <pike@sort.mirar.org>
fce912f362470514817417aeba5df22e5d6f5e8f (
61
lines) (+
59
/-
2
)
[
Show
|
Annotate
]
Branch:
7.9
added zone_tab, _zone_tab and zonenames
Rev: lib/modules/Calendar.pmod/TZnames.pmod:1.7
8:
//! submodule TZnames //! This module contains listnings of available timezones, //! in some different ways
+
+
#pike __REAL_VERSION__
+
+
//! 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,
+
//! <pre>
+
//! ({ string country_code,
+
//! string position,
+
//! string zone_name,
+
//! string comment })
+
//! </pre>
+
//!
+
//! 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")));
+
}
+
+
static array(array(string)) parsed_zone_tab=0;
+
array(array(string)) zone_tab()
+
{
+
return parsed_zone_tab ||
+
(parsed_zone_tab=
+
map(_zone_tab()/"\n",
+
lambda(string s)
+
{
+
if (s=="" || s[0]=='#')
+
return 0;
+
else
+
{
+
array v=s/"\t";
+
if (sizeof(v)==3) return v+=({""});
+
else return v;
+
}
+
})
+
-({0}));
+
}
+
+
//! method array(string) zonenames()
+
//! This reads the zone.tab file and returns name of all
+
//! 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
24:
//! Please note that loading all the timezones can take some //! time, since they are generated and compiled on the fly.
-
#pike __REAL_VERSION__
-
+
mapping zones= ([ "America": ({"Scoresbysund","Godthab","Thule","New_York","Chicago",
1372:
-3600:"Europe/Luxembourg", 0:"Europe/Brussels",]),]),]),]),]), -7200:"Europe/Warsaw",]),]),]);
+
+