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