STRUCT TEMPLAT(3)

NAME
boost::date_time::us_dst_trait - Specification for daylight savings start rules in US.

SYNOPSIS

// In header: <boost/date_time/local_timezone_defs.hpp>
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_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;
  // public static functions
  static day_of_week_type start_day(year_type);
  static month_type start_month(year_type);
  static day_of_week_type end_day(year_type);
  static month_type end_month(year_type);
  static date_type local_dst_start_day(year_type);
  static date_type local_dst_end_day(year_type);
  static int dst_start_offset_minutes();
  static int dst_end_offset_minutes();
  static int dst_shift_length_minutes();
};

DESCRIPTION

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.

  us_dst_trait public static functions

    1.

    static day_of_week_type start_day(year_type);

    2.

    static month_type start_month(year_type y);

    3.

    static day_of_week_type end_day(year_type);

    4.

    static month_type end_month(year_type y);

    5.

    static date_type local_dst_start_day(year_type year);

    6.

    static date_type local_dst_end_day(year_type year);

    7.

    static int dst_start_offset_minutes();

    8.

    static int dst_end_offset_minutes();

    9.

    static int dst_shift_length_minutes();