X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a3fc1c94555b24115eb234230b70783dec0c4036..5b88a837ba75928cd3835a6b97ae2bf5ad983a6e:/interface/wx/datetime.h diff --git a/interface/wx/datetime.h b/interface/wx/datetime.h index 78c7820205..e8eb26d46d 100644 --- a/interface/wx/datetime.h +++ b/interface/wx/datetime.h @@ -527,8 +527,7 @@ public: Returns the ordinal number of the week in the month (in 1-5 range). As GetWeekOfYear(), this function supports both conventions for the - week start. See the description of these @c WeekFlags in the - @ref datetime_constants section. + week start. */ wxDateTime_t GetWeekOfMonth(WeekFlags flags = Monday_First, const TimeZone& tz = Local) const; @@ -542,10 +541,9 @@ public: year. Accordingly, the week number will always be in 1-53 range (52 for non-leap years). - The function depends on the @ref datetime_constants "week start" - convention specified by the @a flags argument but its results for - @c Sunday_First are not well-defined as the ISO definition quoted above - applies to the weeks starting on Monday only. + The function depends on the week start convention specified by the @a flags + argument but its results for @c Sunday_First are not well-defined as the + ISO definition quoted above applies to the weeks starting on Monday only. */ wxDateTime_t GetWeekOfYear(WeekFlags flags = Monday_First, const TimeZone& tz = Local) const; @@ -804,49 +802,31 @@ public: /** This function is like ParseDateTime(), but it only allows the date to - be specified. It is thus less flexible then ParseDateTime(), but also - has less chances to misinterpret the user input. + be specified. - @return @NULL if the conversion failed, otherwise return the pointer - to the character which stopped the scan. + It is thus less flexible then ParseDateTime(), but also has less + chances to misinterpret the user input. - @see Format() - */ - const char* ParseDate(const wxString& date, - wxString::const_iterator* end = NULL); + See ParseFormat() for the description of function parameters and return + value. - /** - @overload - */ - const char* ParseDate(const char* date); - - /** - @overload + @see Format() */ - const wchar_t* ParseDate(const wchar_t* date); + bool ParseDate(const wxString& date, wxString::const_iterator *end); /** Parses the string @a datetime containing the date and time in free - format. This function tries as hard as it can to interpret the given - string as date and time. Unlike ParseRfc822Date(), it will accept - anything that may be accepted and will only reject strings which can - not be parsed in any way at all. + format. - @return @NULL if the conversion failed, otherwise return the pointer - to the character which stopped the scan. - */ - const char* ParseDateTime(const wxString& datetime, - wxString::const_iterator* end = NULL); + This function tries as hard as it can to interpret the given string as + date and time. Unlike ParseRfc822Date(), it will accept anything that + may be accepted and will only reject strings which can not be parsed in + any way at all. - /** - @overload + See ParseFormat() for the description of function parameters and return + value. */ - const char* ParseDateTime(const char* datetime); - - /** - @overload - */ - const wchar_t* ParseDateTime(const wchar_t* datetime); + bool ParseDateTime(const wxString& datetime, wxString::const_iterator *end); /** This function parses the string @a date according to the given @@ -867,29 +847,53 @@ public: @a dateDef. If it is not specified, Today() is used as the default date. - @return @NULL if the conversion failed, otherwise return the pointer - to the character which stopped the scan. + Example of using this function: + @code + wxDateTime dt; + wxString str = "..."; + wxString::const_iterator end; + if ( !dt.ParseFormat(str, "%Y-%m-%d", &end) ) + ... parsing failed ... + else if ( end == str.end() ) + ... entire string parsed ... + else + ... wxString(end, str.end()) left over ... + @endcode + + @param date + The string to be parsed. + @param format + strptime()-like format string. + @param dateDef + Used to fill in the date components not specified in the @a date + string. + @param end + Will be filled with the iterator pointing to the location where the + parsing stopped if the function returns @true. If the entire string + was consumed, it is set to @c date.end(). Notice that this argument + must be non-@NULL. + @return + @true if at least part of the string was parsed successfully, + @false otherwise. @see Format() */ - const char* ParseFormat(const wxString& date, - const wxString& format = wxDefaultDateTimeFormat, - const wxDateTime& dateDef = wxDefaultDateTime, - wxString::const_iterator* end = NULL); + bool ParseFormat(const wxString& date, + const wxString& format = wxDefaultDateTimeFormat, + const wxDateTime& dateDef = wxDefaultDateTime, + wxString::const_iterator *end); /** @overload */ - const char* ParseFormat(const char* date, - const wxString& format = wxDefaultDateTimeFormat, - const wxDateTime& dateDef = wxDefaultDateTime); + bool ParseFormat(const wxString& date, + const wxString& format = wxDefaultDateTimeFormat, + wxString::const_iterator *end); /** @overload */ - const wchar_t* ParseFormat(const wchar_t* date, - const wxString& format = wxDefaultDateTimeFormat, - const wxDateTime& dateDef = wxDefaultDateTime); + bool ParseFormat(const wxString& date, wxString::const_iterator *end); /** This function parses the string containing the date and time in ISO @@ -935,39 +939,20 @@ public: string which is not RFC 822 compliant. If you need to parse date formatted in more free ways, you should use ParseDateTime() or ParseDate() instead. - */ - const char* ParseRfc822Date(const wxString& date, - wxString::const_iterator* end = NULL); - /** - @overload - */ - const char* ParseRfc822Date(const char* date); - - /** - @overload + See ParseFormat() for the description of function parameters and return + value. */ - const wchar_t* ParseRfc822Date(const wchar_t* date); + bool ParseRfc822Date(const wxString& date, wxString::const_iterator *end); /** This functions is like ParseDateTime(), but only allows the time to be specified in the input string. - @return @NULL if the conversion failed, otherwise return the pointer - to the character which stopped the scan. + See ParseFormat() for the description of function parameters and return + value. */ - const char* ParseTime(const wxString& time, - wxString::const_iterator* end = NULL); - - /** - @overload - */ - const char* ParseTime(const char* time); - - /** - @overload - */ - const wchar_t* ParseTime(const wchar_t* time); + bool ParseTime(const wxString& time, wxString::const_iterator *end); //@} @@ -1283,8 +1268,53 @@ public: static int GetCurrentYear(Calendar cal = Gregorian); /** - Gets the full (default) or abbreviated (specify @c Name_Abbr name of - the given month. + Return the standard English name of the given month. + + This function always returns "January" or "Jan" for January, use + GetMonthName() to retrieve the name of the month in the users current + locale. + + @param month + One of wxDateTime::Jan, ..., wxDateTime::Dec values. + @param flags + Either Name_Full (default) or Name_Abbr. + + @see GetEnglishWeekDayName() + + @since 2.9.0 + */ + static wxString GetEnglishMonthName(Month month, + NameFlags flags = Name_Full); + + /** + Return the standard English name of the given week day. + + This function always returns "Monday" or "Mon" for Monday, use + GetWeekDayName() to retrieve the name of the month in the users current + locale. + + @param weekday + One of wxDateTime::Sun, ..., wxDateTime::Sat values. + @param flags + Either Name_Full (default) or Name_Abbr. + + @see GetEnglishMonthName() + + @since 2.9.0 + */ + static wxString GetEnglishWeekDayName(WeekDay weekday, + NameFlags flags = Name_Full); + + /** + Gets the full (default) or abbreviated name of the given month. + + This function returns the name in the current locale, use + GetEnglishMonthName() to get the untranslated name if necessary. + + @param month + One of wxDateTime::Jan, ..., wxDateTime::Dec values. + @param flags + Either Name_Full (default) or Name_Abbr. @see GetWeekDayName() */ @@ -1332,13 +1362,20 @@ public: static tm* GetTmNow(); /** - Gets the full (default) or abbreviated (specify @c Name_Abbr) name of - the given week day. + Gets the full (default) or abbreviated name of the given week day. + + This function returns the name in the current locale, use + GetEnglishWeekDayName() to get the untranslated name if necessary. + + @param weekday + One of wxDateTime::Sun, ..., wxDateTime::Sat values. + @param flags + Either Name_Full (default) or Name_Abbr. @see GetMonthName() */ static wxString GetWeekDayName(WeekDay weekday, - NameFlags flags = Name_Full); + NameFlags flags = Name_Full); /** Returns @true if DST was used in the given year (the current one by @@ -1382,9 +1419,6 @@ public: Sets the country to use by default. This setting influences the DST calculations, date formatting and other things. - The possible values for @a country parameter are enumerated in the - @ref datetime_constants section. - @see GetCountry() */ static void SetCountry(Country country);