Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:40

0001 #ifndef _DATE_TIME_TIME_ZONE_BASE__
0002 #define _DATE_TIME_TIME_ZONE_BASE__
0003 
0004 /* Copyright (c) 2003-2005 CrystalClear Software, Inc.
0005  * Subject to the Boost Software License, Version 1.0.
0006  * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
0007  * Author: Jeff Garland, Bart Garst
0008  * $Date$
0009  */
0010 
0011 
0012 #include <string>
0013 #include <sstream>
0014 #include <boost/date_time/compiler_config.hpp>
0015 
0016 namespace boost {
0017 namespace date_time {
0018 
0019 
0020 
0021   //! Interface class for dynamic time zones.
0022   /*! This class represents the base interface for all timezone
0023    *  representations.  Subclasses may provide different systems
0024    *  for identifying a particular zone.  For example some may
0025    *  provide a geographical based zone construction while others
0026    *  may specify the offset from GMT.  Another possible implementation
0027    *  would be to convert from POSIX timezone strings.  Regardless of
0028    *  the construction technique, this is the interface that these
0029    *  time zone types must provide.
0030    *
0031    * Note that this class is intended to be used as a shared
0032    * resource (hence the derivation from boost::counted_base.
0033    */
0034   template<typename time_type, typename CharT>
0035   class BOOST_SYMBOL_VISIBLE time_zone_base  {
0036   public:
0037     typedef CharT char_type;
0038     typedef std::basic_string<CharT> string_type;
0039     typedef std::basic_ostringstream<CharT> stringstream_type;
0040     typedef typename time_type::date_type::year_type year_type;
0041     typedef typename time_type::time_duration_type time_duration_type;
0042 
0043     time_zone_base() {}
0044     virtual ~time_zone_base() {}
0045     //!String for the timezone when in daylight savings (eg: EDT)
0046     virtual string_type dst_zone_abbrev() const=0;
0047     //!String for the zone when not in daylight savings (eg: EST)
0048     virtual string_type std_zone_abbrev() const=0;
0049     //!String for the timezone when in daylight savings (eg: Eastern Daylight Time)
0050     virtual string_type dst_zone_name() const=0;
0051     //!String for the zone when not in daylight savings (eg: Eastern Standard Time)
0052     virtual string_type std_zone_name() const=0;
0053     //! True if zone uses daylight savings adjustments otherwise false
0054     virtual bool has_dst() const=0;
0055     //! Local time that DST starts -- undefined if has_dst is false
0056     virtual time_type dst_local_start_time(year_type y) const=0;
0057     //! Local time that DST ends -- undefined if has_dst is false
0058     virtual time_type dst_local_end_time(year_type y) const=0;
0059     //! Base offset from UTC for zone (eg: -07:30:00)
0060     virtual time_duration_type base_utc_offset() const=0;
0061     //! Adjustment forward or back made while DST is in effect
0062     virtual time_duration_type dst_offset() const=0;
0063     //! Returns a POSIX time_zone string for this object
0064     virtual string_type to_posix_string() const =0;
0065 
0066   private:
0067 
0068   };
0069 
0070 
0071   //! Structure which holds the time offsets associated with daylight savings time
0072   /*!
0073    *@tparam time_duration_type A type used to represent the offset
0074    */
0075   template<class time_duration_type>
0076   class dst_adjustment_offsets
0077   {
0078   public:
0079     dst_adjustment_offsets(const time_duration_type& dst_adjust,
0080                            const time_duration_type& dst_start_offset,
0081                            const time_duration_type& dst_end_offset) :
0082       dst_adjust_(dst_adjust),
0083       dst_start_offset_(dst_start_offset),
0084       dst_end_offset_(dst_end_offset)
0085     {}
0086 
0087     //! Amount DST adjusts the clock eg: plus one hour
0088     time_duration_type dst_adjust_;
0089     //! Time past midnight on start transition day that dst starts
0090     time_duration_type dst_start_offset_;
0091     //! Time past midnight on end transition day that dst ends
0092     time_duration_type dst_end_offset_;
0093   };
0094 
0095 
0096 } } //namespace date_time
0097 
0098 
0099 
0100 #endif