1#ifndef _DATE_TIME_TIME_ZONE_BASE__
2#define _DATE_TIME_TIME_ZONE_BASE__
3
4/* Copyright (c) 2003-2005 CrystalClear Software, Inc.
5 * Subject to the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
7 * Author: Jeff Garland, Bart Garst
8 * $Date$
9 */
10
11
12#include <string>
13#include <sstream>
14
15namespace boost {
16namespace date_time {
17
18
19
20 //! Interface class for dynamic time zones.
21 /*! This class represents the base interface for all timezone
22 * representations. Subclasses may provide different systems
23 * for identifying a particular zone. For example some may
24 * provide a geographical based zone construction while others
25 * may specify the offset from GMT. Another possible implementation
26 * would be to convert from POSIX timezone strings. Regardless of
27 * the construction technique, this is the interface that these
28 * time zone types must provide.
29 *
30 * Note that this class is intended to be used as a shared
31 * resource (hence the derivation from boost::counted_base.
32 */
33 template<typename time_type, typename CharT>
34 class time_zone_base {
35 public:
36 typedef CharT char_type;
37 typedef std::basic_string<CharT> string_type;
38 typedef std::basic_ostringstream<CharT> stringstream_type;
39 typedef typename time_type::date_type::year_type year_type;
40 typedef typename time_type::time_duration_type time_duration_type;
41
42 time_zone_base() {}
43 virtual ~time_zone_base() {}
44 //!String for the timezone when in daylight savings (eg: EDT)
45 virtual string_type dst_zone_abbrev() const=0;
46 //!String for the zone when not in daylight savings (eg: EST)
47 virtual string_type std_zone_abbrev() const=0;
48 //!String for the timezone when in daylight savings (eg: Eastern Daylight Time)
49 virtual string_type dst_zone_name() const=0;
50 //!String for the zone when not in daylight savings (eg: Eastern Standard Time)
51 virtual string_type std_zone_name() const=0;
52 //! True if zone uses daylight savings adjustments otherwise false
53 virtual bool has_dst() const=0;
54 //! Local time that DST starts -- undefined if has_dst is false
55 virtual time_type dst_local_start_time(year_type y) const=0;
56 //! Local time that DST ends -- undefined if has_dst is false
57 virtual time_type dst_local_end_time(year_type y) const=0;
58 //! Base offset from UTC for zone (eg: -07:30:00)
59 virtual time_duration_type base_utc_offset() const=0;
60 //! Adjustment forward or back made while DST is in effect
61 virtual time_duration_type dst_offset() const=0;
62 //! Returns a POSIX time_zone string for this object
63 virtual string_type to_posix_string() const =0;
64
65 private:
66
67 };
68
69
70 //! Structure which holds the time offsets associated with daylight savings time
71 /*!
72 *@param time_duration_type A type used to represent the offset
73 */
74 template<class time_duration_type>
75 class dst_adjustment_offsets
76 {
77 public:
78 dst_adjustment_offsets(const time_duration_type& dst_adjust,
79 const time_duration_type& dst_start_offset,
80 const time_duration_type& dst_end_offset) :
81 dst_adjust_(dst_adjust),
82 dst_start_offset_(dst_start_offset),
83 dst_end_offset_(dst_end_offset)
84 {}
85
86 //! Amount DST adjusts the clock eg: plus one hour
87 time_duration_type dst_adjust_;
88 //! Time past midnight on start transition day that dst starts
89 time_duration_type dst_start_offset_;
90 //! Time past midnight on end transition day that dst ends
91 time_duration_type dst_end_offset_;
92 };
93
94
95} } //namespace date_time
96
97
98
99#endif
100

source code of boost/boost/date_time/time_zone_base.hpp