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