Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::date_time::tz_db_base< time_zone_type, rule_type > Class Template Reference

Creates a database of time_zones from csv datafile. More...

#include <tz_db_base.hpp>

Public Types

typedef char char_type
 
typedef time_zone_type::base_type time_zone_base_type
 
typedef
time_zone_type::time_duration_type 
time_duration_type
 
typedef time_zone_names_base
< char_type
time_zone_names
 
typedef
boost::date_time::dst_adjustment_offsets
< time_duration_type
dst_adjustment_offsets
 
typedef std::basic_string
< char_type
string_type
 

Public Member Functions

 tz_db_base ()
 Constructs an empty database. More...
 
void load_from_stream (std::istream &in)
 Process csv data file, may throw exceptions. More...
 
void load_from_file (const std::string &pathspec)
 Process csv data file, may throw exceptions. More...
 
bool add_record (const string_type &region, boost::shared_ptr< time_zone_base_type > tz)
 returns true if record successfully added to map More...
 
boost::shared_ptr
< time_zone_base_type
time_zone_from_region (const string_type &region) const
 Returns a time_zone object built from the specs for the given region. More...
 
std::vector< std::string > region_list () const
 Returns a vector of strings holding the time zone regions in the database. More...
 

Detailed Description

template<class time_zone_type, class rule_type>
class boost::date_time::tz_db_base< time_zone_type, rule_type >

Creates a database of time_zones from csv datafile.

The csv file containing the zone_specs used by the tz_db_base is intended to be customized by the library user. When customizing this file (or creating your own) the file must follow a specific format.

This first line is expected to contain column headings and is therefore not processed by the tz_db_base.

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. Ex:

"America/Phoenix" <- string enclosed in quotes
"" <- empty field

Some fields represent a length of time. The format of these fields must be:

"{+|-}hh:mm[:ss]" <- length-of-time format

Where the plus or minus is mandatory and the seconds are optional.

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).

******* Fields and their description/details *********

ID: 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.

STD ABBR: STD NAME: DST ABBR: DST NAME: 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. Ex:

time_zone nyc = tz_db.time_zone_from_region("America/New_York");
local_time ny_time(date(2004, Aug, 30), IS_DST, nyc);
cout << ny_time.to_long_string() << endl;
// 2004-Aug-30 00:00:00 Eastern Daylight Time
cout << ny_time.to_short_string() << endl;
// 2004-Aug-30 00:00:00 EDT

NOTE: The exact format/function names may vary - see local_time documentation for further details.

GMT offset: 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, & Africa/Cairo offset +2 hours. The format must follow the length-of-time format described above.

DST adjustment: 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.

DST Start Date rule: 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. 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). The second field indicates the day-of-week from 0-6 (Sun=0). The third field indicates the month from 1-12 (Jan=1).

Examples are: "-1;5;9"="Last Friday of September", "2;1;3"="Second Monday of March"

Start time: 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.

DST End date rule: See DST Start date rule. The difference here is this is the day daylight savings ends (transition to STD).

End time: Same as Start time.

Member Typedef Documentation

template<class time_zone_type , class rule_type >
typedef char boost::date_time::tz_db_base< time_zone_type, rule_type >::char_type
template<class time_zone_type , class rule_type >
typedef boost::date_time::dst_adjustment_offsets<time_duration_type> boost::date_time::tz_db_base< time_zone_type, rule_type >::dst_adjustment_offsets
template<class time_zone_type , class rule_type >
typedef std::basic_string<char_type> boost::date_time::tz_db_base< time_zone_type, rule_type >::string_type
template<class time_zone_type , class rule_type >
typedef time_zone_type::time_duration_type boost::date_time::tz_db_base< time_zone_type, rule_type >::time_duration_type
template<class time_zone_type , class rule_type >
typedef time_zone_type::base_type boost::date_time::tz_db_base< time_zone_type, rule_type >::time_zone_base_type
template<class time_zone_type , class rule_type >
typedef time_zone_names_base<char_type> boost::date_time::tz_db_base< time_zone_type, rule_type >::time_zone_names

Constructor & Destructor Documentation

template<class time_zone_type , class rule_type >
boost::date_time::tz_db_base< time_zone_type, rule_type >::tz_db_base ( )
inline

Constructs an empty database.

Member Function Documentation

template<class time_zone_type , class rule_type >
bool boost::date_time::tz_db_base< time_zone_type, rule_type >::add_record ( const string_type region,
boost::shared_ptr< time_zone_base_type tz 
)
inline

returns true if record successfully added to map

Takes a region name in the form of "America/Phoenix", and a time_zone object for that region. The id string must be a unique name that does not already exist in the database.

References boost::multiprecision::backends::p, and boost::locale::period::marks::second.

template<class time_zone_type , class rule_type >
void boost::date_time::tz_db_base< time_zone_type, rule_type >::load_from_file ( const std::string &  pathspec)
inline
template<class time_zone_type , class rule_type >
void boost::date_time::tz_db_base< time_zone_type, rule_type >::load_from_stream ( std::istream &  in)
inline

Process csv data file, may throw exceptions.

May throw bad_field_count exceptions

References boost::container::getline().

Referenced by boost::date_time::tz_db_base< time_zone_type, rule_type >::load_from_file().

template<class time_zone_type , class rule_type >
std::vector<std::string> boost::date_time::tz_db_base< time_zone_type, rule_type >::region_list ( ) const
inline

Returns a vector of strings holding the time zone regions in the database.

template<class time_zone_type , class rule_type >
boost::shared_ptr<time_zone_base_type> boost::date_time::tz_db_base< time_zone_type, rule_type >::time_zone_from_region ( const string_type region) const
inline

Returns a time_zone object built from the specs for the given region.

Returns a time_zone object built from the specs for the given region. If region does not exist a local_time::record_not_found exception will be thrown


The documentation for this class was generated from the following file: