template<> void wxStringReadValue(const wxString &s , wxDateTime &data )
{
- data.ParseFormat(s,wxT("%Y-%m-%d %H:%M:%S")) ;
+ data.ParseFormat(s,"%Y-%m-%d %H:%M:%S", NULL);
}
template<> void wxStringWriteValue(wxString &s , const wxDateTime &data )
{
- s = data.Format(wxT("%Y-%m-%d %H:%M:%S")) ;
+ s = data.Format("%Y-%m-%d %H:%M:%S");
}
wxCUSTOM_TYPE_INFO(wxDateTime, wxToStringConverter<wxDateTime> , wxFromStringConverter<wxDateTime>)
-#endif
+#endif // wxUSE_EXTENDED_RTTI
//
// ----------------------------------------------------------------------------
#include <wtime.h>
#endif
-// define a special symbol for VC8 instead of writing tests for 1400 repeatedly
-#ifdef __VISUALC__
- #if __VISUALC__ >= 1400
- #define __VISUALC8__
- #endif
-#endif
-
#if !defined(WX_TIMEZONE) && !defined(WX_GMTOFF_IN_TM)
#if defined(__WXPALMOS__)
#define WX_GMTOFF_IN_TM
// 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"));
+ wxStrncpy(buf, fmt + " (" + dt->GetValue().ToString() + " ticks)",
+ 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;
// common cases
wxDateTime dt;
- const wxChar *result = dt.ParseFormat(input, _T("%T"));
+ const wxStringCharType *
+ result = dt.ParseFormat(input, wxS("%T"));
if ( !result )
{
- result = dt.ParseFormat(input, _T("%r"));
+ result = dt.ParseFormat(input, wxS("%r"));
}
if ( !result )
return NULL;
}
- haveHour = haveMin = haveSec = true;
+ haveHour =
+ haveMin =
+ haveSec = true;
Tm tm = dt.GetTm();
hour = tm.hour;
: (wxDateTime::WeekDay)(wd - 1);
}
+#ifdef __WXMSW__
+
+wxDateTime& wxDateTime::SetFromMSWSysTime(const SYSTEMTIME& st)
+{
+ return Set(st.wDay,
+ wx_static_cast(wxDateTime::Month, wxDateTime::Jan + st.wMonth - 1),
+ st.wYear,
+ 0, 0, 0);
+}
+
+void wxDateTime::GetAsMSWSysTime(SYSTEMTIME* st) const
+{
+ const wxDateTime::Tm tm(GetTm());
+
+ st->wYear = (WXWORD)tm.year;
+ st->wMonth = (WXWORD)(tm.mon - wxDateTime::Jan + 1);
+ st->wDay = tm.mday;
+
+ st->wDayOfWeek =
+ st->wHour =
+ st->wMinute =
+ st->wSecond =
+ st->wMilliseconds = 0;
+}
+#endif // __WXMSW__
+
#endif // wxUSE_DATETIME