Home | Libraries | People | FAQ | More |
boost::date_time::us_dst_trait — Specification for daylight savings start rules in US.
template<typename date_type> struct us_dst_trait { // types typedef date_type::day_of_week_type day_of_week_type; typedef date_type::month_type month_type; typedef date_time::first_kday_of_month< date_type > start_rule_functor; typedef date_time::last_kday_of_month< date_type > end_rule_functor; // public static functions day_of_week_type start_day() ; month_type start_month() ; day_of_week_type end_day() ; month_type end_month() ; int dst_start_offset_minutes() ; int dst_end_offset_minutes() ; int dst_shift_length_minutes() ; };
This class is used to configure dst_calc_engine template typically as follows:
using namespace boost::gregorian; using namespace boost::posix_time; typedef us_dst_trait<date> us_dst_traits; typedef boost::date_time::dst_calc_engine<date, time_duration, us_dst_traits> us_dst_calc; //calculate the 2002 transition day of USA April 7 2002 date dst_start = us_dst_calc::local_dst_start_day(2002); //calculate the 2002 transition day of USA Oct 27 2002 date dst_end = us_dst_calc::local_dst_end_day(2002); //check if a local time is in dst or not -- posible answers //are yes, no, invalid time label, ambiguous ptime t(...some time...); if (us_dst::local_is_dst(t.date(), t.time_of_day()) == boost::date_time::is_not_in_dst) { }
This generates a type suitable for the calculation of dst transitions for the United States. Of course other templates can be used for other locales.
Copyright © 2001-2005 CrystalClear Software, Inc |