source: NonGTP/Boost/boost/date_time/time_zone_base.hpp @ 857

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