[857] | 1 | /* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
|
---|
| 2 | * Use, modification and distribution is subject to the
|
---|
| 3 | * Boost Software License, Version 1.0. (See accompanying
|
---|
| 4 | * file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
|
---|
| 5 | * Author: Jeff Garland, Bart Garst
|
---|
| 6 | */
|
---|
| 7 | #ifndef DATE_TIME_DATE_DST_TRANSITION_DAY_GEN_HPP__
|
---|
| 8 | #define DATE_TIME_DATE_DST_TRANSITION_DAY_GEN_HPP__
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | namespace boost {
|
---|
| 13 | namespace date_time {
|
---|
| 14 |
|
---|
| 15 | //! Defines base interface for calculating start and end date of daylight savings
|
---|
| 16 | template<class date_type>
|
---|
| 17 | class dst_day_calc_rule
|
---|
| 18 | {
|
---|
| 19 | public:
|
---|
| 20 | typedef typename date_type::year_type year_type;
|
---|
| 21 | virtual ~dst_day_calc_rule() {};
|
---|
| 22 | virtual date_type start_day(year_type y) const=0;
|
---|
| 23 | virtual std::string start_rule_as_string() const=0;
|
---|
| 24 | virtual date_type end_day(year_type y) const=0;
|
---|
| 25 | virtual std::string end_rule_as_string() const=0;
|
---|
| 26 |
|
---|
| 27 | };
|
---|
| 28 |
|
---|
| 29 | //! Canonical form for a class that provides day rule calculation
|
---|
| 30 | /*! This class is used to generate specific sets of dst rules
|
---|
| 31 | *
|
---|
| 32 | *@param spec Provides a specifiction of the function object types used
|
---|
| 33 | * to generate start and end days of daylight savings as well
|
---|
| 34 | * as the date type.
|
---|
| 35 | */
|
---|
| 36 | template<class spec>
|
---|
| 37 | class day_calc_dst_rule : public dst_day_calc_rule<typename spec::date_type>
|
---|
| 38 | {
|
---|
| 39 | public:
|
---|
| 40 | typedef typename spec::date_type date_type;
|
---|
| 41 | typedef typename date_type::year_type year_type;
|
---|
| 42 | typedef typename spec::start_rule start_rule;
|
---|
| 43 | typedef typename spec::end_rule end_rule;
|
---|
| 44 | day_calc_dst_rule(start_rule dst_start,
|
---|
| 45 | end_rule dst_end) :
|
---|
| 46 | dst_start_(dst_start),
|
---|
| 47 | dst_end_(dst_end)
|
---|
| 48 | {}
|
---|
| 49 | virtual date_type start_day(year_type y) const
|
---|
| 50 | {
|
---|
| 51 | return dst_start_.get_date(y);
|
---|
| 52 | }
|
---|
| 53 | virtual std::string start_rule_as_string() const
|
---|
| 54 | {
|
---|
| 55 | return dst_start_.to_string();
|
---|
| 56 | }
|
---|
| 57 | virtual date_type end_day(year_type y) const
|
---|
| 58 | {
|
---|
| 59 | return dst_end_.get_date(y);
|
---|
| 60 | }
|
---|
| 61 | virtual std::string end_rule_as_string() const
|
---|
| 62 | {
|
---|
| 63 | return dst_end_.to_string();
|
---|
| 64 | }
|
---|
| 65 | private:
|
---|
| 66 | start_rule dst_start_;
|
---|
| 67 | end_rule dst_end_;
|
---|
| 68 | };
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | } }//namespace
|
---|
| 72 |
|
---|
| 73 |
|
---|
| 74 |
|
---|
| 75 | #endif
|
---|