#include <wx/datetime.h>
The type wxDateTime_t is typedefed as unsigned short and is used to contain the number of years, hours, minutes, seconds and milliseconds.
All the following constants are defined inside wxDateTime class (i.e., to refer to them you should prepend their names with "wxDateTime::").
Time zone symbolic names:
enum TZ { // the time in the current time zone Local, // zones from GMT (= Greenwhich Mean Time): they're guaranteed to be // consequent numbers, so writing something like `GMT0 + offset' is // safe if abs(offset) <= 12 // underscore stands for minus GMT_12, GMT_11, GMT_10, GMT_9, GMT_8, GMT_7, GMT_6, GMT_5, GMT_4, GMT_3, GMT_2, GMT_1, GMT0, GMT1, GMT2, GMT3, GMT4, GMT5, GMT6, GMT7, GMT8, GMT9, GMT10, GMT11, GMT12, GMT13, // Note that GMT12 and GMT_12 are not the same: there is a difference // of exactly one day between them // some symbolic names for TZ // Europe WET = GMT0, // Western Europe Time WEST = GMT1, // Western Europe Summer Time CET = GMT1, // Central Europe Time CEST = GMT2, // Central Europe Summer Time EET = GMT2, // Eastern Europe Time EEST = GMT3, // Eastern Europe Summer Time MSK = GMT3, // Moscow Time MSD = GMT4, // Moscow Summer Time // US and Canada AST = GMT_4, // Atlantic Standard Time ADT = GMT_3, // Atlantic Daylight Time EST = GMT_5, // Eastern Standard Time EDT = GMT_4, // Eastern Daylight Saving Time CST = GMT_6, // Central Standard Time CDT = GMT_5, // Central Daylight Saving Time MST = GMT_7, // Mountain Standard Time MDT = GMT_6, // Mountain Daylight Saving Time PST = GMT_8, // Pacific Standard Time PDT = GMT_7, // Pacific Daylight Saving Time HST = GMT_10, // Hawaiian Standard Time AKST = GMT_9, // Alaska Standard Time AKDT = GMT_8, // Alaska Daylight Saving Time // Australia A_WST = GMT8, // Western Standard Time A_CST = GMT13 + 1, // Central Standard Time (+9.5) A_EST = GMT10, // Eastern Standard Time A_ESST = GMT11, // Eastern Summer Time // New Zealand NZST = GMT12, // Standard Time NZDT = GMT13, // Daylight Saving Time // Universal Coordinated Time = the new and politically correct name // for GMT UTC = GMT0 };
Month names: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec and Inv_Month for an invalid month are the values of wxDateTime::Month enum.
Likewise, Sun, Mon, Tue, Wed, Thu, Fri, Sat, and Inv_WeekDay are the values in wxDateTime::WeekDay enum.
Finally, Inv_Year is defined to be an invalid value for year parameter.
GetMonthName() and GetWeekDayName() functions use the following flags:
enum NameFlags { Name_Full = 0x01, // return full name Name_Abbr = 0x02 // return abbreviated name };
Several functions accept an extra parameter specifying the calendar to use (although most of them only support now the Gregorian calendar). This parameters is one of the following values:
enum Calendar { Gregorian, // calendar currently in use in Western countries Julian // calendar in use since -45 until the 1582 (or later) };
Date calculations often depend on the country and wxDateTime allows to set the country whose conventions should be used using SetCountry(). It takes one of the following values as parameter:
enum Country { Country_Unknown, // no special information for this country Country_Default, // set the default country with SetCountry() method // or use the default country with any other Country_WesternEurope_Start, Country_EEC = Country_WesternEurope_Start, France, Germany, UK, Country_WesternEurope_End = UK, Russia, USA };
Different parts of the world use different conventions for the week start. In some countries, the week starts on Sunday, while in others -- on Monday. The ISO standard doesn't address this issue, so we support both conventions in the functions whose result depends on it (GetWeekOfYear() and GetWeekOfMonth()).
The desired behvaiour may be specified by giving one of the following constants as argument to these functions:
enum WeekFlags { Default_First, // Sunday_First for US, Monday_First for the rest Monday_First, // week starts with a Monday Sunday_First // week starts with a Sunday };
Please note that although several function accept an extra Calendar parameter, it is currently ignored as only the Gregorian calendar is supported. Future versions will support other calendars.
wxPython Note: These methods are standalone functions named "wxDateTime_<StaticMethodName>" in wxPython.
The conversions from text are more interesting, as there are much more possibilities to care about. The simplest cases can be taken care of with ParseFormat() which can parse any date in the given (rigid) format. ParseRfc822Date() is another function for parsing dates in predefined format -- the one of RFC 822 which (still...) defines the format of email messages on the Internet. This format can not be described with strptime(3)-like format strings used by Format(), hence the need for a separate function.
But the most interesting functions are ParseTime(), ParseDate() and ParseDateTime(). They try to parse the date and time (or only one of them) in 'free' format, i.e. allow them to be specified in any of possible ways. These functions will usually be used to parse the (interactive) user input which is not bound to be in any predefined format. As an example, ParseDateTime() can parse the strings such as "tomorrow", "March first" and even "next Sunday".
Finally notice that each of the parsing functions is available in several overloads: if the input string is a narrow (char *) string, then a narrow pointer is returned. If the input string is a wide string, a wide char pointer is returned. Finally, if the input parameter is a wxString, a narrow char pointer is also returned for backwards compatibility but there is also an additional argument of wxString::const_iterator type in which, if it is not NULL, an iterator pointing to the end of the scanned string part is returned.
Predefined objects/pointers:
Public Member Functions | |
Constructors, Assignment Operators and Setters | |
| wxDateTime () | |
| wxDateTime & | wxDateTime (time_t timet) |
| wxDateTime & | wxDateTime (const struct tm &tm) |
| wxDateTime & | wxDateTime (double jdn) |
| wxDateTime & | wxDateTime (wxDateTime_t hour, wxDateTime_t minute=0, wxDateTime_t second=0, wxDateTime_t millisec=0) |
| wxDateTime (wxDateTime_t day, Month month=Inv_Month, int year=Inv_Year, wxDateTime_t hour=0, wxDateTime_t minute=0, wxDateTime_t second=0, wxDateTime_t millisec=0) | |
| wxDateTime (const struct _SYSTEMTIME &st) | |
| wxDateTime & | ResetTime () |
| wxDateTime & | Set (time_t timet) |
| wxDateTime & | Set (const struct tm &tm) |
| wxDateTime & | Set (double jdn) |
| wxDateTime & | Set (wxDateTime_t hour, wxDateTime_t minute=0, wxDateTime_t second=0, wxDateTime_t millisec=0) |
| wxDateTime & | Set (wxDateTime_t day, Month month=Inv_Month, int year=Inv_Year, wxDateTime_t hour=0, wxDateTime_t minute=0, wxDateTime_t second=0, wxDateTime_t millisec=0) |
| wxDateTime & | SetDay (short unsigned int) |
| wxDateTime & | SetFromDOS (unsigned long ddt) |
| wxDateTime & | SetHour (short unsigned int) |
| wxDateTime & | SetMillisecond (short unsigned int) |
| wxDateTime & | SetMinute (short unsigned int) |
| wxDateTime & | SetMonth (Month month) |
| wxDateTime & | SetSecond (short unsigned int) |
| wxDateTime & | SetToCurrent () |
| wxDateTime & | SetYear (int year) |
| wxDateTime & | operator= (time_t timet) |
| wxDateTime & | operator= (const struct tm &tm) |
Accessors | |
Here are the trivial accessors. Other functions, which might have to perform some more complicated calculations to find the answer are under the "Date Arithmetics" section. | |
| long unsigned int | GetAsDOS () const |
| wxDateTime & | SetFromMSWSysTime (const struct _SYSTEMTIME &st) |
| void | GetAsMSWSysTime (struct _SYSTEMTIME *st) const |
| int | GetCentury (const TimeZone &tz=Local) const |
| wxDateTime | GetDateOnly () const |
| short unsigned int | GetDay (const TimeZone &tz=Local) const |
| short unsigned int | GetDayOfYear (const TimeZone &tz=Local) const |
| short unsigned int | GetHour (const TimeZone &tz=Local) const |
| short unsigned int | GetMillisecond (const TimeZone &tz=Local) const |
| short unsigned int | GetMinute (const TimeZone &tz=Local) const |
| Month | GetMonth (const TimeZone &tz=Local) const |
| short unsigned int | GetSecond (const TimeZone &tz=Local) const |
| time_t | GetTicks () const |
| Tm | GetTm (const TimeZone &tz=Local) const |
| WeekDay | GetWeekDay (const TimeZone &tz=Local) const |
| wxDateTime_t | GetWeekOfMonth (WeekFlags flags=Monday_First, const TimeZone &tz=Local) const |
| wxDateTime_t | GetWeekOfYear (WeekFlags flags=Monday_First, const TimeZone &tz=Local) const |
| int | GetYear (const TimeZone &tz=Local) const |
| bool | IsGregorianDate (GregorianAdoption country=Gr_Standard) const |
| bool | IsValid () const |
| bool | IsWorkDay (Country country=Country_Default) const |
Date Comparison | |
There are several functions to allow date comparison. To supplement them, a few global operators, etc taking wxDateTime are defined. | |
| bool | IsEarlierThan (const wxDateTime &datetime) const |
| bool | IsEqualTo (const wxDateTime &datetime) const |
| bool | IsEqualUpTo (const wxDateTime &dt, const wxTimeSpan &ts) const |
| bool | IsLaterThan (const wxDateTime &datetime) const |
| bool | IsSameDate (const wxDateTime &dt) const |
| bool | IsSameTime (const wxDateTime &dt) const |
| bool | IsStrictlyBetween (const wxDateTime &t1, const wxDateTime &t2) const |
| bool | IsBetween (const wxDateTime &t1, const wxDateTime &t2) const |
Date Arithmetics | |
These functions carry out arithmetics on the wxDateTime objects. As explained in the overview, either wxTimeSpan or wxDateSpan may be added to wxDateTime, hence all functions are overloaded to accept both arguments.
Also, both Add() and Subtract() have both const and non-const version. The first one returns a new object which represents the sum/difference of the original one with the argument while the second form modifies the object to which it is applied. The operators "-=" and "+=" are defined to be equivalent to the second forms of these functions. | |
| wxDateTime | Add (const wxDateSpan &diff) const |
| wxDateTime | Add (const wxDateSpan &diff) |
| wxDateTime | Add (const wxTimeSpan &diff) const |
| wxDateTime & | Add (const wxTimeSpan &diff) |
| wxDateTime | Subtract (const wxTimeSpan &diff) const |
| wxDateTime & | Subtract (const wxTimeSpan &diff) |
| wxDateTime | Subtract (const wxDateSpan &diff) const |
| wxDateTime & | Subtract (const wxDateSpan &diff) |
| wxTimeSpan | Subtract (const wxDateTime &dt) const |
| wxDateTime | operator+= (const wxDateSpan &diff) |
| wxDateTime & | operator-= (const wxDateSpan &diff) |
| wxDateTime & | operator+= (const wxTimeSpan &diff) |
| wxDateTime & | operator-= (const wxTimeSpan &diff) |
Date Formatting and Parsing | |
| wxString | Format (const wxChar *format=wxDefaultDateTimeFormat, const TimeZone &tz=Local) const |
| wxString | FormatDate () const |
| wxString | FormatISOCombined (char sep= 'T') const |
| wxString | FormatISODate () const |
| wxString | FormatISOTime () const |
| wxString | FormatTime () const |
| const char * | ParseDate (const wxString &date, wxString::const_iterator *end=NULL) |
| const char * | ParseDate (const char *date) |
| const wchar_t * | ParseDate (const wchar_t *date) |
| const char * | ParseDateTime (const wxString &datetime, wxString::const_iterator *end=NULL) |
| const char * | ParseDateTime (const char *datetime) |
| const wchar_t * | ParseDateTime (const wchar_t *datetime) |
| const char * | ParseFormat (const wxString &date, const wxString &format=wxDefaultDateTimeFormat, const wxDateTime &dateDef=wxDefaultDateTime, wxString::const_iterator *end=NULL) |
| const char * | ParseFormat (const char *date, const wxString &format=wxDefaultDateTimeFormat, const wxDateTime &dateDef=wxDefaultDateTime) |
| const wchar_t * | ParseFormat (const wchar_t *date, const wxString &format=wxDefaultDateTimeFormat, const wxDateTime &dateDef=wxDefaultDateTime) |
| bool | ParseISOCombined (const wxString &date, char sep= 'T') |
| bool | ParseISODate (const wxString &date) |
| bool | ParseISOTime (const wxString &date) |
| const char * | ParseRfc822Date (const wxString &date, wxString::const_iterator *end=NULL) |
| const char * | ParseRfc822Date (const char *date) |
| const wchar_t * | ParseRfc822Date (const wchar_t *date) |
| const char * | ParseTime (const wxString &time, wxString::const_iterator *end=NULL) |
| const char * | ParseTime (const char *time) |
| const wchar_t * | ParseTime (const wchar_t *time) |
Calendar Calculations | |
The functions in this section perform the basic calendar calculations, mostly related to the week days. They allow to find the given week day in the week with given number (either in the month or in the year) and so on.
None of the functions in this section modify the time part of the wxDateTime, they only work with the date part of it. | |
| wxDateTime | GetLastMonthDay (Month month=Inv_Month, int year=Inv_Year) const |
| wxDateTime | GetLastWeekDay (WeekDay weekday, Month month=Inv_Month, int year=Inv_Year) |
| wxDateTime | GetNextWeekDay (WeekDay weekday) const |
| wxDateTime | GetPrevWeekDay (WeekDay weekday) const |
| wxDateTime | GetWeekDay (WeekDay weekday, int n=1, Month month=Inv_Month, int year=Inv_Year) const |
| wxDateTime | GetWeekDayInSameWeek (WeekDay weekday, WeekFlags flags=Monday_First) const |
| wxDateTime | GetYearDay (wxDateTime_t yday) const |
| wxDateTime | SetToLastMonthDay (Month month=Inv_Month, int year=Inv_Year) |
| bool | SetToLastWeekDay (WeekDay weekday, Month month=Inv_Month, int year=Inv_Year) |
| wxDateTime & | SetToNextWeekDay (WeekDay weekday) |
| wxDateTime & | SetToPrevWeekDay (WeekDay weekday) |
| bool | SetToWeekDay (WeekDay weekday, int n=1, Month month=Inv_Month, int year=Inv_Year) |
| wxDateTime | SetToWeekDayInSameWeek (WeekDay weekday, WeekFlags flags=Monday_First) |
| wxDateTime & | SetToYearDay (wxDateTime_t yday) |
Astronomical/Historical Functions | |
Some degree of support for the date units used in astronomy and/or history is provided. You can construct a wxDateTime object from a JDN and you may also get its JDN, MJD or Rata Die number from it.
Related functions in other groups: wxDateTime(double), Set(double) | |
| double | GetJDN () const |
| double | GetJulianDayNumber () const |
| double | GetMJD () const |
| double | GetModifiedJulianDayNumber () const |
| double | GetRataDie () const |
Time Zone and DST Support | |
Please see the time zone overview for more information about time zones. Normally, these functions should be rarely used.
Related functions in other groups: GetBeginDST(), GetEndDST() | |
| wxDateTime | FromTimezone (const TimeZone &tz, bool noDST=false) const |
| int | IsDST (Country country=Country_Default) const |
| wxDateTime | MakeFromTimezone (const TimeZone &tz, bool noDST=false) |
| wxDateTime | MakeTimezone (const TimeZone &tz, bool noDST=false) |
| wxDateTime & | MakeUTC (bool noDST=false) |
| wxDateTime | ToTimezone (const TimeZone &tz, bool noDST=false) const |
| wxDateTime | ToUTC (bool noDST=false) const |
Static Public Member Functions | |
| static int | ConvertYearToBC (int year) |
| static void | GetAmPmStrings (wxString *am, wxString *pm) |
| static wxDateTime | GetBeginDST (int year=Inv_Year, Country country=Country_Default) |
| static wxDateTime | GetEndDST (int year=Inv_Year, Country country=Country_Default) |
| static int | GetCentury (int year) |
| static Country | GetCountry () |
| static Month | GetCurrentMonth (Calendar cal=Gregorian) |
| static int | GetCurrentYear (Calendar cal=Gregorian) |
| static wxString | GetMonthName (Month month, NameFlags flags=Name_Full) |
| static wxDateTime_t | GetNumberOfDays (int year, Calendar cal=Gregorian) |
| static wxDateTime_t | GetNumberOfDays (Month month, int year=Inv_Year, Calendar cal=Gregorian) |
| static time_t | GetTimeNow () |
| static struct tm * | GetTmNow (struct tm *tm) |
| static struct tm * | GetTmNow () |
| static wxString | GetWeekDayName (WeekDay weekday, NameFlags flags=Name_Full) |
| static bool | IsDSTApplicable (int year=Inv_Year, Country country=Country_Default) |
| static bool | IsLeapYear (int year=Inv_Year, Calendar cal=Gregorian) |
| static bool | IsWestEuropeanCountry (Country country=Country_Default) |
| static wxDateTime | Now () |
| static void | SetCountry (Country country) |
| static wxDateTime | SetToWeekOfYear (int year, wxDateTime_t numWeek, WeekDay weekday=Mon) |
| static wxDateTime | Today () |
| static wxDateTime | UNow () |
| wxDateTime::wxDateTime | ( | ) |
Default constructor. Use one of the Set() functions to initialize the object later.
| wxDateTime& wxDateTime::wxDateTime | ( | time_t | timet | ) |
Same as Set().
wxPython Note: This constructor is named "wxDateTimeFromTimeT" in wxPython.
| wxDateTime& wxDateTime::wxDateTime | ( | const struct tm & | tm | ) |
Same as Set().
wxPython Note: Unsupported.
| wxDateTime& wxDateTime::wxDateTime | ( | double | jdn | ) |
Same as Set().
wxPython Note: This constructor is named "wxDateTimeFromJDN" in wxPython.
| wxDateTime& wxDateTime::wxDateTime | ( | wxDateTime_t | hour, | |
| wxDateTime_t | minute = 0, |
|||
| wxDateTime_t | second = 0, |
|||
| wxDateTime_t | millisec = 0 | |||
| ) |
Same as Set().
wxPython Note: This constructor is named "wxDateTimeFromHMS" in wxPython.
| wxDateTime::wxDateTime | ( | wxDateTime_t | day, | |
| Month | month = Inv_Month, |
|||
| int | year = Inv_Year, |
|||
| wxDateTime_t | hour = 0, |
|||
| wxDateTime_t | minute = 0, |
|||
| wxDateTime_t | second = 0, |
|||
| wxDateTime_t | millisec = 0 | |||
| ) |
Same as Set().
wxPython Note: This constructor is named "wxDateTimeFromDMY" in wxPython.
| wxDateTime::wxDateTime | ( | const struct _SYSTEMTIME & | st | ) |
Same as SetFromMSWSysTime.
| st | Input, Windows SYSTEMTIME reference |
| wxDateTime& wxDateTime::ResetTime | ( | ) |
Reset time to midnight (00:00:00) without changing the date.
| wxDateTime& wxDateTime::Set | ( | time_t | timet | ) |
Constructs the object from timet value holding the number of seconds since Jan 1, 1970.
wxPython Note: This method is named "SetTimeT" in wxPython.
| wxDateTime& wxDateTime::Set | ( | const struct tm & | tm | ) |
Sets the date and time from the broken down representation in the standard tm structure.
wxPython Note: Unsupported.
| wxDateTime& wxDateTime::Set | ( | double | jdn | ) |
Sets the date from the so-called Julian Day Number.
By definition, the Julian Day Number, usually abbreviated as JDN, of a particular instant is the fractional number of days since 12 hours Universal Coordinated Time (Greenwich mean noon) on January 1 of the year -4712 in the Julian proleptic calendar.
wxPython Note: This method is named "SetJDN" in wxPython.
| wxDateTime& wxDateTime::Set | ( | wxDateTime_t | hour, | |
| wxDateTime_t | minute = 0, |
|||
| wxDateTime_t | second = 0, |
|||
| wxDateTime_t | millisec = 0 | |||
| ) |
Sets the date to be equal to Today() and the time from supplied parameters.
wxPython Note: This method is named "SetHMS" in wxPython.
| wxDateTime& wxDateTime::Set | ( | wxDateTime_t | day, | |
| Month | month = Inv_Month, |
|||
| int | year = Inv_Year, |
|||
| wxDateTime_t | hour = 0, |
|||
| wxDateTime_t | minute = 0, |
|||
| wxDateTime_t | second = 0, |
|||
| wxDateTime_t | millisec = 0 | |||
| ) |
Sets the date and time from the parameters.
| wxDateTime& wxDateTime::SetDay | ( | short unsigned | int | ) |
Sets the day without changing other date components.
| wxDateTime& wxDateTime::SetFromDOS | ( | unsigned long | ddt | ) |
Sets the date from the date and time in DOS format.
| wxDateTime& wxDateTime::SetHour | ( | short unsigned | int | ) |
Sets the hour without changing other date components.
| wxDateTime& wxDateTime::SetMillisecond | ( | short unsigned | int | ) |
Sets the millisecond without changing other date components.
| wxDateTime& wxDateTime::SetMinute | ( | short unsigned | int | ) |
Sets the minute without changing other date components.
| wxDateTime& wxDateTime::SetMonth | ( | Month | month | ) |
Sets the month without changing other date components.
| wxDateTime& wxDateTime::SetSecond | ( | short unsigned | int | ) |
Sets the second without changing other date components.
| wxDateTime& wxDateTime::SetToCurrent | ( | ) |
Sets the date and time of to the current values. Same as assigning the result of Now() to this object.
| wxDateTime& wxDateTime::SetYear | ( | int | year | ) |
Sets the year without changing other date components.
| wxDateTime& wxDateTime::operator= | ( | time_t | timet | ) |
Same as Set().
| wxDateTime& wxDateTime::operator= | ( | const struct tm & | tm | ) |
Same as Set().
| long unsigned int wxDateTime::GetAsDOS | ( | ) | const |
Returns the date and time in DOS format.
| wxDateTime& wxDateTime::SetFromMSWSysTime | ( | const struct _SYSTEMTIME & | st | ) |
Initialize using the Windows SYSTEMTIME structure.
| st | Input, Windows SYSTEMTIME reference |
| void wxDateTime::GetAsMSWSysTime | ( | struct _SYSTEMTIME * | st | ) | const |
Returns the date and time in the Windows SYSTEMTIME format.
| st | Output, pointer to Windows SYSTEMTIME |
| int wxDateTime::GetCentury | ( | const TimeZone & | tz = Local |
) | const |
Returns the century of this date.
| wxDateTime wxDateTime::GetDateOnly | ( | ) | const |
Returns the object having the same date component as this one but time of 00:00:00.
| short unsigned int wxDateTime::GetDay | ( | const TimeZone & | tz = Local |
) | const |
Returns the day in the given timezone (local one by default).
| short unsigned int wxDateTime::GetDayOfYear | ( | const TimeZone & | tz = Local |
) | const |
Returns the day of the year (in 1-366 range) in the given timezone (local one by default).
| short unsigned int wxDateTime::GetHour | ( | const TimeZone & | tz = Local |
) | const |
Returns the hour in the given timezone (local one by default).
| short unsigned int wxDateTime::GetMillisecond | ( | const TimeZone & | tz = Local |
) | const |
Returns the milliseconds in the given timezone (local one by default).
| short unsigned int wxDateTime::GetMinute | ( | const TimeZone & | tz = Local |
) | const |
Returns the minute in the given timezone (local one by default).
| Month wxDateTime::GetMonth | ( | const TimeZone & | tz = Local |
) | const |
Returns the month in the given timezone (local one by default).
| short unsigned int wxDateTime::GetSecond | ( | const TimeZone & | tz = Local |
) | const |
Returns the seconds in the given timezone (local one by default).
| time_t wxDateTime::GetTicks | ( | ) | const |
Returns the number of seconds since Jan 1, 1970. An assert failure will occur if the date is not in the range covered by time_t type.
| Tm wxDateTime::GetTm | ( | const TimeZone & | tz = Local |
) | const |
Returns broken down representation of the date and time.
| WeekDay wxDateTime::GetWeekDay | ( | const TimeZone & | tz = Local |
) | const |
Returns the week day in the given timezone (local one by default).
| wxDateTime_t wxDateTime::GetWeekOfMonth | ( | WeekFlags | flags = Monday_First, |
|
| const TimeZone & | tz = Local | |||
| ) | const |
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 WeekFlags in the Constants section.
| wxDateTime_t wxDateTime::GetWeekOfYear | ( | WeekFlags | flags = Monday_First, |
|
| const TimeZone & | tz = Local | |||
| ) | const |
Returns the number of the week of the year this date is in. The first week of the year is, according to international standards, the one containing Jan 4 or, equivalently, the first week which has Thursday in this year. Both of these definitions are the same as saying that the first week of the year must contain more than half of its days in this year. Accordingly, the week number will always be in 1-53 range (52 for non-leap years).
The function depends on the week start convention specified by the flags argument but its results for Sunday_First are not well-defined as the ISO definition quoted above applies to the weeks starting on Monday only.
| int wxDateTime::GetYear | ( | const TimeZone & | tz = Local |
) | const |
Returns the year in the given timezone (local one by default).
| bool wxDateTime::IsGregorianDate | ( | GregorianAdoption | country = Gr_Standard |
) | const |
Returns true if the given date is later than the date of adoption of the Gregorian calendar in the given country (and hence the Gregorian calendar calculations make sense for it).
| bool wxDateTime::IsValid | ( | ) | const |
Returns true if the object represents a valid time moment.
| bool wxDateTime::IsWorkDay | ( | Country | country = Country_Default |
) | const |
Returns true is this day is not a holiday in the given country.
| bool wxDateTime::IsEarlierThan | ( | const wxDateTime & | datetime | ) | const |
Returns true if this date precedes the given one.
| bool wxDateTime::IsEqualTo | ( | const wxDateTime & | datetime | ) | const |
Returns true if the two dates are strictly identical.
| bool wxDateTime::IsEqualUpTo | ( | const wxDateTime & | dt, | |
| const wxTimeSpan & | ts | |||
| ) | const |
Returns true if the date is equal to another one up to the given time interval, i.e. if the absolute difference between the two dates is less than this interval.
| bool wxDateTime::IsLaterThan | ( | const wxDateTime & | datetime | ) | const |
Returns true if this date is later than the given one.
| bool wxDateTime::IsSameDate | ( | const wxDateTime & | dt | ) | const |
Returns true if the date is the same without comparing the time parts.
| bool wxDateTime::IsSameTime | ( | const wxDateTime & | dt | ) | const |
Returns true if the time is the same (although dates may differ).
| bool wxDateTime::IsStrictlyBetween | ( | const wxDateTime & | t1, | |
| const wxDateTime & | t2 | |||
| ) | const |
| bool wxDateTime::IsBetween | ( | const wxDateTime & | t1, | |
| const wxDateTime & | t2 | |||
| ) | const |
Returns true if IsStrictlyBetween() is true or if the date is equal to one of the limit values.
| wxDateTime wxDateTime::Add | ( | const wxDateSpan & | diff | ) | const |
Adds the given date span to this object.
wxPython Note: This method is named "AddDS" in wxPython.
| wxDateTime wxDateTime::Add | ( | const wxDateSpan & | diff | ) |
Adds the given date span to this object.
wxPython Note: This method is named "AddDS" in wxPython.
| wxDateTime wxDateTime::Add | ( | const wxTimeSpan & | diff | ) | const |
Adds the given time span to this object.
wxPython Note: This method is named "AddTS" in wxPython.
| wxDateTime& wxDateTime::Add | ( | const wxTimeSpan & | diff | ) |
Adds the given time span to this object.
wxPython Note: This method is named "AddTS" in wxPython.
| wxDateTime wxDateTime::Subtract | ( | const wxTimeSpan & | diff | ) | const |
Subtracts the given time span from this object.
wxPython Note: This method is named "SubtractTS" in wxPython.
| wxDateTime& wxDateTime::Subtract | ( | const wxTimeSpan & | diff | ) |
Subtracts the given time span from this object.
wxPython Note: This method is named "SubtractTS" in wxPython.
| wxDateTime wxDateTime::Subtract | ( | const wxDateSpan & | diff | ) | const |
Subtracts the given date span from this object.
wxPython Note: This method is named "SubtractDS" in wxPython.
| wxDateTime& wxDateTime::Subtract | ( | const wxDateSpan & | diff | ) |
Subtracts the given date span from this object.
wxPython Note: This method is named "SubtractDS" in wxPython.
| wxTimeSpan wxDateTime::Subtract | ( | const wxDateTime & | dt | ) | const |
Subtracts another date from this one and returns the difference between them as a wxTimeSpan.
| wxDateTime wxDateTime::operator+= | ( | const wxDateSpan & | diff | ) |
Adds the given date span to this object.
| wxDateTime& wxDateTime::operator-= | ( | const wxDateSpan & | diff | ) |
Subtracts the given date span from this object.
| wxDateTime& wxDateTime::operator+= | ( | const wxTimeSpan & | diff | ) |
Adds the given time span to this object.
| wxDateTime& wxDateTime::operator-= | ( | const wxTimeSpan & | diff | ) |
Subtracts the given time span from this object.
| wxString wxDateTime::Format | ( | const wxChar * | format = wxDefaultDateTimeFormat, |
|
| const TimeZone & | tz = Local | |||
| ) | const |
This function does the same as the standard ANSI C strftime(3) function. Please see its description for the meaning of format parameter.
It also accepts a few wxWidgets-specific extensions: you can optionally specify the width of the field to follow using printf(3)-like syntax and the format specification "%l" can be used to get the number of milliseconds.
| wxString wxDateTime::FormatDate | ( | ) | const |
Identical to calling Format() with "%x" argument (which means "preferred date representation for the current locale").
| wxString wxDateTime::FormatISOCombined | ( | char | sep = 'T' |
) | const |
Returns the combined date-time representation in the ISO 8601 format "YYYY-MM-DDTHH:MM:SS". The sep parameter default value produces the result exactly corresponding to the ISO standard, but it can also be useful to use a space as seprator if a more human-readable combined date-time representation is needed.
| wxString wxDateTime::FormatISODate | ( | ) | const |
This function returns the date representation in the ISO 8601 format "YYYY-MM-DD".
| wxString wxDateTime::FormatISOTime | ( | ) | const |
This function returns the time representation in the ISO 8601 format "HH:MM:SS".
| wxString wxDateTime::FormatTime | ( | ) | const |
Identical to calling Format() with "%X" argument (which means "preferred time representation for the current locale").
| const char* wxDateTime::ParseDate | ( | const wxString & | date, | |
| wxString::const_iterator * | end = NULL | |||
| ) |
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.