File indexing completed on 2025-01-18 09:30:38
0001 #ifndef DATE_TIME_LOCAL_TIMEZONE_DEFS_HPP__
0002 #define DATE_TIME_LOCAL_TIMEZONE_DEFS_HPP__
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "boost/date_time/dst_rules.hpp"
0013
0014 namespace boost {
0015 namespace date_time {
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 template<class date_type>
0054 struct us_dst_trait
0055 {
0056 typedef typename date_type::day_of_week_type day_of_week_type;
0057 typedef typename date_type::month_type month_type;
0058 typedef typename date_type::year_type year_type;
0059 typedef date_time::nth_kday_of_month<date_type> start_rule_functor;
0060 typedef date_time::first_kday_of_month<date_type> end_rule_functor;
0061 typedef date_time::first_kday_of_month<date_type> start_rule_functor_pre2007;
0062 typedef date_time::last_kday_of_month<date_type> end_rule_functor_pre2007;
0063 static day_of_week_type start_day(year_type) {return Sunday;}
0064 static month_type start_month(year_type y)
0065 {
0066 if (y < 2007) return Apr;
0067 return Mar;
0068 }
0069 static day_of_week_type end_day(year_type) {return Sunday;}
0070 static month_type end_month(year_type y)
0071 {
0072 if (y < 2007) return Oct;
0073 return Nov;
0074 }
0075 static date_type local_dst_start_day(year_type year)
0076 {
0077 if (year < 2007) {
0078 start_rule_functor_pre2007 start1(start_day(year),
0079 start_month(year));
0080 return start1.get_date(year);
0081 }
0082 start_rule_functor start(start_rule_functor::second,
0083 start_day(year),
0084 start_month(year));
0085 return start.get_date(year);
0086
0087 }
0088 static date_type local_dst_end_day(year_type year)
0089 {
0090 if (year < 2007) {
0091 end_rule_functor_pre2007 end_rule(end_day(year),
0092 end_month(year));
0093 return end_rule.get_date(year);
0094 }
0095 end_rule_functor end(end_day(year),
0096 end_month(year));
0097 return end.get_date(year);
0098 }
0099 static int dst_start_offset_minutes() { return 120;}
0100 static int dst_end_offset_minutes() { return 120; }
0101 static int dst_shift_length_minutes() { return 60; }
0102 };
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112 template<class date_type>
0113 struct eu_dst_trait
0114 {
0115 typedef typename date_type::day_of_week_type day_of_week_type;
0116 typedef typename date_type::month_type month_type;
0117 typedef typename date_type::year_type year_type;
0118 typedef date_time::last_kday_of_month<date_type> start_rule_functor;
0119 typedef date_time::last_kday_of_month<date_type> end_rule_functor;
0120 static day_of_week_type start_day(year_type) {return Sunday;}
0121 static month_type start_month(year_type) {return Mar;}
0122 static day_of_week_type end_day(year_type) {return Sunday;}
0123 static month_type end_month(year_type) {return Oct;}
0124 static int dst_start_offset_minutes() { return 120;}
0125 static int dst_end_offset_minutes() { return 180; }
0126 static int dst_shift_length_minutes() { return 60; }
0127 static date_type local_dst_start_day(year_type year)
0128 {
0129 start_rule_functor start(start_day(year),
0130 start_month(year));
0131 return start.get_date(year);
0132 }
0133 static date_type local_dst_end_day(year_type year)
0134 {
0135 end_rule_functor end(end_day(year),
0136 end_month(year));
0137 return end.get_date(year);
0138 }
0139 };
0140
0141
0142
0143
0144
0145
0146
0147 template<class date_type>
0148 struct uk_dst_trait : public eu_dst_trait<date_type>
0149 {
0150 static int dst_start_offset_minutes() { return 60;}
0151 static int dst_end_offset_minutes() { return 120; }
0152 static int dst_shift_length_minutes() { return 60; }
0153 };
0154
0155
0156 template<class date_type>
0157 struct acst_dst_trait
0158 {
0159 typedef typename date_type::day_of_week_type day_of_week_type;
0160 typedef typename date_type::month_type month_type;
0161 typedef typename date_type::year_type year_type;
0162 typedef date_time::last_kday_of_month<date_type> start_rule_functor;
0163 typedef date_time::last_kday_of_month<date_type> end_rule_functor;
0164 static day_of_week_type start_day(year_type) {return Sunday;}
0165 static month_type start_month(year_type) {return Oct;}
0166 static day_of_week_type end_day(year_type) {return Sunday;}
0167 static month_type end_month(year_type) {return Mar;}
0168 static int dst_start_offset_minutes() { return 120;}
0169 static int dst_end_offset_minutes() { return 180; }
0170 static int dst_shift_length_minutes() { return 60; }
0171 static date_type local_dst_start_day(year_type year)
0172 {
0173 start_rule_functor start(start_day(year),
0174 start_month(year));
0175 return start.get_date(year);
0176 }
0177 static date_type local_dst_end_day(year_type year)
0178 {
0179 end_rule_functor end(end_day(year),
0180 end_month(year));
0181 return end.get_date(year);
0182 }
0183 };
0184
0185
0186
0187
0188
0189
0190 } }
0191
0192
0193 #endif