X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/71ebd60b06f0c299b3f6ae3b11a8dcb4b0306493..9c97f8ea883afa5db14c37bea63f6d4c327b4596:/include/wx/datetime.h diff --git a/include/wx/datetime.h b/include/wx/datetime.h index 1c337df30a..7677de54ed 100644 --- a/include/wx/datetime.h +++ b/include/wx/datetime.h @@ -17,11 +17,11 @@ #if wxUSE_DATETIME -#ifndef __WXWINCE__ -#include -#else -#include "wx/msw/wince/time.h" -#endif +#ifdef __WXWINCE__ + #include "wx/msw/wince/time.h" +#elif !defined(__WXPALMOS5__) + #include +#endif // OS #include // for INT_MIN @@ -1109,12 +1109,42 @@ public: } 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, @@ -1184,15 +1214,20 @@ public: 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 // ------------------------------------------------------------------------