Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/date_time/xmldoc/tz_database.xml @ 44

Last change on this file since 44 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 10.5 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
3"../../../tools/boostbook/dtd/boostbook.dtd">
4
5<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
6     Subject to the Boost Software License, Version 1.0.
7     (See accompanying file LICENSE-1.0 or  http://www.boost.org/LICENSE-1.0)
8-->
9
10<section id="date_time.local_time.tz_database">
11  <title>Time Zone Database</title>
12
13  <link linkend="tz_database_intro">Introduction</link> --
14  <link linkend="tz_database_header">Header</link> --
15  <link linkend="tz_database_constr">Construction</link> --
16  <link linkend="tz_database_accessors">Accessors</link> --
17  <link linkend="tz_database_datafile">Data File Details</link>
18
19  <anchor id="tz_database_intro" />
20  <bridgehead renderas="sect3">Introduction</bridgehead>
21  <para>
22    The local_time system depends on the ability to store time zone information. Our Time Zone Database (tz_database) is a means of permanently storing that data. The specifications for many time zones (377 at this time) are provided. These specifications are based on data found in the <ulink url="http://www.twinsun.com/tz/tz-link.htm">zoneinfo datebase</ulink>. The specifications are stored in the file:<screen>libs/date_time/data/date_time_zonespec.csv</screen>. While this file already contains specifications for many time zones, it's real intent is for the user to modify it by adding (or removing) time zones to fit their application. See <link linkend="tz_database_datafile">Data File Details</link> to learn how this is accomplished.
23  </para>
24
25  <anchor id="tz_database_header" />
26  <bridgehead renderas="sect3">Header</bridgehead>
27  <para>
28    The inclusion of a single header will bring in all boost::local_time types, functions, and IO operators.
29    <programlisting>#include "boost/date_time/local_time/local_time.hpp"
30    </programlisting>
31  </para>
32
33  <anchor id="tz_database_constr" />
34  <bridgehead renderas="sect3">Construction</bridgehead>
35  <para>
36    The only constructor takes no arguments and creates an empty database. It is up to the user to populate the database. This is typically achieved by loading the desired datafile, but can also be accomplished by means of the <code>add_record(...)</code> function (see the <link linkend="tz_database_accessors">Accessors table</link>). A <code>local_time::data_not_accessible</code> exception will be thrown if given zonespec file cannot be found. <code>local_time::bad_field_count</code> exception will be thrown if the number of fields in given zonespec file is incorrect.
37  </para>
38  <para>
39    <informaltable frame="all">
40      <tgroup cols="2">
41        <thead>
42          <row>
43            <entry valign="top" morerows="1">Syntax</entry>
44            <entry>Description</entry>
45          </row>
46        </thead>
47        <tbody>
48          <row>
49            <entry valign="top" morerows="1"><screen>tz_database()</screen></entry>
50            <entry>Constructor creates an empty database.</entry>
51          </row>
52          <row>
53            <entry><screen>tz_database tz_db;</screen></entry>
54          </row>
55
56          <row>
57            <entry valign="top" morerows="1"><screen>bool load_from_file(std::string)</screen></entry>
58            <entry>Parameter is path to a time zone spec csv file (see <link linkend="tz_database_datafile">Data File Details</link> for details on the contents of this file). This function populates the database with time zone records found in the zone spec file. A <code>local_time::data_not_accessible</code> exception will be thrown if given zonespec file cannot be found. <code>local_time::bad_field_count</code> exception will be thrown if the number of fields in given zonespec file is incorrect.</entry>
59          </row>
60          <row>
61            <entry><screen>tz_database tz_db;
62tz_db.load_from_file("./date_time_zonespec.csv");</screen>
63            </entry>
64          </row>
65        </tbody>
66      </tgroup>
67    </informaltable>
68  </para>
69
70  <anchor id="tz_database_accessors" />
71  <bridgehead renderas="sect3">Accessors</bridgehead>
72  <para>
73    <informaltable frame="all">
74      <tgroup cols="2">
75        <thead>
76          <row>
77            <entry valign="top" morerows="1">Syntax</entry>
78            <entry>Description</entry>
79          </row>
80          <row>
81            <entry>Example</entry>
82          </row>
83        </thead>
84        <tbody>
85          <row>
86            <entry valign="top" morerows="1"><screen>bool tz_db.add_record(std::string id,
87                      <link linkend="date_time.local_time.custom_time_zone_ptr">time_zone_ptr</link> tz);</screen></entry>
88            <entry>Adds a time_zone, or a posix_time_zone, to the database. ID is the region name for this zone (Ex: "America/Phoenix").</entry>
89          </row>
90          <row>
91            <entry><screen>time_zone_ptr zone(
92  new posix_time_zone("PST-8PDT,M4.1.0,M10.1.0")
93);
94std::string id("America/West_Coast");
95tz_db.add_record(id, zone);</screen>
96            </entry>
97          </row>
98           
99          <row>
100            <entry valign="top" morerows="1"><screen>time_zone_ptr
101  tz_db.time_zone_from_region(string id);</screen></entry>
102            <entry>Returns a time_zone, via a time_zone_ptr, that matches the region listed in the data file. A null pointer is returned if no match is found.
103            </entry>
104          </row>
105          <row>
106            <entry><screen>time_zone_ptr nyc =
107  tz_db.time_zone_from_region("America/New_York");</screen>
108            </entry>
109          </row>
110         
111          <row>
112            <entry valign="top" morerows="1"><screen>vector&lt;string&gt; tz_db.region_list();</screen></entry>
113            <entry>Returns a vector of strings that holds all the region ID strings from the database.</entry>
114          </row>
115          <row>
116            <entry><screen>std::vector&lt;std::string&gt; regions;
117regions = tz_db.region_list();</screen>
118            </entry>
119          </row>
120        </tbody>
121      </tgroup>
122    </informaltable>
123  </para>
124
125  <anchor id="tz_database_datafile" />
126  <bridgehead renderas="sect3">Data File Details</bridgehead>
127  <link linkend="tz_database_fields">Field Description/Details</link>
128  <para>
129    The csv file containing the zone_specs used by the boost::local_time::tz_database is intended to be customized by the library user. When customizing this file (or creating your own) the file must follow a specific format.
130  </para>
131  <para>
132    This first line is expected to contain column headings and is therefore
133not processed by the tz_database.
134  </para>
135  <para>
136    Each record (line) must have eleven fields. Some of those fields can be empty. Every field (even empty ones) must be enclosed in double-quotes.
137    <literallayout>
138      Ex:
139      "America/Phoenix" &lt;- string enclosed in quotes
140      ""                &lt;- empty field
141    </literallayout>
142  </para>
143  <para>
144    Some fields represent a length of time. The format of these fields must be:
145    <literallayout>
146      "{+|-}hh:mm[:ss]" &lt;- length-of-time format
147    </literallayout>
148    Where the plus or minus is mandatory and the seconds are optional.
149  </para>
150  <para>
151    Since some time zones do not use daylight savings it is not always necessary for every field in a zone_spec to contain a value. All zone_specs must have at least ID and GMT offset. Zones that use daylight savings must have all fields filled except: STD ABBR, STD NAME, DST NAME. You should take note that DST ABBR is mandatory for zones that use daylight savings (see field descriptions for further details).
152  </para>
153
154  <anchor id="tz_database_fields" />
155  <bridgehead renderas="sect3">Field Description/Details</bridgehead>
156  <para>
157    <itemizedlist>
158      <listitem>
159        ID
160        <para>
161          Contains the identifying string for the zone_spec. Any string will do as long as it's unique. No two ID's can be the same.
162        </para>
163      </listitem>
164      <listitem>
165        STD ABBR
166      </listitem>
167      <listitem>
168        STD NAME
169      </listitem>
170      <listitem>
171        DST ABBR
172      </listitem>
173      <listitem>
174        DST NAME
175        <para>
176          These four are all the names and abbreviations used by the time zone being described. While any string will do in these fields, care should be taken. These fields hold the strings that will be used in the output of many of the local_time classes.
177        </para>
178      </listitem>
179      <listitem>
180        GMT offset
181        <para>
182          This is the number of hours added to utc to get the local time before any daylight savings adjustments are made. Some examples are: America/New_York offset -5 hours, and Africa/Cairo offset +2 hours. The format must follow the length-of-time format described above.
183        </para>
184      </listitem>
185      <listitem>
186        DST adjustment
187        <para>
188          The amount of time added to gmt_offset when daylight savings is in effect. The format must follow the length-of-time format described above.
189        </para>
190        <para>
191          NOTE: more rule capabilities are needed - this portion of the tz_database is incomplete
192        </para>
193      </listitem>
194      <listitem>
195        DST Start Date rule
196        <para>
197          This is a specially formatted string that describes the day of year in which the transition take place. It holds three fields of it's own, separated by semicolons.
198          <orderedlist>
199            <listitem>
200              The first field indicates the "nth" weekday of the month. The possible values are: 1 (first), 2 (second), 3 (third), 4 (fourth), 5 (fifth), and -1 (last).
201            </listitem>
202            <listitem>
203              The second field indicates the day-of-week from 0-6 (Sun=0).
204            </listitem>
205            <listitem>
206              The third field indicates the month from 1-12 (Jan=1).
207            </listitem>
208          </orderedlist>
209          Examples are: "-1;5;9"="Last Friday of September", "2;1;3"="Second Monday of March"
210        </para>
211      </listitem>
212      <listitem>
213        Start time
214        <para>
215          Start time is the number of hours past midnight, on the day of the start transition, the transition takes place. More simply put, the time of day the transition is made (in 24 hours format). The format must follow the length-of-time format described above with the exception that it must always be positive.
216        </para>
217      </listitem>
218      <listitem>
219        DST End date rule
220        <para>
221          See DST Start date rule. The difference here is this is the day daylight savings ends (transition to STD).
222        </para>
223      </listitem>
224      <listitem>
225        End time
226        <para>
227          Same as Start time.
228        </para>
229      </listitem>
230    </itemizedlist>
231  </para>
232
233</section>
Note: See TracBrowser for help on using the repository browser.