123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- #ifndef DATE_TIME_LOCAL_TIMEZONE_DEFS_HPP__
- #define DATE_TIME_LOCAL_TIMEZONE_DEFS_HPP__
- #include "boost/date_time/dst_rules.hpp"
- namespace boost {
- namespace date_time {
-
-
-
-
-
- template<class date_type>
- struct us_dst_trait
- {
- typedef typename date_type::day_of_week_type day_of_week_type;
- typedef typename date_type::month_type month_type;
- typedef typename date_type::year_type year_type;
- typedef date_time::nth_kday_of_month<date_type> start_rule_functor;
- typedef date_time::first_kday_of_month<date_type> end_rule_functor;
- typedef date_time::first_kday_of_month<date_type> start_rule_functor_pre2007;
- typedef date_time::last_kday_of_month<date_type> end_rule_functor_pre2007;
- static day_of_week_type start_day(year_type) {return Sunday;}
- static month_type start_month(year_type y)
- {
- if (y < 2007) return Apr;
- return Mar;
- }
- static day_of_week_type end_day(year_type) {return Sunday;}
- static month_type end_month(year_type y)
- {
- if (y < 2007) return Oct;
- return Nov;
- }
- static date_type local_dst_start_day(year_type year)
- {
- if (year < 2007) {
- start_rule_functor_pre2007 start1(start_day(year),
- start_month(year));
- return start1.get_date(year);
- }
- start_rule_functor start(start_rule_functor::second,
- start_day(year),
- start_month(year));
- return start.get_date(year);
-
- }
- static date_type local_dst_end_day(year_type year)
- {
- if (year < 2007) {
- end_rule_functor_pre2007 end_rule(end_day(year),
- end_month(year));
- return end_rule.get_date(year);
- }
- end_rule_functor end(end_day(year),
- end_month(year));
- return end.get_date(year);
- }
- static int dst_start_offset_minutes() { return 120;}
- static int dst_end_offset_minutes() { return 120; }
- static int dst_shift_length_minutes() { return 60; }
- };
-
-
- template<class date_type>
- struct eu_dst_trait
- {
- typedef typename date_type::day_of_week_type day_of_week_type;
- typedef typename date_type::month_type month_type;
- typedef typename date_type::year_type year_type;
- typedef date_time::last_kday_of_month<date_type> start_rule_functor;
- typedef date_time::last_kday_of_month<date_type> end_rule_functor;
- static day_of_week_type start_day(year_type) {return Sunday;}
- static month_type start_month(year_type) {return Mar;}
- static day_of_week_type end_day(year_type) {return Sunday;}
- static month_type end_month(year_type) {return Oct;}
- static int dst_start_offset_minutes() { return 120;}
- static int dst_end_offset_minutes() { return 180; }
- static int dst_shift_length_minutes() { return 60; }
- static date_type local_dst_start_day(year_type year)
- {
- start_rule_functor start(start_day(year),
- start_month(year));
- return start.get_date(year);
- }
- static date_type local_dst_end_day(year_type year)
- {
- end_rule_functor end(end_day(year),
- end_month(year));
- return end.get_date(year);
- }
- };
-
-
- template<class date_type>
- struct uk_dst_trait : public eu_dst_trait<date_type>
- {
- static int dst_start_offset_minutes() { return 60;}
- static int dst_end_offset_minutes() { return 120; }
- static int dst_shift_length_minutes() { return 60; }
- };
-
- template<class date_type>
- struct acst_dst_trait
- {
- typedef typename date_type::day_of_week_type day_of_week_type;
- typedef typename date_type::month_type month_type;
- typedef typename date_type::year_type year_type;
- typedef date_time::last_kday_of_month<date_type> start_rule_functor;
- typedef date_time::last_kday_of_month<date_type> end_rule_functor;
- static day_of_week_type start_day(year_type) {return Sunday;}
- static month_type start_month(year_type) {return Oct;}
- static day_of_week_type end_day(year_type) {return Sunday;}
- static month_type end_month(year_type) {return Mar;}
- static int dst_start_offset_minutes() { return 120;}
- static int dst_end_offset_minutes() { return 180; }
- static int dst_shift_length_minutes() { return 60; }
- static date_type local_dst_start_day(year_type year)
- {
- start_rule_functor start(start_day(year),
- start_month(year));
- return start.get_date(year);
- }
- static date_type local_dst_end_day(year_type year)
- {
- end_rule_functor end(end_day(year),
- end_month(year));
- return end.get_date(year);
- }
- };
-
-
- } }
- #endif
|