Chris@16: /* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc. Chris@16: * Use, modification and distribution is subject to the Chris@16: * Boost Software License, Version 1.0. (See accompanying Chris@16: * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) Chris@16: * Author: Jeff Garland, Bart Garst Chris@16: */ Chris@16: #ifndef DATE_TIME_DATE_DST_TRANSITION_DAY_GEN_HPP__ Chris@16: #define DATE_TIME_DATE_DST_TRANSITION_DAY_GEN_HPP__ Chris@16: Chris@16: Chris@16: Chris@16: namespace boost { Chris@16: namespace date_time { Chris@16: Chris@16: //! Defines base interface for calculating start and end date of daylight savings Chris@16: template Chris@16: class dst_day_calc_rule Chris@16: { Chris@16: public: Chris@16: typedef typename date_type::year_type year_type; Chris@16: virtual ~dst_day_calc_rule() {} Chris@16: virtual date_type start_day(year_type y) const=0; Chris@16: virtual std::string start_rule_as_string() const=0; Chris@16: virtual date_type end_day(year_type y) const=0; Chris@16: virtual std::string end_rule_as_string() const=0; Chris@16: Chris@16: }; Chris@16: Chris@16: //! Canonical form for a class that provides day rule calculation Chris@16: /*! This class is used to generate specific sets of dst rules Chris@16: * Chris@16: *@param spec Provides a specifiction of the function object types used Chris@16: * to generate start and end days of daylight savings as well Chris@16: * as the date type. Chris@16: */ Chris@16: template Chris@16: class day_calc_dst_rule : public dst_day_calc_rule Chris@16: { Chris@16: public: Chris@16: typedef typename spec::date_type date_type; Chris@16: typedef typename date_type::year_type year_type; Chris@16: typedef typename spec::start_rule start_rule; Chris@16: typedef typename spec::end_rule end_rule; Chris@16: day_calc_dst_rule(start_rule dst_start, Chris@16: end_rule dst_end) : Chris@16: dst_start_(dst_start), Chris@16: dst_end_(dst_end) Chris@16: {} Chris@16: virtual date_type start_day(year_type y) const Chris@16: { Chris@16: return dst_start_.get_date(y); Chris@16: } Chris@16: virtual std::string start_rule_as_string() const Chris@16: { Chris@16: return dst_start_.to_string(); Chris@16: } Chris@16: virtual date_type end_day(year_type y) const Chris@16: { Chris@16: return dst_end_.get_date(y); Chris@16: } Chris@16: virtual std::string end_rule_as_string() const Chris@16: { Chris@16: return dst_end_.to_string(); Chris@16: } Chris@16: private: Chris@16: start_rule dst_start_; Chris@16: end_rule dst_end_; Chris@16: }; Chris@16: Chris@16: Chris@16: } }//namespace Chris@16: Chris@16: Chris@16: Chris@16: #endif