// debugger helper: shows what the date really is
#ifdef __WXDEBUG__
-extern const wxChar *wxDumpDate(const wxDateTime* dt)
+extern const char *wxDumpDate(const wxDateTime* dt)
{
- static wxChar buf[128];
+ static char buf[128];
- wxStrcpy(buf, dt->Format(_T("%Y-%m-%d (%a) %H:%M:%S")));
+ wxString fmt(dt->Format("%Y-%m-%d (%a) %H:%M:%S"));
+ wxStrlcpy(buf,
+ (fmt + " (" + dt->GetValue().ToString() + " ticks)").ToAscii(),
+ WXSIZEOF(buf));
return buf;
}
if ( !wxStrftime(buf, WXSIZEOF(buf), format, tm) )
{
- // buffer is too small?
+ // if the format is valid, buffer must be too small?
wxFAIL_MSG(_T("strftime() failed"));
+
+ buf[0] = '\0';
}
s = buf;
min = (wxDateTime_t)(min + *p++ - _T('0'));
wxDateTime_t sec = 0;
- if ( *p++ == _T(':') )
+ if ( *p == _T(':') )
{
+ p++;
if ( !wxIsdigit(*p) )
{
return NULL;
Tm tm = tmDef;
// set the date
+ if ( haveMon )
+ {
+ tm.mon = mon;
+ }
+
if ( haveYear )
{
tm.year = year;
// TODO we don't check here that the values are consistent, if both year
// day and month/day were found, we just ignore the year day and we
// also always ignore the week day
- if ( haveMon && haveDay )
+ if ( haveDay )
{
- if ( mday > GetNumOfDaysInMonth(tm.year, mon) )
+ if ( mday > GetNumOfDaysInMonth(tm.year, tm.mon) )
{
wxLogDebug(_T("bad month day in wxDateTime::ParseFormat"));
return NULL;
}
- tm.mon = mon;
tm.mday = mday;
}
else if ( haveYDay )
wxDateTime& wxDateTime::SetFromMSWSysTime(const SYSTEMTIME& st)
{
return Set(st.wDay,
- wx_static_cast(wxDateTime::Month, wxDateTime::Jan + st.wMonth - 1),
+ static_cast<wxDateTime::Month>(wxDateTime::Jan + st.wMonth - 1),
st.wYear,
0, 0, 0);
}