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) )
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
+ {
+ 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
{
- // weirder and weirder...
- wxFAIL_MSG( _T("no last Sunday in 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);
}
haveYear = false,
haveHour = false,
haveMin = false,
- haveSec = false;
+ haveSec = false,
+ haveMsec = false;
bool hourIsIn12hFormat = false, // or in 24h one?
isPM = false; // AM by default
// and the value of the items we have (init them to get rid of warnings)
- wxDateTime_t sec = 0,
+ wxDateTime_t msec = 0,
+ sec = 0,
min = 0,
hour = 0;
WeekDay wday = Inv_WeekDay;
yday = (wxDateTime_t)num;
break;
+ case _T('l'): // milliseconds (0-999)
+ if ( !GetNumericToken(width, input, &num) )
+ return NULL;
+
+ haveMsec = true;
+ msec = (wxDateTime_t)num;
+ break;
+
case _T('m'): // month as a number (01-12)
if ( !GetNumericToken(width, input, &num) || !num || (num > 12) )
{
tm.sec = sec;
}
+ if ( haveMsec )
+ tm.msec = msec;
+
Set(tm);
// finally check that the week day is consistent -- if we had it