1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDateTime
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 wxDateTime class represents an absolute moment in the time.
15 The type @c wxDateTime_t is typedefed as <tt>unsigned short</tt> and is
16 used to contain the number of years, hours, minutes, seconds and
20 @section datetime_constants Constants
22 Global constant wxDefaultDateTime and synonym for it wxInvalidDateTime are
23 defined. This constant will be different from any valid wxDateTime object.
25 All the following constants are defined inside wxDateTime class (i.e., to
26 refer to them you should prepend their names with "wxDateTime::").
28 Time zone symbolic names:
33 // the time in the current time zone
36 // zones from GMT (= Greenwhich Mean Time): they're guaranteed to be
37 // consequent numbers, so writing something like `GMT0 + offset' is
38 // safe if abs(offset) <= 12
40 // underscore stands for minus
41 GMT_12, GMT_11, GMT_10, GMT_9, GMT_8, GMT_7,
42 GMT_6, GMT_5, GMT_4, GMT_3, GMT_2, GMT_1,
44 GMT1, GMT2, GMT3, GMT4, GMT5, GMT6,
45 GMT7, GMT8, GMT9, GMT10, GMT11, GMT12, GMT13,
46 // Note that GMT12 and GMT_12 are not the same: there is a difference
47 // of exactly one day between them
49 // some symbolic names for TZ
52 WET = GMT0, // Western Europe Time
53 WEST = GMT1, // Western Europe Summer Time
54 CET = GMT1, // Central Europe Time
55 CEST = GMT2, // Central Europe Summer Time
56 EET = GMT2, // Eastern Europe Time
57 EEST = GMT3, // Eastern Europe Summer Time
58 MSK = GMT3, // Moscow Time
59 MSD = GMT4, // Moscow Summer Time
62 AST = GMT_4, // Atlantic Standard Time
63 ADT = GMT_3, // Atlantic Daylight Time
64 EST = GMT_5, // Eastern Standard Time
65 EDT = GMT_4, // Eastern Daylight Saving Time
66 CST = GMT_6, // Central Standard Time
67 CDT = GMT_5, // Central Daylight Saving Time
68 MST = GMT_7, // Mountain Standard Time
69 MDT = GMT_6, // Mountain Daylight Saving Time
70 PST = GMT_8, // Pacific Standard Time
71 PDT = GMT_7, // Pacific Daylight Saving Time
72 HST = GMT_10, // Hawaiian Standard Time
73 AKST = GMT_9, // Alaska Standard Time
74 AKDT = GMT_8, // Alaska Daylight Saving Time
78 A_WST = GMT8, // Western Standard Time
79 A_CST = GMT13 + 1, // Central Standard Time (+9.5)
80 A_EST = GMT10, // Eastern Standard Time
81 A_ESST = GMT11, // Eastern Summer Time
84 NZST = GMT12, // Standard Time
85 NZDT = GMT13, // Daylight Saving Time
87 // Universal Coordinated Time = the new and politically correct name
93 Month names: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec and
94 Inv_Month for an invalid month are the values of @c wxDateTime::Month enum.
96 Likewise, Sun, Mon, Tue, Wed, Thu, Fri, Sat, and Inv_WeekDay are the values
97 in @c wxDateTime::WeekDay enum.
99 Finally, Inv_Year is defined to be an invalid value for year parameter.
101 GetMonthName() and GetWeekDayName() functions use the following flags:
106 Name_Full = 0x01, // return full name
107 Name_Abbr = 0x02 // return abbreviated name
111 Several functions accept an extra parameter specifying the calendar to use
112 (although most of them only support now the Gregorian calendar). This
113 parameters is one of the following values:
118 Gregorian, // calendar currently in use in Western countries
119 Julian // calendar in use since -45 until the 1582 (or later)
123 Date calculations often depend on the country and wxDateTime allows to set
124 the country whose conventions should be used using SetCountry(). It takes
125 one of the following values as parameter:
130 Country_Unknown, // no special information for this country
131 Country_Default, // set the default country with SetCountry() method
132 // or use the default country with any other
134 Country_WesternEurope_Start,
135 Country_EEC = Country_WesternEurope_Start,
139 Country_WesternEurope_End = UK,
147 Different parts of the world use different conventions for the week start.
148 In some countries, the week starts on Sunday, while in others -- on Monday.
149 The ISO standard doesn't address this issue, so we support both conventions
150 in the functions whose result depends on it (GetWeekOfYear() and
153 The desired behvaiour may be specified by giving one of the following
154 constants as argument to these functions:
159 Default_First, // Sunday_First for US, Monday_First for the rest
160 Monday_First, // week starts with a Monday
161 Sunday_First // week starts with a Sunday
166 @section datetime_static Static Functions
168 All static functions either set or return the static variables of
169 wxDateSpan (the country), return the current moment, year, month or number
170 of days in it, or do some general calendar-related actions.
172 Please note that although several function accept an extra Calendar
173 parameter, it is currently ignored as only the Gregorian calendar is
174 supported. Future versions will support other calendars.
177 These methods are standalone functions named
178 "wxDateTime_<StaticMethodName>" in wxPython.
182 @section datetime_formatting Date Formatting and Parsing
184 The date formatting and parsing functions convert wxDateTime objects to and
185 from text. The conversions to text are mostly trivial: you can either do it
186 using the default date and time representations for the current locale
187 (FormatDate() and FormatTime()), using the international standard
188 representation defined by ISO 8601 (FormatISODate(), FormatISOTime() and
189 FormatISOCombined()) or by specifying any format at all and using Format()
192 The conversions from text are more interesting, as there are much more
193 possibilities to care about. The simplest cases can be taken care of with
194 ParseFormat() which can parse any date in the given (rigid) format.
195 ParseRfc822Date() is another function for parsing dates in predefined
196 format -- the one of RFC 822 which (still...) defines the format of email
197 messages on the Internet. This format can not be described with
198 @c strptime(3)-like format strings used by Format(), hence the need for a
201 But the most interesting functions are ParseTime(), ParseDate() and
202 ParseDateTime(). They try to parse the date and time (or only one of them)
203 in 'free' format, i.e. allow them to be specified in any of possible ways.
204 These functions will usually be used to parse the (interactive) user input
205 which is not bound to be in any predefined format. As an example,
206 ParseDateTime() can parse the strings such as "tomorrow", "March first" and
209 Finally notice that each of the parsing functions is available in several
210 overloads: if the input string is a narrow (@c char *) string, then a
211 narrow pointer is returned. If the input string is a wide string, a wide
212 char pointer is returned. Finally, if the input parameter is a wxString, a
213 narrow char pointer is also returned for backwards compatibility but there
214 is also an additional argument of wxString::const_iterator type in which,
215 if it is not @NULL, an iterator pointing to the end of the scanned string
223 - ::wxDefaultDateTime
225 @see @ref overview_datetime, wxTimeSpan, wxDateSpan, wxCalendarCtrl
231 @name Constructors, Assignment Operators and Setters
233 Constructors and various Set() methods are collected here. If you
234 construct a date object from separate values for day, month and year,
235 you should use IsValid() method to check that the values were correct
236 as constructors can not return an error code.
241 Default constructor. Use one of the Set() functions to initialize the
249 This constructor is named "wxDateTimeFromTimeT" in wxPython.
252 wxDateTime
& wxDateTime(time_t timet
);
256 @beginWxPythonOnly Unsupported. @endWxPythonOnly
258 wxDateTime
& wxDateTime(const struct tm
& tm
);
263 This constructor is named "wxDateTimeFromJDN" in wxPython.
266 wxDateTime
& wxDateTime(double jdn
);
271 This constructor is named "wxDateTimeFromHMS" in wxPython.
274 wxDateTime
& wxDateTime(wxDateTime_t hour
, wxDateTime_t minute
= 0,
275 wxDateTime_t second
= 0, wxDateTime_t millisec
= 0);
280 This constructor is named "wxDateTimeFromDMY" in wxPython.
283 wxDateTime(wxDateTime_t day
, Month month
= Inv_Month
,
284 int year
= Inv_Year
, wxDateTime_t hour
= 0,
285 wxDateTime_t minute
= 0, wxDateTime_t second
= 0,
286 wxDateTime_t millisec
= 0);
289 Same as SetFromMSWSysTime.
292 Input, Windows SYSTEMTIME reference
296 wxDateTime(const struct _SYSTEMTIME
& st
);
300 Reset time to midnight (00:00:00) without changing the date.
302 wxDateTime
& ResetTime();
305 Constructs the object from @a timet value holding the number of seconds
309 This method is named "SetTimeT" in wxPython.
312 wxDateTime
& Set(time_t timet
);
314 Sets the date and time from the broken down representation in the
315 standard @a tm structure.
317 @beginWxPythonOnly Unsupported. @endWxPythonOnly
319 wxDateTime
& Set(const struct tm
& tm
);
321 Sets the date from the so-called Julian Day Number.
323 By definition, the Julian Day Number, usually abbreviated as JDN, of a
324 particular instant is the fractional number of days since 12 hours
325 Universal Coordinated Time (Greenwich mean noon) on January 1 of the
326 year -4712 in the Julian proleptic calendar.
329 This method is named "SetJDN" in wxPython.
332 wxDateTime
& Set(double jdn
);
334 Sets the date to be equal to Today() and the time from supplied
338 This method is named "SetHMS" in wxPython.
341 wxDateTime
& Set(wxDateTime_t hour
, wxDateTime_t minute
= 0,
342 wxDateTime_t second
= 0, wxDateTime_t millisec
= 0);
344 Sets the date and time from the parameters.
346 wxDateTime
& Set(wxDateTime_t day
, Month month
= Inv_Month
,
347 int year
= Inv_Year
, wxDateTime_t hour
= 0,
348 wxDateTime_t minute
= 0, wxDateTime_t second
= 0,
349 wxDateTime_t millisec
= 0);
352 Sets the day without changing other date components.
354 wxDateTime
& SetDay(short unsigned int);
357 Sets the date from the date and time in DOS format.
359 wxDateTime
& SetFromDOS(unsigned long ddt
);
362 Sets the hour without changing other date components.
364 wxDateTime
& SetHour(short unsigned int);
367 Sets the millisecond without changing other date components.
369 wxDateTime
& SetMillisecond(short unsigned int);
372 Sets the minute without changing other date components.
374 wxDateTime
& SetMinute(short unsigned int);
377 Sets the month without changing other date components.
379 wxDateTime
& SetMonth(Month month
);
382 Sets the second without changing other date components.
384 wxDateTime
& SetSecond(short unsigned int);
387 Sets the date and time of to the current values. Same as assigning the
388 result of Now() to this object.
390 wxDateTime
& SetToCurrent();
393 Sets the year without changing other date components.
395 wxDateTime
& SetYear(int year
);
400 wxDateTime
& operator=(time_t timet
);
404 wxDateTime
& operator=(const struct tm
& tm
);
413 Here are the trivial accessors. Other functions, which might have to
414 perform some more complicated calculations to find the answer are under
415 the "Date Arithmetics" section.
420 Returns the date and time in DOS format.
422 long unsigned int GetAsDOS() const;
425 Initialize using the Windows SYSTEMTIME structure.
427 Input, Windows SYSTEMTIME reference
431 wxDateTime
& SetFromMSWSysTime(const struct _SYSTEMTIME
& st
);
434 Returns the date and time in the Windows SYSTEMTIME format.
436 Output, pointer to Windows SYSTEMTIME
440 void GetAsMSWSysTime(struct _SYSTEMTIME
* st
) const;
443 Returns the century of this date.
445 int GetCentury(const TimeZone
& tz
= Local
) const;
448 Returns the object having the same date component as this one but time
455 wxDateTime
GetDateOnly() const;
458 Returns the day in the given timezone (local one by default).
460 short unsigned int GetDay(const TimeZone
& tz
= Local
) const;
463 Returns the day of the year (in 1-366 range) in the given timezone
464 (local one by default).
466 short unsigned int GetDayOfYear(const TimeZone
& tz
= Local
) const;
469 Returns the hour in the given timezone (local one by default).
471 short unsigned int GetHour(const TimeZone
& tz
= Local
) const;
474 Returns the milliseconds in the given timezone (local one by default).
476 short unsigned int GetMillisecond(const TimeZone
& tz
= Local
) const;
479 Returns the minute in the given timezone (local one by default).
481 short unsigned int GetMinute(const TimeZone
& tz
= Local
) const;
484 Returns the month in the given timezone (local one by default).
486 Month
GetMonth(const TimeZone
& tz
= Local
) const;
489 Returns the seconds in the given timezone (local one by default).
491 short unsigned int GetSecond(const TimeZone
& tz
= Local
) const;
494 Returns the number of seconds since Jan 1, 1970. An assert failure will
495 occur if the date is not in the range covered by @c time_t type.
497 time_t GetTicks() const;
500 Returns broken down representation of the date and time.
502 Tm
GetTm(const TimeZone
& tz
= Local
) const;
505 Returns the week day in the given timezone (local one by default).
507 WeekDay
GetWeekDay(const TimeZone
& tz
= Local
) const;
510 Returns the ordinal number of the week in the month (in 1-5 range).
512 As GetWeekOfYear(), this function supports both conventions for the
513 week start. See the description of these @c WeekFlags in the
514 @ref datetime_constants section.
516 wxDateTime_t
GetWeekOfMonth(WeekFlags flags
= Monday_First
,
517 const TimeZone
& tz
= Local
) const;
520 Returns the number of the week of the year this date is in. The first
521 week of the year is, according to international standards, the one
522 containing Jan 4 or, equivalently, the first week which has Thursday in
523 this year. Both of these definitions are the same as saying that the
524 first week of the year must contain more than half of its days in this
525 year. Accordingly, the week number will always be in 1-53 range (52 for
528 The function depends on the @ref datetime_constants "week start"
529 convention specified by the @a flags argument but its results for
530 @c Sunday_First are not well-defined as the ISO definition quoted above
531 applies to the weeks starting on Monday only.
533 wxDateTime_t
GetWeekOfYear(WeekFlags flags
= Monday_First
,
534 const TimeZone
& tz
= Local
) const;
537 Returns the year in the given timezone (local one by default).
539 int GetYear(const TimeZone
& tz
= Local
) const;
542 Returns @true if the given date is later than the date of adoption of
543 the Gregorian calendar in the given country (and hence the Gregorian
544 calendar calculations make sense for it).
546 bool IsGregorianDate(GregorianAdoption country
= Gr_Standard
) const;
549 Returns @true if the object represents a valid time moment.
551 bool IsValid() const;
554 Returns @true is this day is not a holiday in the given country.
556 bool IsWorkDay(Country country
= Country_Default
) const;
563 @name Date Comparison
565 There are several functions to allow date comparison. To supplement
566 them, a few global operators, etc taking wxDateTime are defined.
571 Returns @true if this date precedes the given one.
573 bool IsEarlierThan(const wxDateTime
& datetime
) const;
576 Returns @true if the two dates are strictly identical.
578 bool IsEqualTo(const wxDateTime
& datetime
) const;
581 Returns @true if the date is equal to another one up to the given time
582 interval, i.e. if the absolute difference between the two dates is less
585 bool IsEqualUpTo(const wxDateTime
& dt
, const wxTimeSpan
& ts
) const;
588 Returns @true if this date is later than the given one.
590 bool IsLaterThan(const wxDateTime
& datetime
) const;
593 Returns @true if the date is the same without comparing the time parts.
595 bool IsSameDate(const wxDateTime
& dt
) const;
598 Returns @true if the time is the same (although dates may differ).
600 bool IsSameTime(const wxDateTime
& dt
) const;
603 Returns @true if this date lies strictly between the two given dates.
607 bool IsStrictlyBetween(const wxDateTime
& t1
,
608 const wxDateTime
& t2
) const;
611 Returns @true if IsStrictlyBetween() is @true or if the date is equal
612 to one of the limit values.
614 @see IsStrictlyBetween()
616 bool IsBetween(const wxDateTime
& t1
, const wxDateTime
& t2
) const;
623 @name Date Arithmetics
625 These functions carry out
626 @ref overview_datetime_arithmetics "arithmetics" on the wxDateTime
627 objects. As explained in the overview, either wxTimeSpan or wxDateSpan
628 may be added to wxDateTime, hence all functions are overloaded to
629 accept both arguments.
631 Also, both Add() and Subtract() have both const and non-const version.
632 The first one returns a new object which represents the sum/difference
633 of the original one with the argument while the second form modifies
634 the object to which it is applied. The operators "-=" and "+=" are
635 defined to be equivalent to the second forms of these functions.
640 Adds the given date span to this object.
643 This method is named "AddDS" in wxPython.
646 wxDateTime
Add(const wxDateSpan
& diff
) const;
648 Adds the given date span to this object.
651 This method is named "AddDS" in wxPython.
654 wxDateTime
Add(const wxDateSpan
& diff
);
656 Adds the given time span to this object.
659 This method is named "AddTS" in wxPython.
662 wxDateTime
Add(const wxTimeSpan
& diff
) const;
664 Adds the given time span to this object.
667 This method is named "AddTS" in wxPython.
670 wxDateTime
& Add(const wxTimeSpan
& diff
);
673 Subtracts the given time span from this object.
676 This method is named "SubtractTS" in wxPython.
679 wxDateTime
Subtract(const wxTimeSpan
& diff
) const;
681 Subtracts the given time span from this object.
684 This method is named "SubtractTS" in wxPython.
687 wxDateTime
& Subtract(const wxTimeSpan
& diff
);
689 Subtracts the given date span from this object.
692 This method is named "SubtractDS" in wxPython.
695 wxDateTime
Subtract(const wxDateSpan
& diff
) const;
697 Subtracts the given date span from this object.
700 This method is named "SubtractDS" in wxPython.
703 wxDateTime
& Subtract(const wxDateSpan
& diff
);
705 Subtracts another date from this one and returns the difference between
706 them as a wxTimeSpan.
708 wxTimeSpan
Subtract(const wxDateTime
& dt
) const;
711 Adds the given date span to this object.
713 wxDateTime
operator+=(const wxDateSpan
& diff
);
715 Subtracts the given date span from this object.
717 wxDateTime
& operator-=(const wxDateSpan
& diff
);
719 Adds the given time span to this object.
721 wxDateTime
& operator+=(const wxTimeSpan
& diff
);
723 Subtracts the given time span from this object.
725 wxDateTime
& operator-=(const wxTimeSpan
& diff
);
732 @name Date Formatting and Parsing
734 See @ref datetime_formatting
739 This function does the same as the standard ANSI C @c strftime(3)
740 function. Please see its description for the meaning of @a format
743 It also accepts a few wxWidgets-specific extensions: you can optionally
744 specify the width of the field to follow using @c printf(3)-like syntax
745 and the format specification @c "%l" can be used to get the number of
750 wxString
Format(const wxChar
* format
= wxDefaultDateTimeFormat
,
751 const TimeZone
& tz
= Local
) const;
754 Identical to calling Format() with @c "%x" argument (which means
755 "preferred date representation for the current locale").
757 wxString
FormatDate() const;
760 Returns the combined date-time representation in the ISO 8601 format
761 @c "YYYY-MM-DDTHH:MM:SS". The @a sep parameter default value produces
762 the result exactly corresponding to the ISO standard, but it can also
763 be useful to use a space as seprator if a more human-readable combined
764 date-time representation is needed.
766 @see FormatISODate(), FormatISOTime(), ParseISOCombined()
768 wxString
FormatISOCombined(char sep
= 'T') const;
771 This function returns the date representation in the ISO 8601 format
774 wxString
FormatISODate() const;
777 This function returns the time representation in the ISO 8601 format
780 wxString
FormatISOTime() const;
783 Identical to calling Format() with @c "%X" argument (which means
784 "preferred time representation for the current locale").
786 wxString
FormatTime() const;
789 This function is like ParseDateTime(), but it only allows the date to
790 be specified. It is thus less flexible then ParseDateTime(), but also
791 has less chances to misinterpret the user input.
793 @return @NULL if the conversion failed, otherwise return the pointer
794 to the character which stopped the scan.
796 const char* ParseDate(const wxString
& date
,
797 wxString::const_iterator
* end
= NULL
);
799 This function is like ParseDateTime(), but it only allows the date to
800 be specified. It is thus less flexible then ParseDateTime(), but also
801 has less chances to misinterpret the user input.
803 @return @NULL if the conversion failed, otherwise return the pointer
804 to the character which stopped the scan.
806 const char* ParseDate(const char* date
);
808 This function is like ParseDateTime(), but it only allows the date to
809 be specified. It is thus less flexible then ParseDateTime(), but also
810 has less chances to misinterpret the user input.
812 @return @NULL if the conversion failed, otherwise return the pointer
813 to the character which stopped the scan.
815 const wchar_t* ParseDate(const wchar_t* date
);
818 Parses the string @a datetime containing the date and time in free
819 format. This function tries as hard as it can to interpret the given
820 string as date and time. Unlike ParseRfc822Date(), it will accept
821 anything that may be accepted and will only reject strings which can
822 not be parsed in any way at all.
824 @return @NULL if the conversion failed, otherwise return the pointer
825 to the character which stopped the scan.
827 const char* ParseDateTime(const wxString
& datetime
,
828 wxString::const_iterator
* end
= NULL
);
830 Parses the string @a datetime containing the date and time in free
831 format. This function tries as hard as it can to interpret the given
832 string as date and time. Unlike ParseRfc822Date(), it will accept
833 anything that may be accepted and will only reject strings which can
834 not be parsed in any way at all.
836 @return @NULL if the conversion failed, otherwise return the pointer
837 to the character which stopped the scan.
839 const char* ParseDateTime(const char* datetime
);
841 Parses the string @a datetime containing the date and time in free
842 format. This function tries as hard as it can to interpret the given
843 string as date and time. Unlike ParseRfc822Date(), it will accept
844 anything that may be accepted and will only reject strings which can
845 not be parsed in any way at all.
847 @return @NULL if the conversion failed, otherwise return the pointer
848 to the character which stopped the scan.
850 const wchar_t* ParseDateTime(const wchar_t* datetime
);
853 This function parses the string @a date according to the given
854 @e format. The system @c strptime(3) function is used whenever
855 available, but even if it is not, this function is still implemented,
856 although support for locale-dependent format specifiers such as
857 @c "%c", @c "%x" or @c "%X" may not be perfect and GNU extensions such
858 as @c "%z" and @c "%Z" are not implemented. This function does handle
859 the month and weekday names in the current locale on all platforms,
862 Please see the description of the ANSI C function @c strftime(3) for
863 the syntax of the format string.
865 The @a dateDef parameter is used to fill in the fields which could not
866 be determined from the format string. For example, if the format is
867 @c "%d" (the day of the month), the month and the year are taken from
868 @a dateDef. If it is not specified, Today() is used as the default
871 @return @NULL if the conversion failed, otherwise return the pointer
872 to the character which stopped the scan.
874 const char* ParseFormat(const wxString
& date
,
875 const wxString
& format
= wxDefaultDateTimeFormat
,
876 const wxDateTime
& dateDef
= wxDefaultDateTime
,
877 wxString::const_iterator
* end
= NULL
);
879 This function parses the string @a date according to the given
880 @e format. The system @c strptime(3) function is used whenever
881 available, but even if it is not, this function is still implemented,
882 although support for locale-dependent format specifiers such as
883 @c "%c", @c "%x" or @c "%X" may not be perfect and GNU extensions such
884 as @c "%z" and @c "%Z" are not implemented. This function does handle
885 the month and weekday names in the current locale on all platforms,
888 Please see the description of the ANSI C function @c strftime(3) for
889 the syntax of the format string.
891 The @a dateDef parameter is used to fill in the fields which could not
892 be determined from the format string. For example, if the format is
893 @c "%d" (the day of the month), the month and the year are taken from
894 @a dateDef. If it is not specified, Today() is used as the default
897 @return @NULL if the conversion failed, otherwise return the pointer
898 to the character which stopped the scan.
900 const char* ParseFormat(const char* date
,
901 const wxString
& format
= wxDefaultDateTimeFormat
,
902 const wxDateTime
& dateDef
= wxDefaultDateTime
);
904 This function parses the string @a date according to the given
905 @e format. The system @c strptime(3) function is used whenever
906 available, but even if it is not, this function is still implemented,
907 although support for locale-dependent format specifiers such as
908 @c "%c", @c "%x" or @c "%X" may not be perfect and GNU extensions such
909 as @c "%z" and @c "%Z" are not implemented. This function does handle
910 the month and weekday names in the current locale on all platforms,
913 Please see the description of the ANSI C function @c strftime(3) for
914 the syntax of the format string.
916 The @a dateDef parameter is used to fill in the fields which could not
917 be determined from the format string. For example, if the format is
918 @c "%d" (the day of the month), the month and the year are taken from
919 @a dateDef. If it is not specified, Today() is used as the default
922 @return @NULL if the conversion failed, otherwise return the pointer
923 to the character which stopped the scan.
925 const wchar_t* ParseFormat(const wchar_t* date
,
926 const wxString
& format
= wxDefaultDateTimeFormat
,
927 const wxDateTime
& dateDef
= wxDefaultDateTime
);
930 This function parses the string containing the date and time in ISO
931 8601 combined format @c "YYYY-MM-DDTHH:MM:SS". The separator between
932 the date and time parts must be equal to @a sep for the function to
935 @return @true if the entire string was parsed successfully, @false
938 bool ParseISOCombined(const wxString
& date
, char sep
= 'T');
941 This function parses the date in ISO 8601 format @c "YYYY-MM-DD".
943 @return @true if the entire string was parsed successfully, @false
946 bool ParseISODate(const wxString
& date
);
949 This function parses the time in ISO 8601 format @c "HH:MM:SS".
951 @return @true if the entire string was parsed successfully, @false
954 bool ParseISOTime(const wxString
& date
);
957 Parses the string @a date looking for a date formatted according to the
958 RFC 822 in it. The exact description of this format may, of course, be
959 found in the RFC (section 5), but, briefly, this is the format used in
960 the headers of Internet email messages and one of the most common
961 strings expressing date in this format may be something like
962 @c "Sat, 18 Dec 1999 00:48:30 +0100".
964 Returns @NULL if the conversion failed, otherwise return the pointer to
965 the character immediately following the part of the string which could
966 be parsed. If the entire string contains only the date in RFC 822
967 format, the returned pointer will be pointing to a @c NUL character.
969 This function is intentionally strict, it will return an error for any
970 string which is not RFC 822 compliant. If you need to parse date
971 formatted in more free ways, you should use ParseDateTime() or
974 const char* ParseRfc822Date(const wxString
& date
,
975 wxString::const_iterator
* end
= NULL
);
977 Parses the string @a date looking for a date formatted according to the
978 RFC 822 in it. The exact description of this format may, of course, be
979 found in the RFC (section 5), but, briefly, this is the format used in
980 the headers of Internet email messages and one of the most common
981 strings expressing date in this format may be something like
982 @c "Sat, 18 Dec 1999 00:48:30 +0100".
984 Returns @NULL if the conversion failed, otherwise return the pointer to
985 the character immediately following the part of the string which could
986 be parsed. If the entire string contains only the date in RFC 822
987 format, the returned pointer will be pointing to a @c NUL character.
989 This function is intentionally strict, it will return an error for any
990 string which is not RFC 822 compliant. If you need to parse date
991 formatted in more free ways, you should use ParseDateTime() or
994 const char* ParseRfc822Date(const char* date
);
996 Parses the string @a date looking for a date formatted according to the
997 RFC 822 in it. The exact description of this format may, of course, be
998 found in the RFC (section 5), but, briefly, this is the format used in
999 the headers of Internet email messages and one of the most common
1000 strings expressing date in this format may be something like
1001 @c "Sat, 18 Dec 1999 00:48:30 +0100".
1003 Returns @NULL if the conversion failed, otherwise return the pointer to
1004 the character immediately following the part of the string which could
1005 be parsed. If the entire string contains only the date in RFC 822
1006 format, the returned pointer will be pointing to a @c NUL character.
1008 This function is intentionally strict, it will return an error for any
1009 string which is not RFC 822 compliant. If you need to parse date
1010 formatted in more free ways, you should use ParseDateTime() or
1011 ParseDate() instead.
1013 const wchar_t* ParseRfc822Date(const wchar_t* date
);
1016 This functions is like ParseDateTime(), but only allows the time to be
1017 specified in the input string.
1019 @return @NULL if the conversion failed, otherwise return the pointer
1020 to the character which stopped the scan.
1022 const char* ParseTime(const wxString
& time
,
1023 wxString::const_iterator
* end
= NULL
);
1025 This functions is like ParseDateTime(), but only allows the time to be
1026 specified in the input string.
1028 @return @NULL if the conversion failed, otherwise return the pointer
1029 to the character which stopped the scan.
1031 const char* ParseTime(const char* time
);
1033 This functions is like ParseDateTime(), but only allows the time to be
1034 specified in the input string.
1036 @return @NULL if the conversion failed, otherwise return the pointer
1037 to the character which stopped the scan.
1039 const wchar_t* ParseTime(const wchar_t* time
);
1046 @name Calendar Calculations
1048 The functions in this section perform the basic calendar calculations,
1049 mostly related to the week days. They allow to find the given week day
1050 in the week with given number (either in the month or in the year) and
1053 None of the functions in this section modify the time part of the
1054 wxDateTime, they only work with the date part of it.
1059 Returns the copy of this object to which SetToLastMonthDay() was
1062 wxDateTime
GetLastMonthDay(Month month
= Inv_Month
,
1063 int year
= Inv_Year
) const;
1066 Returns the copy of this object to which SetToLastWeekDay() was
1069 wxDateTime
GetLastWeekDay(WeekDay weekday
, Month month
= Inv_Month
,
1070 int year
= Inv_Year
);
1073 Returns the copy of this object to which SetToNextWeekDay() was
1076 wxDateTime
GetNextWeekDay(WeekDay weekday
) const;
1079 Returns the copy of this object to which SetToPrevWeekDay() was
1082 wxDateTime
GetPrevWeekDay(WeekDay weekday
) const;
1085 Returns the copy of this object to which SetToWeekDay() was applied.
1087 wxDateTime
GetWeekDay(WeekDay weekday
, int n
= 1, Month month
= Inv_Month
,
1088 int year
= Inv_Year
) const;
1091 Returns the copy of this object to which SetToWeekDayInSameWeek() was
1094 wxDateTime
GetWeekDayInSameWeek(WeekDay weekday
,
1095 WeekFlags flags
= Monday_First
) const;
1098 Returns the copy of this object to which SetToYearDay() was applied.
1100 wxDateTime
GetYearDay(wxDateTime_t yday
) const;
1103 Sets the date to the last day in the specified month (the current one
1106 @return The reference to the modified object itself.
1108 wxDateTime
SetToLastMonthDay(Month month
= Inv_Month
,
1109 int year
= Inv_Year
);
1112 The effect of calling this function is the same as of calling
1113 @c SetToWeekDay(-1, weekday, month, year). The date will be set to the
1114 last @a weekday in the given month and year (the current ones by
1115 default). Always returns @true.
1117 bool SetToLastWeekDay(WeekDay weekday
, Month month
= Inv_Month
,
1118 int year
= Inv_Year
);
1121 Sets the date so that it will be the first @a weekday following the
1124 @return The reference to the modified object itself.
1126 wxDateTime
& SetToNextWeekDay(WeekDay weekday
);
1129 Sets the date so that it will be the last @a weekday before the current
1132 @return The reference to the modified object itself.
1134 wxDateTime
& SetToPrevWeekDay(WeekDay weekday
);
1137 Sets the date to the @e n-th @a weekday in the given month of the given
1138 year (the current month and year are used by default). The parameter
1139 @a n may be either positive (counting from the beginning of the month)
1140 or negative (counting from the end of it).
1142 For example, SetToWeekDay(2, wxDateTime::Wed) will set the date to the
1143 second Wednesday in the current month and
1144 SetToWeekDay(-1, wxDateTime::Sun) will set the date to the last Sunday
1145 in the current month.
1147 @return @true if the date was modified successfully, @false otherwise
1148 meaning that the specified date doesn't exist.
1150 bool SetToWeekDay(WeekDay weekday
, int n
= 1,
1151 Month month
= Inv_Month
, int year
= Inv_Year
);
1154 Adjusts the date so that it will still lie in the same week as before,
1155 but its week day will be the given one.
1157 @return The reference to the modified object itself.
1159 wxDateTime
SetToWeekDayInSameWeek(WeekDay weekday
,
1160 WeekFlags flags
= Monday_First
);
1163 Sets the date to the day number @a yday in the same year (i.e., unlike
1164 the other functions, this one does not use the current year). The day
1165 number should be in the range 1-366 for the leap years and 1-365 for
1168 @return The reference to the modified object itself.
1170 wxDateTime
& SetToYearDay(wxDateTime_t yday
);
1177 @name Astronomical/Historical Functions
1179 Some degree of support for the date units used in astronomy and/or
1180 history is provided. You can construct a wxDateTime object from a
1181 JDN and you may also get its JDN, MJD or Rata Die number from it.
1183 Related functions in other groups: wxDateTime(double), Set(double)
1188 Synonym for GetJulianDayNumber().
1190 double GetJDN() const;
1193 Returns the JDN corresponding to this date. Beware of rounding errors!
1195 @see GetModifiedJulianDayNumber()
1197 double GetJulianDayNumber() const;
1200 Synonym for GetModifiedJulianDayNumber().
1202 double GetMJD() const;
1205 Returns the @e "Modified Julian Day Number" (MJD) which is, by
1206 definition, is equal to JDN - 2400000.5. The MJDs are simpler to work
1207 with as the integral MJDs correspond to midnights of the dates in the
1208 Gregorian calendar and not the noons like JDN. The MJD 0 represents
1211 double GetModifiedJulianDayNumber() const;
1214 Return the @e Rata Die number of this date.
1216 By definition, the Rata Die number is a date specified as the number of
1217 days relative to a base date of December 31 of the year 0. Thus January
1218 1 of the year 1 is Rata Die day 1.
1220 double GetRataDie() const;
1227 @name Time Zone and DST Support
1229 Please see the @ref overview_datetime_timezones "time zone overview"
1230 for more information about time zones. Normally, these functions should
1233 Related functions in other groups: GetBeginDST(), GetEndDST()
1238 Transform the date from the given time zone to the local one. If
1239 @a noDST is @true, no DST adjustments will be made.
1241 @return The date in the local time zone.
1243 wxDateTime
FromTimezone(const TimeZone
& tz
, bool noDST
= false) const;
1246 Returns @true if the DST is applied for this date in the given country.
1248 @see GetBeginDST(), GetEndDST()
1250 int IsDST(Country country
= Country_Default
) const;
1253 Same as FromTimezone() but modifies the object in place.
1255 wxDateTime
MakeFromTimezone(const TimeZone
& tz
, bool noDST
= false);
1258 Modifies the object in place to represent the date in another time
1259 zone. If @a noDST is @true, no DST adjustments will be made.
1261 wxDateTime
MakeTimezone(const TimeZone
& tz
, bool noDST
= false);
1264 This is the same as calling MakeTimezone() with the argument @c GMT0.
1266 wxDateTime
& MakeUTC(bool noDST
= false);
1269 Transform the date to the given time zone. If @a noDST is @true, no DST
1270 adjustments will be made.
1272 @return The date in the new time zone.
1274 wxDateTime
ToTimezone(const TimeZone
& tz
, bool noDST
= false) const;
1277 This is the same as calling ToTimezone() with the argument @c GMT0.
1279 wxDateTime
ToUTC(bool noDST
= false) const;
1288 Converts the year in absolute notation (i.e. a number which can be
1289 negative, positive or zero) to the year in BC/AD notation. For the
1290 positive years, nothing is done, but the year 0 is year 1 BC and so for
1291 other years there is a difference of 1.
1293 This function should be used like this:
1297 int y = dt.GetYear();
1298 printf("The year is %d%s", wxDateTime::ConvertYearToBC(y), y > 0 ? "AD" : "BC");
1301 static int ConvertYearToBC(int year
);
1304 Returns the translations of the strings @c AM and @c PM used for time
1305 formatting for the current locale. Either of the pointers may be @NULL
1306 if the corresponding value is not needed.
1308 static void GetAmPmStrings(wxString
* am
, wxString
* pm
);
1311 Get the beginning of DST for the given country in the given year
1312 (current one by default). This function suffers from limitations
1313 described in the @ref overview_datetime_dst "DST overview".
1317 static wxDateTime
GetBeginDST(int year
= Inv_Year
,
1318 Country country
= Country_Default
);
1321 Returns the end of DST for the given country in the given year (current
1326 static wxDateTime
GetEndDST(int year
= Inv_Year
,
1327 Country country
= Country_Default
);
1330 Get the current century, i.e. first two digits of the year, in given
1331 calendar (only Gregorian is currently supported).
1333 static int GetCentury(int year
);
1336 Returns the current default country. The default country is used for
1337 DST calculations, for example.
1341 static Country
GetCountry();
1344 Get the current month in given calendar (only Gregorian is currently
1347 static Month
GetCurrentMonth(Calendar cal
= Gregorian
);
1350 Get the current year in given calendar (only Gregorian is currently
1353 static int GetCurrentYear(Calendar cal
= Gregorian
);
1356 Gets the full (default) or abbreviated (specify @c Name_Abbr name of
1359 @see GetWeekDayName()
1361 static wxString
GetMonthName(Month month
, NameFlags flags
= Name_Full
);
1364 Returns the number of days in the given year. The only supported value
1365 for @a cal currently is @c Gregorian.
1368 This method is named "GetNumberOfDaysInYear" in wxPython.
1371 static wxDateTime_t
GetNumberOfDays(int year
, Calendar cal
= Gregorian
);
1374 Returns the number of days in the given month of the given year. The
1375 only supported value for @a cal currently is @c Gregorian.
1378 This method is named "GetNumberOfDaysInMonth" in wxPython.
1381 static wxDateTime_t
GetNumberOfDays(Month month
, int year
= Inv_Year
,
1382 Calendar cal
= Gregorian
);
1385 Returns the current time.
1387 static time_t GetTimeNow();
1390 Returns the current time broken down using the buffer whose adress is
1391 passed to the function with @a tm to store the result.
1393 static struct tm
* GetTmNow(struct tm
*tm
);
1396 Returns the current time broken down. Note that this function returns a
1397 pointer to a static buffer that's reused by calls to this function and
1398 certain C library functions (e.g. localtime). If there is any chance
1399 your code might be used in a multi-threaded application, you really
1400 should use GetTmNow(struct tm *) instead.
1402 static struct tm
* GetTmNow();
1405 Gets the full (default) or abbreviated (specify @c Name_Abbr) name of
1410 static wxString
GetWeekDayName(WeekDay weekday
,
1411 NameFlags flags
= Name_Full
);
1414 Returns @true if DST was used n the given year (the current one by
1415 default) in the given country.
1417 static bool IsDSTApplicable(int year
= Inv_Year
,
1418 Country country
= Country_Default
);
1421 Returns @true if the @a year is a leap one in the specified calendar.
1422 This functions supports Gregorian and Julian calendars.
1424 static bool IsLeapYear(int year
= Inv_Year
, Calendar cal
= Gregorian
);
1427 This function returns @true if the specified (or default) country is
1428 one of Western European ones. It is used internally by wxDateTime to
1429 determine the DST convention and date and time formatting rules.
1431 static bool IsWestEuropeanCountry(Country country
= Country_Default
);
1434 Returns the object corresponding to the current time.
1439 wxDateTime now = wxDateTime::Now();
1440 printf("Current time in Paris:\t%s\n", now.Format("%c", wxDateTime::CET).c_str());
1443 @note This function is accurate up to seconds. UNow() should be used
1444 for better precision, but it is less efficient and might not be
1445 available on all platforms.
1449 static wxDateTime
Now();
1452 Sets the country to use by default. This setting influences the DST
1453 calculations, date formatting and other things.
1455 The possible values for @a country parameter are enumerated in the
1456 @ref datetime_constants section.
1460 static void SetCountry(Country country
);
1463 Set the date to the given @a weekday in the week number @a numWeek of
1464 the given @a year . The number should be in range 1-53.
1466 Note that the returned date may be in a different year than the one
1467 passed to this function because both the week 1 and week 52 or 53 (for
1468 leap years) contain days from different years. See GetWeekOfYear() for
1469 the explanation of how the year weeks are counted.
1471 static wxDateTime
SetToWeekOfYear(int year
, wxDateTime_t numWeek
,
1472 WeekDay weekday
= Mon
);
1475 Returns the object corresponding to the midnight of the current day
1476 (i.e. the same as Now(), but the time part is set to 0).
1480 static wxDateTime
Today();
1483 Returns the object corresponding to the current time including the
1484 milliseconds if a function to get time with such precision is available
1485 on the current platform (supported under most Unices and Win32).
1489 static wxDateTime
UNow();
1493 Global instance of an empty wxDateTime object.
1495 @todo Would it be better to rename this wxNullDateTime so it's consistent
1496 with the rest of the "empty/invalid/null" global objects?
1498 const wxDateTime wxDefaultDateTime
;
1503 @class wxDateTimeWorkDays
1504 @wxheader{datetime.h}
1506 @todo Write wxDateTimeWorkDays documentation.
1511 class wxDateTimeWorkDays
1521 @wxheader{datetime.h}
1523 This class is a "logical time span" and is useful for implementing program
1524 logic for such things as "add one month to the date" which, in general,
1525 doesn't mean to add 60*60*24*31 seconds to it, but to take the same date
1526 the next month (to understand that this is indeed different consider adding
1527 one month to Feb, 15 -- we want to get Mar, 15, of course).
1529 When adding a month to the date, all lesser components (days, hours, ...)
1530 won't be changed unless the resulting date would be invalid: for example,
1531 Jan 31 + 1 month will be Feb 28, not (non-existing) Feb 31.
1533 Because of this feature, adding and subtracting back again the same
1534 wxDateSpan will @b not, in general, give back the original date: Feb 28 - 1
1535 month will be Jan 28, not Jan 31!
1537 wxDateSpan objects can be either positive or negative. They may be
1538 multiplied by scalars which multiply all deltas by the scalar: i.e.
1539 2*(1 month and 1 day) is 2 months and 2 days. They can be added together
1540 with wxDateTime or wxTimeSpan, but the type of result is different for each
1543 @warning If you specify both weeks and days, the total number of days added
1544 will be 7*weeks + days! See also GetTotalDays().
1546 Equality operators are defined for wxDateSpans. Two wxDateSpans are equal
1547 if and only if they both give the same target date when added to @b every
1548 source date. Thus wxDateSpan::Months(1) is not equal to
1549 wxDateSpan::Days(30), because they don't give the same date when added to
1550 Feb 1st. But wxDateSpan::Days(14) is equal to wxDateSpan::Weeks(2).
1552 Finally, notice that for adding hours, minutes and so on you don't need
1553 this class at all: wxTimeSpan will do the job because there are no
1554 subtleties associated with those (we don't support leap seconds).
1559 @see @ref overview_datetime, wxDateTime
1565 Constructs the date span object for the given number of years, months,
1566 weeks and days. Note that the weeks and days add together if both are
1569 wxDateSpan(int years
= 0, int months
= 0, int weeks
= 0, int days
= 0);
1572 Returns the sum of two date spans.
1574 @return A new wxDateSpan object with the result.
1576 wxDateSpan
Add(const wxDateSpan
& other
) const;
1578 Adds the given wxDateSpan to this wxDateSpan and returns a reference
1581 wxDateSpan
& Add(const wxDateSpan
& other
);
1584 Returns a date span object corresponding to one day.
1588 static wxDateSpan
Day();
1591 Returns a date span object corresponding to the given number of days.
1595 static wxDateSpan
Days(int days
);
1598 Returns the number of days (not counting the weeks component) in this
1603 int GetDays() const;
1606 Returns the number of the months (not counting the years) in this date
1609 int GetMonths() const;
1612 Returns the combined number of days in this date span, counting both
1613 weeks and days. This doesn't take months or years into account.
1615 @see GetWeeks(), GetDays()
1617 int GetTotalDays() const;
1620 Returns the number of weeks in this date span.
1624 int GetWeeks() const;
1627 Returns the number of years in this date span.
1629 int GetYears() const;
1632 Returns a date span object corresponding to one month.
1636 static wxDateSpan
Month();
1639 Returns a date span object corresponding to the given number of months.
1643 static wxDateSpan
Months(int mon
);
1646 Returns the product of the date span by the specified @a factor. The
1647 product is computed by multiplying each of the components by the
1650 @return A new wxDateSpan object with the result.
1652 wxDateSpan
Multiply(int factor
) const;
1654 Multiplies this date span by the specified @a factor. The product is
1655 computed by multiplying each of the components by the @a factor.
1657 @return A reference to this wxDateSpan object modified in place.
1659 wxDateSpan
& Multiply(int factor
);
1662 Changes the sign of this date span.
1669 Returns a date span with the opposite sign.
1673 wxDateSpan
Negate() const;
1676 Sets the number of days (without modifying any other components) in
1679 wxDateSpan
& SetDays(int n
);
1682 Sets the number of months (without modifying any other components) in
1685 wxDateSpan
& SetMonths(int n
);
1688 Sets the number of weeks (without modifying any other components) in
1691 wxDateSpan
& SetWeeks(int n
);
1694 Sets the number of years (without modifying any other components) in
1697 wxDateSpan
& SetYears(int n
);
1700 Returns the difference of two date spans.
1702 @return A new wxDateSpan object with the result.
1704 wxDateSpan
Subtract(const wxDateSpan
& other
) const;
1706 Subtracts the given wxDateSpan to this wxDateSpan and returns a
1707 reference to itself.
1709 wxDateSpan
& Subtract(const wxDateSpan
& other
);
1712 Returns a date span object corresponding to one week.
1716 static wxDateSpan
Week();
1719 Returns a date span object corresponding to the given number of weeks.
1723 static wxDateSpan
Weeks(int weeks
);
1726 Returns a date span object corresponding to one year.
1730 static wxDateSpan
Year();
1733 Returns a date span object corresponding to the given number of years.
1737 static wxDateSpan
Years(int years
);
1740 Adds the given wxDateSpan to this wxDateSpan and returns the result.
1742 wxDateSpan
& operator+=(const wxDateSpan
& other
);
1745 Subtracts the given wxDateSpan to this wxDateSpan and returns the
1748 wxDateSpan
& operator-=(const wxDateSpan
& other
);
1751 Changes the sign of this date span.
1755 wxDateSpan
& operator-();
1758 Multiplies this date span by the specified @a factor. The product is
1759 computed by multiplying each of the components by the @a factor.
1761 @return A reference to this wxDateSpan object modified in place.
1763 wxDateSpan
& operator*=(int factor
);
1766 Returns @true if this date span is different from the other one.
1768 bool operator!=(const wxDateSpan
&) const;
1771 Returns @true if this date span is equal to the other one. Two date
1772 spans are considered equal if and only if they have the same number of
1773 years and months and the same total number of days (counting both days
1776 bool operator==(const wxDateSpan
&) const;
1783 @wxheader{datetime.h}
1785 wxTimeSpan class represents a time interval.
1790 @see @ref overview_datetime, wxDateTime
1796 Default constructor, constructs a zero timespan.
1800 Constructs timespan from separate values for each component, with the
1801 date set to 0. Hours are not restricted to 0-24 range, neither are
1802 minutes, seconds or milliseconds.
1804 wxTimeSpan(long hours
, long min
, long sec
, long msec
);
1807 Returns the absolute value of the timespan: does not modify the object.
1809 wxTimeSpan
Abs() const;
1812 Returns the sum of two time spans.
1814 @return A new wxDateSpan object with the result.
1816 wxTimeSpan
Add(const wxTimeSpan
& diff
) const;
1818 Adds the given wxTimeSpan to this wxTimeSpan and returns a reference
1821 wxTimeSpan
& Add(const wxTimeSpan
& diff
);
1824 Returns the timespan for one day.
1826 static wxTimespan
Day();
1829 Returns the timespan for the given number of days.
1831 static wxTimespan
Days(long days
);
1834 Returns the string containing the formatted representation of the time
1835 span. The following format specifiers are allowed after %:
1837 - @c H - Number of Hours
1838 - @c M - Number of Minutes
1839 - @c S - Number of Seconds
1840 - @c l - Number of Milliseconds
1841 - @c D - Number of Days
1842 - @c E - Number of Weeks
1843 - @c % - The percent character
1845 Note that, for example, the number of hours in the description above is
1846 not well defined: it can be either the total number of hours (for
1847 example, for a time span of 50 hours this would be 50) or just the hour
1848 part of the time span, which would be 2 in this case as 50 hours is
1849 equal to 2 days and 2 hours.
1851 wxTimeSpan resolves this ambiguity in the following way: if there had
1852 been, indeed, the @c %D format specified preceding the @c %H, then it
1853 is interpreted as 2. Otherwise, it is 50.
1855 The same applies to all other format specifiers: if they follow a
1856 specifier of larger unit, only the rest part is taken, otherwise the
1859 wxString
Format(const wxString
& = wxDefaultTimeSpanFormat
) const;
1862 Returns the difference in number of days.
1864 int GetDays() const;
1867 Returns the difference in number of hours.
1869 int GetHours() const;
1872 Returns the difference in number of milliseconds.
1874 wxLongLong
GetMilliseconds() const;
1877 Returns the difference in number of minutes.
1879 int GetMinutes() const;
1882 Returns the difference in number of seconds.
1884 wxLongLong
GetSeconds() const;
1887 Returns the internal representation of timespan.
1889 wxLongLong
GetValue() const;
1892 Returns the difference in number of weeks.
1894 int GetWeeks() const;
1897 Returns the timespan for one hour.
1899 static wxTimespan
Hour();
1902 Returns the timespan for the given number of hours.
1904 static wxTimespan
Hours(long hours
);
1907 Returns @true if two timespans are equal.
1909 bool IsEqualTo(const wxTimeSpan
& ts
) const;
1912 Compares two timespans: works with the absolute values, i.e. -2 hours
1913 is longer than 1 hour. Also, it will return @false if the timespans are
1914 equal in absolute value.
1916 bool IsLongerThan(const wxTimeSpan
& ts
) const;
1919 Returns @true if the timespan is negative.
1921 bool IsNegative() const;
1924 Returns @true if the timespan is empty.
1926 bool IsNull() const;
1929 Returns @true if the timespan is positive.
1931 bool IsPositive() const;
1934 Compares two timespans: works with the absolute values, i.e. 1 hour is
1935 shorter than -2 hours. Also, it will return @false if the timespans are
1936 equal in absolute value.
1938 bool IsShorterThan(const wxTimeSpan
& ts
) const;
1941 Returns the timespan for one millisecond.
1943 static wxTimespan
Millisecond();
1946 Returns the timespan for the given number of milliseconds.
1948 static wxTimespan
Milliseconds(long ms
);
1951 Returns the timespan for one minute.
1953 static wxTimespan
Minute();
1956 Returns the timespan for the given number of minutes.
1958 static wxTimespan
Minutes(long min
);
1961 Returns the product of this time span by @a n.
1963 @return A new wxTimeSpan object with the result.
1965 wxTimeSpan
Multiply(int n
) const;
1967 Multiplies this time span by @a n.
1969 @return A reference to this wxTimeSpan object modified in place.
1971 wxTimeSpan
& Multiply(int n
);
1974 Negate the value of the timespan.
1981 Returns timespan with inverted sign.
1985 wxTimeSpan
Negate() const;
1988 Returns the timespan for one second.
1990 static wxTimespan
Second();
1993 Returns the timespan for the given number of seconds.
1995 static wxTimespan
Seconds(long sec
);
1998 Returns the difference of two time spans.
2000 @return A new wxDateSpan object with the result.
2002 wxTimeSpan
Subtract(const wxTimeSpan
& diff
) const;
2004 Subtracts the given wxTimeSpan to this wxTimeSpan and returns a
2005 reference to itself.
2007 wxTimeSpan
& Subtract(const wxTimeSpan
& diff
);
2010 Returns the timespan for one week.
2012 static wxTimespan
Week();
2015 Returns the timespan for the given number of weeks.
2017 static wxTimespan
Weeks(long weeks
);
2020 Adds the given wxTimeSpan to this wxTimeSpan and returns the result.
2022 wxTimeSpan
& operator+=(const wxTimeSpan
& diff
);
2025 Multiplies this time span by @a n.
2027 @return A reference to this wxTimeSpan object modified in place.
2029 wxTimeSpan
& operator*=(int n
);
2032 Negate the value of the timespan.
2036 wxTimeSpan
& operator-();
2039 Subtracts the given wxTimeSpan to this wxTimeSpan and returns the
2042 wxTimeSpan
& operator-=(const wxTimeSpan
& diff
);
2048 @class wxDateTimeHolidayAuthority
2049 @wxheader{datetime.h}
2051 @todo Write wxDateTimeHolidayAuthority documentation.
2056 class wxDateTimeHolidayAuthority