correct wxDateTime DST begin/end computations for years > 2006 in USA (closes #10425)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@58486 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -102,6 +102,7 @@ All:
|
||||
- Fix wxURL::GetInputStream() for URLs with special characters in credentials
|
||||
(Robert Wruck).
|
||||
- Fix wxURI::GetUser() for URIs without password.
|
||||
- Correct wxDateTime DST computation for 2006 and later (Christopher Barker).
|
||||
|
||||
All (GUI):
|
||||
|
||||
|
@@ -1239,6 +1239,17 @@ wxDateTime wxDateTime::GetBeginDST(int year, Country country)
|
||||
wxFAIL_MSG( _T("no first Sunday in April?") );
|
||||
}
|
||||
}
|
||||
else if ( year > 2006 )
|
||||
// Energy Policy Act of 2005, Pub. L. no. 109-58, 119 Stat 594 (2005).
|
||||
// Starting in 2007, daylight time begins in the United States on the
|
||||
// second Sunday in March and ends on the first Sunday in November
|
||||
{
|
||||
if ( !dt.SetToWeekDay(Sun, 2, Mar, year) )
|
||||
{
|
||||
// weird...
|
||||
wxFAIL_MSG( _T("no second Sunday in March?") );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !dt.SetToWeekDay(Sun, 1, Apr, year) )
|
||||
@@ -1318,21 +1329,36 @@ wxDateTime wxDateTime::GetEndDST(int year, Country country)
|
||||
dt.Set(30, Sep, year);
|
||||
break;
|
||||
|
||||
default:
|
||||
// DST ends at 2 a.m. on the last Sunday of October
|
||||
if ( !dt.SetToLastWeekDay(Sun, Oct, year) )
|
||||
default: // default for switch (year)
|
||||
if ( year > 2006 )
|
||||
// Energy Policy Act of 2005, Pub. L. no. 109-58, 119 Stat 594 (2005).
|
||||
// Starting in 2007, daylight time begins in the United States on the
|
||||
// second Sunday in March and ends on the first Sunday in November
|
||||
{
|
||||
// weirder and weirder...
|
||||
wxFAIL_MSG( _T("no last Sunday in October?") );
|
||||
if ( !dt.SetToWeekDay(Sun, 1, Nov, year) )
|
||||
{
|
||||
// weird...
|
||||
wxFAIL_MSG( _T("no first Sunday in November?") );
|
||||
}
|
||||
}
|
||||
else
|
||||
// pre-2007
|
||||
// DST ends at 2 a.m. on the last Sunday of October
|
||||
{
|
||||
if ( !dt.SetToLastWeekDay(Sun, Oct, year) )
|
||||
{
|
||||
// weirder and weirder...
|
||||
wxFAIL_MSG( _T("no last Sunday in October?") );
|
||||
}
|
||||
}
|
||||
|
||||
dt += wxTimeSpan::Hours(2);
|
||||
|
||||
// TODO what about timezone??
|
||||
// TODO: what about timezone??
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
default: // default for switch (country)
|
||||
// assume October 26th as the end of the DST - totally bogus too
|
||||
dt.Set(26, Oct, year);
|
||||
}
|
||||
|
Reference in New Issue
Block a user