// ----------------------------------------------------------------------------
// debugging helper: just a convenient replacement of wxCHECK()
-#define wxDATETIME_CHECK(expr, msg) \
- if ( !(expr) ) \
- { \
- wxFAIL_MSG(msg); \
- *this = wxInvalidDateTime; \
- return *this; \
- }
+#define wxDATETIME_CHECK(expr, msg) \
+ wxCHECK2_MSG(expr, *this = wxInvalidDateTime; return *this, msg)
// ----------------------------------------------------------------------------
// private classes
return dt;
}
+#if WXWIN_COMPATIBILITY_2_6
// use a separate function to avoid warnings about using deprecated
// SetToTheWeek in GetWeek below
static wxDateTime
{
return ::SetToTheWeek(GetYear(), numWeek, weekday, flags);
}
+#endif // WXWIN_COMPATIBILITY_2_6
wxDateTime& wxDateTime::SetToLastMonthDay(Month month,
int year)
}
else // may be either day or year
{
+ // use a leap year if we don't have the year yet to allow
+ // dates like 2/29/1976 which would be rejected otherwise
wxDateTime_t max_days = (wxDateTime_t)(
haveMon
- ? GetNumOfDaysInMonth(haveYear ? year : Inv_Year, mon)
+ ? GetNumOfDaysInMonth(haveYear ? year : 1976, mon)
: 31
);
{
wxLogDebug(_T("ParseDate: no day, no weekday hence no date."));
- return (wxChar *)NULL;
+ return NULL;
}
if ( haveWDay && (haveMon || haveYear || haveDay) &&
// without adjectives (which we don't support here) the week day only
// makes sense completely separately or with the full date
// specification (what would "Wed 1999" mean?)
- return (wxChar *)NULL;
+ return NULL;
}
if ( !haveWDay && haveYear && !(haveDay && haveMon) )
// if we give the year, month and day must be given too
wxLogDebug(_T("ParseDate: day and month should be specified if year is."));
- return (wxChar *)NULL;
+ return NULL;
}
}
if ( haveDay )
{
+ // normally we check the day above but the check is optimistic in case
+ // we find the day before its month/year so we have to redo it now
+ if ( day > GetNumOfDaysInMonth(year, mon) )
+ return NULL;
+
Set(day, mon, year);
if ( haveWDay )