Chris@16: #ifndef _DATE_TIME_TIME_ZONE_BASE__ Chris@16: #define _DATE_TIME_TIME_ZONE_BASE__ Chris@16: Chris@16: /* Copyright (c) 2003-2005 CrystalClear Software, Inc. Chris@16: * Subject to the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) Chris@16: * Author: Jeff Garland, Bart Garst Chris@101: * $Date$ Chris@16: */ Chris@16: Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace date_time { Chris@16: Chris@16: Chris@16: Chris@16: //! Interface class for dynamic time zones. Chris@16: /*! This class represents the base interface for all timezone Chris@16: * representations. Subclasses may provide different systems Chris@16: * for identifying a particular zone. For example some may Chris@16: * provide a geographical based zone construction while others Chris@16: * may specify the offset from GMT. Another possible implementation Chris@16: * would be to convert from POSIX timezone strings. Regardless of Chris@16: * the construction technique, this is the interface that these Chris@16: * time zone types must provide. Chris@16: * Chris@16: * Note that this class is intended to be used as a shared Chris@16: * resource (hence the derivation from boost::counted_base. Chris@16: */ Chris@16: template Chris@16: class time_zone_base { Chris@16: public: Chris@16: typedef CharT char_type; Chris@16: typedef std::basic_string string_type; Chris@16: typedef std::basic_ostringstream stringstream_type; Chris@16: typedef typename time_type::date_type::year_type year_type; Chris@16: typedef typename time_type::time_duration_type time_duration_type; Chris@16: Chris@16: time_zone_base() {} Chris@16: virtual ~time_zone_base() {} Chris@16: //!String for the timezone when in daylight savings (eg: EDT) Chris@16: virtual string_type dst_zone_abbrev() const=0; Chris@16: //!String for the zone when not in daylight savings (eg: EST) Chris@16: virtual string_type std_zone_abbrev() const=0; Chris@16: //!String for the timezone when in daylight savings (eg: Eastern Daylight Time) Chris@16: virtual string_type dst_zone_name() const=0; Chris@16: //!String for the zone when not in daylight savings (eg: Eastern Standard Time) Chris@16: virtual string_type std_zone_name() const=0; Chris@16: //! True if zone uses daylight savings adjustments otherwise false Chris@16: virtual bool has_dst() const=0; Chris@16: //! Local time that DST starts -- undefined if has_dst is false Chris@16: virtual time_type dst_local_start_time(year_type y) const=0; Chris@16: //! Local time that DST ends -- undefined if has_dst is false Chris@16: virtual time_type dst_local_end_time(year_type y) const=0; Chris@16: //! Base offset from UTC for zone (eg: -07:30:00) Chris@16: virtual time_duration_type base_utc_offset() const=0; Chris@16: //! Adjustment forward or back made while DST is in effect Chris@16: virtual time_duration_type dst_offset() const=0; Chris@16: //! Returns a POSIX time_zone string for this object Chris@16: virtual string_type to_posix_string() const =0; Chris@16: Chris@16: private: Chris@16: Chris@16: }; Chris@16: Chris@16: Chris@16: //! Structure which holds the time offsets associated with daylight savings time Chris@16: /*! Chris@16: *@param time_duration_type A type used to represent the offset Chris@16: */ Chris@16: template Chris@16: class dst_adjustment_offsets Chris@16: { Chris@16: public: Chris@16: dst_adjustment_offsets(const time_duration_type& dst_adjust, Chris@16: const time_duration_type& dst_start_offset, Chris@16: const time_duration_type& dst_end_offset) : Chris@16: dst_adjust_(dst_adjust), Chris@16: dst_start_offset_(dst_start_offset), Chris@16: dst_end_offset_(dst_end_offset) Chris@16: {} Chris@16: Chris@16: //! Amount DST adjusts the clock eg: plus one hour Chris@16: time_duration_type dst_adjust_; Chris@16: //! Time past midnight on start transition day that dst starts Chris@16: time_duration_type dst_start_offset_; Chris@16: //! Time past midnight on end transition day that dst ends Chris@16: time_duration_type dst_end_offset_; Chris@16: }; Chris@16: Chris@16: Chris@16: } } //namespace date_time Chris@16: Chris@16: Chris@16: Chris@16: #endif