// wxInvalidDateTime)
class WXDLLIMPEXP_BASE wxDateTime;
+extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxDefaultDateTimeFormat;
+extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxDefaultTimeSpanFormat;
extern WXDLLIMPEXP_DATA_BASE(const wxDateTime) wxDefaultDateTime;
+
#define wxInvalidDateTime wxDefaultDateTime
// ----------------------------------------------------------------------------
// sets the date to the given day of the given week in the year,
// returns true on success and false if given date doesn't exist (e.g.
// numWeek is > 53)
- bool SetToTheWeek(wxDateTime_t numWeek,
- WeekDay weekday = Mon,
- WeekFlags flags = Monday_First);
- inline wxDateTime GetWeek(wxDateTime_t numWeek,
- WeekDay weekday = Mon,
- WeekFlags flags = Monday_First) const;
+ //
+ // these functions are badly defined as they're not the reverse of
+ // GetWeekOfYear(), use SetToTheWeekOfYear() instead
+ wxDEPRECATED( bool SetToTheWeek(wxDateTime_t numWeek,
+ WeekDay weekday = Mon,
+ WeekFlags flags = Monday_First) );
+ wxDEPRECATED( wxDateTime GetWeek(wxDateTime_t numWeek,
+ WeekDay weekday = Mon,
+ WeekFlags flags = Monday_First) const );
+
+ // returns the date corresponding to the given week day of the given
+ // week (in ISO notation) of the specified year
+ static wxDateTime SetToWeekOfYear(int year,
+ wxDateTime_t numWeek,
+ WeekDay weekday = Mon);
// sets the date to the last day of the given (or current) month or the
// given (or current) year
// default, they will not change if they had valid values or will
// default to Today() otherwise)
const wxChar *ParseFormat(const wxChar *date,
- const wxChar *format = _T("%c"),
+ const wxChar *format = wxDefaultDateTimeFormat,
const wxDateTime& dateDef = wxDefaultDateTime);
// parse a string containing the date/time in "free" format, this
// function will try to make an educated guess at the string contents
// argument corresponds to the preferred date and time representation
// for the current locale) and returns the string containing the
// resulting text representation
- wxString Format(const wxChar *format = _T("%c"),
+ wxString Format(const wxChar *format = wxDefaultDateTimeFormat,
const TimeZone& tz = Local) const;
// preferred date representation for the current locale
wxString FormatDate() const { return Format(_T("%x")); }
// resulting text representation. Notice that only some of format
// specifiers valid for wxDateTime are valid for wxTimeSpan: hours,
// minutes and seconds make sense, but not "PM/AM" string for example.
- wxString Format(const wxChar *format = _T("%H:%M:%S")) const;
+ wxString Format(const wxChar *format = wxDefaultTimeSpanFormat) const;
// implementation
// ------------------------------------------------------------------------
return dt.SetToLastWeekDay(weekday, month, year) ? dt : wxInvalidDateTime;
}
-inline wxDateTime wxDateTime::GetWeek(wxDateTime_t numWeek,
- WeekDay weekday,
- WeekFlags flags) const
-{
- wxDateTime dt(*this);
-
- return dt.SetToTheWeek(numWeek, weekday, flags) ? dt : wxInvalidDateTime;
-}
-
inline wxDateTime wxDateTime::GetLastMonthDay(Month month, int year) const
{
MODIFY_AND_RETURN( SetToLastMonthDay(month, year) );