.\" This is a wxWidgets manpage page generated from the XML docs .TH wxDateTime 3wx 2005-02-15 "wxWidgets" "wxWidgets class documentation" .SH NAME wxDateTime \- A class for date/time manipulations .SH DESCRIPTION wxDateTime class represents an absolute moment in the time. .SH "PARENTS" .SH "INCLUDE FILES" wx/datetime.h .SH MEMBERS .SS static int ConvertYearToBC (int year) Converts the year in absolute notation (i.e. a number which can be negative, positive or zero) to the year in BC/AD notation. For the positive years, nothing is done, but the year 0 is year 1 BC and so for other years there is a difference of 1. This function should be used like this: wxDateTime dt(...); int y = dt.GetYear(); printf("The year is .SS static void GetAmPmStrings (wxString *amwxString *pm) Returns the translations of the strings AM and PM used for time formatting for the current locale. Either of the pointers may be NULL if the corresponding value is not needed. .SS static wxDateTime GetBeginDST (int year = Inv_YearCountry country = Country_Default) Get the beginning of DST for the given country in the given year (current one by default). This function suffers from limitations described in DST overview . .SS static Country GetCountry () Returns the current default country. The default country is used for DST calculations, for example. .SS static int GetCurrentYear (Calendar cal = Gregorian) Get the current year in given calendar (only Gregorian is currently supported). .SS static Month GetCurrentMonth (Calendar cal = Gregorian) Get the current month in given calendar (only Gregorian is currently supported). .SS static int GetCentury (int year = Inv_Year) Get the current century, i.e. first two digits of the year, in given calendar (only Gregorian is currently supported). .SS static wxDateTime GetEndDST (int year = Inv_YearCountry country = Country_Default) Returns the end of DST for the given country in the given year (current one by default). .SS static wxString GetMonthName (Month monthNameFlags flags = Name_Full) Gets the full (default) or abbreviated (specify Name_Abbr name of the given month. .SS static wxDateTime_t GetNumberOfDays (int yearCalendar cal = Gregorian) .SS static wxDateTime_t GetNumberOfDays (Month monthint year = Inv_YearCalendar cal = Gregorian) Returns the number of days in the given year or in the given month of the year. The only supported value for cal parameter is currently Gregorian . .SS static time_t GetTimeNow () Returns the current time. .SS static struct tm * GetTmNow () Returns the current time broken down. .SS static wxString GetWeekDayName (WeekDay weekdayNameFlags flags = Name_Full) Gets the full (default) or abbreviated (specify Name_Abbr name of the given week day. .SS static bool IsLeapYear (int year = Inv_YearCalendar cal = Gregorian) Returns true if the year is a leap one in the specified calendar. This functions supports Gregorian and Julian calendars. .SS static bool IsWestEuropeanCountry (Country country = Country_Default) This function returns true if the specified (or default) country is one of Western European ones. It is used internally by wxDateTime to determine the DST convention and date and time formatting rules. .SS static bool IsDSTApplicable (int year = Inv_YearCountry country = Country_Default) Returns true if DST was used n the given year (the current one by default) in the given country. .SS static wxDateTime Now () Returns the object corresponding to the current time. Example: wxDateTime now = wxDateTime::Now(); printf("Current time in Paris:\t Note that this function is accurate up to second: wxDateTime::UNow should be used for better precision (but it is less efficient and might not be available on all platforms). .SS static void SetCountry (Country country) Sets the country to use by default. This setting influences the DST calculations, date formatting and other things. The possible values for country parameter are enumerated in wxDateTime constants section . .SS static wxDateTime Today () Returns the object corresponding to the midnight of the current day (i.e. the same as Now() , but the time part is set to 0). .SS static wxDateTime UNow () Returns the object corresponding to the current time including the milliseconds if a function to get time with such precision is available on the current platform (supported under most Unices and Win32). .SS wxDateTime () Default constructor. Use one of Set() functions to initialize the object later. .SS wxDateTime& wxDateTime (time_t timet) Same as Set . .SS wxDateTime& wxDateTime (const struct tm& tm) Same as Set .SS wxDateTime& wxDateTime (double jdn) Same as Set .SS wxDateTime& wxDateTime (wxDateTime_t hourwxDateTime_t minute = 0wxDateTime_t second = 0wxDateTime_t millisec = 0) Same as Set .SS wxDateTime& wxDateTime (wxDateTime_t dayMonth month = Inv_Monthint Inv_YearwxDateTime_t hour = 0wxDateTime_t minute = 0wxDateTime_t second = 0wxDateTime_t millisec = 0) Same as Set .SS wxDateTime& SetToCurrent () Sets the date and time of to the current values. Same as assigning the result of Now() to this object. .SS wxDateTime& Set (time_t timet) Constructs the object from timet value holding the number of seconds since Jan 1, 1970. .SS wxDateTime& Set (const struct tm& tm) Sets the date and time from the broken down representation in the standard tm structure. .SS 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. .SS wxDateTime& Set (wxDateTime_t hourwxDateTime_t minute = 0wxDateTime_t second = 0wxDateTime_t millisec = 0) Sets the date to be equal to Today and the time from supplied parameters. .SS wxDateTime& Set (wxDateTime_t dayMonth month = Inv_Monthint year = Inv_YearwxDateTime_t hour = 0wxDateTime_t minute = 0wxDateTime_t second = 0wxDateTime_t millisec = 0) Sets the date and time from the parameters. .SS wxDateTime& ResetTime () Reset time to midnight (00:00:00) without changing the date. .SS wxDateTime& SetYear (int year) Sets the year without changing other date components. .SS wxDateTime& SetMonth (Month month) Sets the month without changing other date components. .SS wxDateTime& SetDay (wxDateTime_t day) Sets the day without changing other date components. .SS wxDateTime& SetHour (wxDateTime_t hour) Sets the hour without changing other date components. .SS wxDateTime& SetMinute (wxDateTime_t minute) Sets the minute without changing other date components. .SS wxDateTime& SetSecond (wxDateTime_t second) Sets the second without changing other date components. .SS wxDateTime& SetMillisecond (wxDateTime_t millisecond) Sets the millisecond without changing other date components. .SS wxDateTime& operator (time_t timet) Same as Set . .SS wxDateTime& operator (const struct tm& tm) Same as Set . .SS bool IsValid () Returns true if the object represents a valid time moment. .SS Tm GetTm (const TimeZone& tz = Local) Returns broken down representation of the date and time. .SS time_t GetTicks () 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. .SS int GetYear (const TimeZone& tz = Local) Returns the year in the given timezone (local one by default). .SS Month GetMonth (const TimeZone& tz = Local) Returns the month in the given timezone (local one by default). .SS wxDateTime_t GetDay (const TimeZone& tz = Local) Returns the day in the given timezone (local one by default). .SS WeekDay GetWeekDay (const TimeZone& tz = Local) Returns the week day in the given timezone (local one by default). .SS wxDateTime_t GetHour (const TimeZone& tz = Local) Returns the hour in the given timezone (local one by default). .SS wxDateTime_t GetMinute (const TimeZone& tz = Local) Returns the minute in the given timezone (local one by default). .SS wxDateTime_t GetSecond (const TimeZone& tz = Local) Returns the seconds in the given timezone (local one by default). .SS wxDateTime_t GetMillisecond (const TimeZone& tz = Local) Returns the milliseconds in the given timezone (local one by default). .SS wxDateTime_t GetDayOfYear (const TimeZone& tz = Local) Returns the day of the year (in 1\ldots366 range) in the given timezone (local one by default). .SS wxDateTime_t GetWeekOfYear (WeekFlags flags = Monday_Firstconst TimeZone& tz = Local) 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\ldots53 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. .SS wxDateTime_t GetWeekOfMonth (WeekFlags flags = Monday_Firstconst TimeZone& tz = Local) Returns the ordinal number of the week in the month (in 1\ldots5 range). As GetWeekOfYear , this function supports both conventions for the week start. See the description of these week start conventions. .SS bool IsWorkDay (Country country = Country_Default) Returns true is this day is not a holiday in the given country. .SS bool IsGregorianDate (GregorianAdoption country = Gr_Standard) 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). .SS wxDateTime& Set (unsigned long ddt) Sets the date from the date and time in http://developer.novell.com/ndk/doc/smscomp/index.html?page=/ndk/doc/smscomp/sms_docs/data/hc2vlu5i.html format. .SS unsigned long GetAsDOS () Returns the date and time in http://developer.novell.com/ndk/doc/smscomp/index.html?page=/ndk/doc/smscomp/sms_docs/data/hc2vlu5i.html format. .SS bool IsEqualTo (const wxDateTime& datetime) Returns true if the two dates are strictly identical. .SS bool IsEarlierThan (const wxDateTime& datetime) Returns true if this date precedes the given one. .SS bool IsLaterThan (const wxDateTime& datetime) Returns true if this date is later than the given one. .SS bool IsStrictlyBetween (const wxDateTime& t1const wxDateTime& t2) Returns true if this date lies strictly between the two others, .SS bool IsBetween (const wxDateTime& t1const wxDateTime& t2) Returns true if IsStrictlyBetween is true or if the date is equal to one of the limit values. .SS bool IsSameDate (const wxDateTime& dt) Returns true if the date is the same without comparing the time parts. .SS bool IsSameTime (const wxDateTime& dt) Returns true if the time is the same (although dates may differ). .SS bool IsEqualUpTo (const wxDateTime& dtconst wxTimeSpan& ts) 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. .SS wxDateTime Add (const wxTimeSpan& diff) .SS wxDateTime& Add (const wxTimeSpan& diff) .SS wxDateTime& operator+= (const wxTimeSpan& diff) Adds the given time span to this object. .SS wxDateTime Add (const wxDateSpan& diff) .SS wxDateTime& Add (const wxDateSpan& diff) .SS wxDateTime& operator+= (const wxDateSpan& diff) Adds the given date span to this object. .SS wxDateTime Subtract (const wxTimeSpan& diff) .SS wxDateTime& Subtract (const wxTimeSpan& diff) .SS wxDateTime& operator-= (const wxTimeSpan& diff) Subtracts the given time span from this object. .SS wxDateTime Subtract (const wxDateSpan& diff) .SS wxDateTime& Subtract (const wxDateSpan& diff) .SS wxDateTime& operator-= (const wxDateSpan& diff) Subtracts the given date span from this object. .SS wxTimeSpan Subtract (const wxDateTime& dt) Subtracts another date from this one and returns the difference between them as wxTimeSpan. .SS const wxChar * ParseRfc822Date (const wxChar* date) Parses the string date looking for a date formatted according to the RFC 822 in it. The exact description of this format may, of course, be found in the RFC (section 5), but, briefly, this is the format used in the headers of Internet email messages and one of the most common strings expressing date in this format may be something like "Sat, 18 Dec 1999 00:48:30 +0100" . Returns NULL if the conversion failed, otherwise return the pointer to the character immediately following the part of the string which could be parsed. If the entire string contains only the date in RFC 822 format, the returned pointer will be pointing to a NUL character. This function is intentionally strict, it will return an error for any 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. .SS const wxChar * ParseFormat (const wxChar *dateconst wxChar *format = wxDefaultDateTimeFormatconst wxDateTime& dateDef = wxDefaultDateTime) This function parses the string date according to the given format . The system strptime(3) function is used whenever available, but even if it is not, this function is still implemented, although support for locale-dependent format specifiers such as "%c" , "%x" or "%X" may not be perfect and GNU extensions such as "%z" and "%Z" are not implemented. This function does handle the month and weekday names in the current locale on all platforms, however. Please see the description of the ANSI C function strftime(3) for the syntax of the format string. The dateDef parameter is used to fill in the fields which could not be determined from the format string. For example, if the format is "%d" (the ay of the month), the month and the year are taken from dateDef . If it is not specified, Today is used as the default date. Returns NULL if the conversion failed, otherwise return the pointer to the character which stopped the scan. .SS const wxChar * ParseDateTime (const wxChar *datetime) Parses the string 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. Returns NULL if the conversion failed, otherwise return the pointer to the character which stopped the scan. This method is currently not implemented, so always returns NULL. .SS const wxChar * ParseDate (const wxChar *date) 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. Returns NULL if the conversion failed, otherwise return the pointer to the character which stopped the scan. .SS const wxChar * ParseTime (const wxChar *time) This functions is like ParseDateTime , but only allows the time to be specified in the input string. Returns NULL if the conversion failed, otherwise return the pointer to the character which stopped the scan. .SS wxString Format (const wxChar *format = wxDefaultDateTimeFormatconst TimeZone& tz = Local) 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. .SS wxString FormatDate () Identical to calling Format() with "%x" argument (which means `preferred date representation for the current locale'). .SS wxString FormatTime () Identical to calling Format() with "%X" argument (which means `preferred time representation for the current locale'). .SS wxString FormatISODate () This function returns the date representation in the ISO 8601 format (YYYY-MM-DD). .SS wxString FormatISOTime () This function returns the time representation in the ISO 8601 format (HH:MM:SS). .SS wxDateTime& SetToWeekDayInSameWeek (WeekDay weekdayWeekFlagsflags = Monday_First) Adjusts the date so that it will still lie in the same week as before, but its week day will be the given one. Returns the reference to the modified object itself. .SS wxDateTime GetWeekDayInSameWeek (WeekDay weekdayWeekFlagsflags = Monday_First) Returns the copy of this object to which SetToWeekDayInSameWeek was applied. .SS wxDateTime& SetToNextWeekDay (WeekDay weekday) Sets the date so that it will be the first weekday following the current date. Returns the reference to the modified object itself. .SS wxDateTime GetNextWeekDay (WeekDay weekday) Returns the copy of this object to which SetToNextWeekDay was applied. .SS wxDateTime& SetToPrevWeekDay (WeekDay weekday) Sets the date so that it will be the last weekday before the current date. Returns the reference to the modified object itself. .SS wxDateTime GetPrevWeekDay (WeekDay weekday) Returns the copy of this object to which SetToPrevWeekDay was applied. .SS bool SetToWeekDay (WeekDay weekdayint n = 1Month month = Inv_Monthint year = Inv_Year) Sets the date to the n -th weekday in the given month of the given year (the current month and year are used by default). The parameter n may be either positive (counting from the beginning of the month) or negative (counting from the end of it). For example, SetToWeekDay(2, wxDateTime::Wed) will set the date to the second Wednesday in the current month and SetToWeekDay(-1, wxDateTime::Sun) -- to the last Sunday in it. Returns true if the date was modified successfully, false otherwise meaning that the specified date doesn't exist. .SS wxDateTime GetWeekDay (WeekDay weekdayint n = 1Month month = Inv_Monthint year = Inv_Year) Returns the copy of this object to which SetToWeekDay was applied. .SS bool SetToLastWeekDay (WeekDay weekdayMonth month = Inv_Monthint year = Inv_Year) The effect of calling this function is the same as of calling SetToWeekDay(-1, weekday, month, year) . The date will be set to the last weekday in the given month and year (the current ones by default). Always returns true . .SS wxDateTime GetLastWeekDay (WeekDay weekdayMonth month = Inv_Monthint year = Inv_Year) Returns the copy of this object to which SetToLastWeekDay was applied. .SS static wxDateTime SetToWeekOfYear (int yearwxDateTime_t numWeekWeekDay weekday = Mon) Set the date to the given weekday in the week number numWeek of the given year . The number should be in range 1\ldots53. Note that the returned date may be in a different year than the one passed to this function because both the week 1 and week 52 or 53 (for leap years) contain days from different years. See GetWeekOfYear for the explanation of how the year weeks are counted. .SS wxDateTime& SetToLastMonthDay (Month month = Inv_Monthint year = Inv_Year) Sets the date to the last day in the specified month (the current one by default). Returns the reference to the modified object itself. .SS wxDateTime GetLastMonthDay (Month month = Inv_Monthint year = Inv_Year) Returns the copy of this object to which SetToLastMonthDay was applied. .SS wxDateTime& SetToYearDay (wxDateTime_t yday) Sets the date to the day number yday in the same year (i.e., unlike the other functions, this one does not use the current year). The day number should be in the range 1\ldots366 for the leap years and 1\ldots365 for the other ones. Returns the reference to the modified object itself. .SS wxDateTime GetYearDay (wxDateTime_t yday) Returns the copy of this object to which SetToYearDay was applied. .SS double GetJulianDayNumber () Returns the JDN corresponding to this date. Beware of rounding errors! .SS double GetJDN () Synonym for GetJulianDayNumber . .SS double GetModifiedJulianDayNumber () Returns the Modified Julian Day Number (MJD) which is, by definition, equal to JDN - 2400000.5. The MJDs are simpler to work with as the integral MJDs correspond to midnights of the dates in the Gregorian calendar and not th noons like JDN. The MJD 0 is Nov 17, 1858. .SS double GetMJD () Synonym for GetModifiedJulianDayNumber . .SS double GetRataDie () Return the Rata Die number of this date. By definition, the Rata Die number is a date specified as the number of days relative to a base date of December 31 of the year 0. Thus January 1 of the year 1 is Rata Die day 1. .SS wxDateTime FromTimezone (const TimeZone& tzbool noDST = false) Transform the date from the given time zone to the local one. If noDST is true , no DST adjustments will be made. Returns the date in the local time zone. .SS wxDateTime ToTimezone (const TimeZone& tzbool noDST = false) Transform the date to the given time zone. If noDST is true , no DST adjustments will be made. Returns the date in the new time zone. .SS wxDateTime& MakeTimezone (const TimeZone& tzbool noDST = false) Modifies the object in place to represent the date in another time zone. If noDST is true , no DST adjustments will be made. .SS wxDateTime& MakeFromTimezone (const TimeZone& tzbool noDST = false) Same as FromTimezone but modifies the object in place. .SS wxDateTime ToUTC (bool noDST = false) This is the same as calling ToTimezone with the argument GMT0 . .SS wxDateTime& MakeUTC (bool noDST = false) This is the same as calling MakeTimezone with the argument GMT0 . .SS int IsDST (Country country = Country_Default) Returns true if the DST is applied for this date in the given country. .SH "SEE ALSO" Date classes overview , wxTimeSpan , wxDateSpan , wxCalendarCtrl .SH "AUTHORS" Documentation content by Julian Smart, Robert Roebling, Vadim Zeitlin, Robin Dunn, et al Conversion to manpage format by Arnout Engelen (http://bzzt.net), bugreports welcome.