#if wxUSE_DATETIME
-#ifndef __WXWINCE__
-#include <time.h>
-#else
-#include "wx/msw/wince/time.h"
-#endif
+#ifdef __WXWINCE__
+ #include "wx/msw/wince/time.h"
+#elif !defined(__WXPALMOS5__)
+ #include <time.h>
+#endif // OS
#include <limits.h> // for INT_MIN
}
const char *ParseFormat(const char *date,
- const wxString& format = wxDefaultDateTimeFormat,
+ const wxString& format = "%c",
const wxDateTime& dateDef = wxDefaultDateTime)
{
return ParseFormat(wxString(date), format, dateDef);
}
+ const char *ParseFormat(const char *date,
+ const char *format = wxDefaultDateTimeFormat,
+ const wxDateTime& dateDef = wxDefaultDateTime)
+ {
+ return ParseFormat(wxString(date), wxString(format), dateDef);
+ }
+
+ // parse a string containing date, time or both in ISO 8601 format
+ //
+ // notice that these functions are new in wx 3.0 and so we don't
+ // provide compatibility overloads for them
+ bool ParseISODate(const wxString& date)
+ {
+ wxString::const_iterator end;
+ return ParseFormat(date, wxS("%Y-%m-%d"), &end) && end == date.end();
+ }
+
+ bool ParseISOTime(const wxString& time)
+ {
+ wxString::const_iterator end;
+ return ParseFormat(time, wxS("%H:%M:%S"), &end) && end == time.end();
+ }
+
+ bool ParseISOCombined(const wxString& datetime, char sep = 'T')
+ {
+ wxString::const_iterator end;
+ const wxString fmt = wxS("%Y-%m-%d") + wxString(sep) + wxS("%H:%M:%S");
+ return ParseFormat(datetime, fmt, &end) && end == datetime.end();
+ }
+
// parse a string containing the date/time in "free" format, this
// function will try to make an educated guess at the string contents
const char *ParseDateTime(const wxString& datetime,
wxString Format(const wxString& format = wxDefaultDateTimeFormat,
const TimeZone& tz = Local) const;
// preferred date representation for the current locale
- wxString FormatDate() const { return Format(_T("%x")); }
+ wxString FormatDate() const { return Format(wxS("%x")); }
// preferred time representation for the current locale
- wxString FormatTime() const { return Format(_T("%X")); }
+ wxString FormatTime() const { return Format(wxS("%X")); }
// returns the string representing the date in ISO 8601 format
// (YYYY-MM-DD)
- wxString FormatISODate() const { return Format(_T("%Y-%m-%d")); }
+ wxString FormatISODate() const { return Format(wxS("%Y-%m-%d")); }
// returns the string representing the time in ISO 8601 format
// (HH:MM:SS)
- wxString FormatISOTime() const { return Format(_T("%H:%M:%S")); }
+ wxString FormatISOTime() const { return Format(wxS("%H:%M:%S")); }
+ // return the combined date time representation in ISO 8601 format; the
+ // separator character should be 'T' according to the standard but it
+ // can also be useful to set it to ' '
+ wxString FormatISOCombined(char sep = 'T') const
+ { return FormatISODate() + sep + FormatISOTime(); }
// implementation
// ------------------------------------------------------------------------