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.txt or http://www.boost.org/LICENSE_1_0.txt)
5 * Author: Jeff Garland, Bart Garst
7 #ifndef DATE_TIME_DATE_DST_TRANSITION_DAY_GEN_HPP__
8 #define DATE_TIME_DATE_DST_TRANSITION_DAY_GEN_HPP__
15 //! Defines base interface for calculating start and end date of daylight savings
16 template<class date_type>
17 class dst_day_calc_rule
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;
29 //! Canonical form for a class that provides day rule calculation
30 /*! This class is used to generate specific sets of dst rules
32 *@param spec Provides a specifiction of the function object types used
33 * to generate start and end days of daylight savings as well
37 class day_calc_dst_rule : public dst_day_calc_rule<typename spec::date_type>
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,
46 dst_start_(dst_start),
49 virtual date_type start_day(year_type y) const
51 return dst_start_.get_date(y);
53 virtual std::string start_rule_as_string() const
55 return dst_start_.to_string();
57 virtual date_type end_day(year_type y) const
59 return dst_end_.get_date(y);
61 virtual std::string end_rule_as_string() const
63 return dst_end_.to_string();
66 start_rule dst_start_;