--- boost_1_33_1-prepatch/boost/date_time/dst_rules.hpp 2007-01-12 17:16:50.000000000 +0000 +++ boost_1_33_1/boost/date_time/dst_rules.hpp 2007-01-15 18:23:31.000000000 +0000 @@ -284,6 +284,7 @@ typedef typename date_type::calendar_type calendar_type; typedef date_time::last_kday_of_month lkday; typedef date_time::first_kday_of_month fkday; + typedef date_time::nth_kday_of_month nkday; typedef dst_calculator dstcalc; //! Calculates if the given local time is dst or not @@ -315,16 +316,28 @@ static date_type local_dst_start_day(year_type year) { - //first sunday in april - fkday fsia(Sunday, gregorian::Apr); - return fsia.get_date(year); + if (year >= year_type(dst_changeover_year)) { + //second sunday in march + nkday ssim(nkday::second, Sunday, gregorian::Mar); + return ssim.get_date(year); + } else { + //first sunday in april + fkday fsia(Sunday, gregorian::Apr); + return fsia.get_date(year); + } } static date_type local_dst_end_day(year_type year) { - //last sunday in october - lkday lsio(Sunday, gregorian::Oct); - return lsio.get_date(year); + if (year >= year_type(dst_changeover_year)) { + //first sunday in november + fkday fsin(Sunday, gregorian::Nov); + return fsin.get_date(year); + } else { + //last sunday in october + lkday lsio(Sunday, gregorian::Oct); + return lsio.get_date(year); + } } static time_duration_type dst_offset() @@ -332,6 +345,15 @@ return time_duration_type(0,dst_length_minutes,0); } + private: + + /** + * The year when US DST rules changed + * (http://en.wikipedia.org/wiki/Energy_Policy_Act_of_2005#Change_to_daylight_saving_time). + * This will have to be extended to a set of years if it the + * rules change again. + */ + static const int dst_changeover_year = 2007; };