X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3371873669823e49ac8b01e67711e453252eaa23..5c80fea840f43976c0903a0dd6f87f046d09d555:/include/wx/datetime.h?ds=sidebyside diff --git a/include/wx/datetime.h b/include/wx/datetime.h index b990cfb508..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 @@ -1108,11 +1108,11 @@ public: return date + (end - datestr.begin()); } - const wchar_t *ParseFormat(const wchar_t *date, - const wchar_t *format = wxDefaultDateTimeFormat, - const wxDateTime& dateDef = wxDefaultDateTime) + const char *ParseFormat(const char *date, + const wxString& format = "%c", + const wxDateTime& dateDef = wxDefaultDateTime) { - return ParseFormat(date, wxString(format), dateDef); + return ParseFormat(wxString(date), format, dateDef); } const char *ParseFormat(const char *date, @@ -1122,6 +1122,29 @@ public: 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, @@ -1191,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 // ------------------------------------------------------------------------