1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDateTime
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
12 wxDateTime class represents an absolute moment in time.
14 The type @c wxDateTime_t is typedefed as <tt>unsigned short</tt> and is
15 used to contain the number of years, hours, minutes, seconds and
18 Global constant ::wxDefaultDateTime and synonym for it ::wxInvalidDateTime are
19 defined. This constant will be different from any valid wxDateTime object.
22 @section datetime_static Static Functions
24 All static functions either set or return the static variables of
25 wxDateSpan (the country), return the current moment, year, month or number
26 of days in it, or do some general calendar-related actions.
28 Please note that although several function accept an extra Calendar
29 parameter, it is currently ignored as only the Gregorian calendar is
30 supported. Future versions will support other calendars.
32 @section datetime_formatting Date Formatting and Parsing
34 The date formatting and parsing functions convert wxDateTime objects to and
35 from text. The conversions to text are mostly trivial: you can either do it
36 using the default date and time representations for the current locale
37 (FormatDate() and FormatTime()), using the international standard
38 representation defined by ISO 8601 (FormatISODate(), FormatISOTime() and
39 FormatISOCombined()) or by specifying any format at all and using Format()
42 The conversions from text are more interesting, as there are much more
43 possibilities to care about. The simplest cases can be taken care of with
44 ParseFormat() which can parse any date in the given (rigid) format.
45 ParseRfc822Date() is another function for parsing dates in predefined
46 format -- the one of RFC 822 which (still...) defines the format of email
47 messages on the Internet. This format cannot be described with
48 @c strptime(3)-like format strings used by Format(), hence the need for a
51 But the most interesting functions are ParseTime(), ParseDate() and
52 ParseDateTime(). They try to parse the date and time (or only one of them)
53 in 'free' format, i.e. allow them to be specified in any of possible ways.
54 These functions will usually be used to parse the (interactive) user input
55 which is not bound to be in any predefined format. As an example,
56 ParseDate() can parse the strings such as "tomorrow", "March first" and
59 Finally notice that each of the parsing functions is available in several
60 overloads: if the input string is a narrow (@c char *) string, then a
61 narrow pointer is returned. If the input string is a wide string, a wide
62 char pointer is returned. Finally, if the input parameter is a wxString, a
63 narrow char pointer is also returned for backwards compatibility but there
64 is also an additional argument of wxString::const_iterator type in which,
65 if it is not @NULL, an iterator pointing to the end of the scanned string
75 @see @ref overview_datetime, wxTimeSpan, wxDateSpan, wxCalendarCtrl
81 A small unsigned integer type for storing things like minutes,
82 seconds &c. It should be at least short (i.e. not char) to contain
83 the number of milliseconds - it may also be 'int' because there is
84 no size penalty associated with it in our code, we don't store any
87 typedef unsigned short wxDateTime_t
;
91 Time zone symbolic names.
95 /// the time in the current time zone
99 /// zones from GMT (= Greenwich Mean Time): they're guaranteed to be
100 /// consequent numbers, so writing something like `GMT0 + offset' is
101 /// safe if abs(offset) <= 12
103 // underscore stands for minus
104 GMT_12
, GMT_11
, GMT_10
, GMT_9
, GMT_8
, GMT_7
,
105 GMT_6
, GMT_5
, GMT_4
, GMT_3
, GMT_2
, GMT_1
,
107 GMT1
, GMT2
, GMT3
, GMT4
, GMT5
, GMT6
,
108 GMT7
, GMT8
, GMT9
, GMT10
, GMT11
, GMT12
, GMT13
,
109 // Note that GMT12 and GMT_12 are not the same: there is a difference
110 // of exactly one day between them
113 // some symbolic names for TZ
116 WET
= GMT0
, //!< Western Europe Time
117 WEST
= GMT1
, //!< Western Europe Summer Time
118 CET
= GMT1
, //!< Central Europe Time
119 CEST
= GMT2
, //!< Central Europe Summer Time
120 EET
= GMT2
, //!< Eastern Europe Time
121 EEST
= GMT3
, //!< Eastern Europe Summer Time
122 MSK
= GMT3
, //!< Moscow Time
123 MSD
= GMT4
, //!< Moscow Summer Time
126 AST
= GMT_4
, //!< Atlantic Standard Time
127 ADT
= GMT_3
, //!< Atlantic Daylight Time
128 EST
= GMT_5
, //!< Eastern Standard Time
129 EDT
= GMT_4
, //!< Eastern Daylight Saving Time
130 CST
= GMT_6
, //!< Central Standard Time
131 CDT
= GMT_5
, //!< Central Daylight Saving Time
132 MST
= GMT_7
, //!< Mountain Standard Time
133 MDT
= GMT_6
, //!< Mountain Daylight Saving Time
134 PST
= GMT_8
, //!< Pacific Standard Time
135 PDT
= GMT_7
, //!< Pacific Daylight Saving Time
136 HST
= GMT_10
, //!< Hawaiian Standard Time
137 AKST
= GMT_9
, //!< Alaska Standard Time
138 AKDT
= GMT_8
, //!< Alaska Daylight Saving Time
142 A_WST
= GMT8
, //!< Western Standard Time
143 A_CST
= GMT13
+ 1, //!< Central Standard Time (+9.5)
144 A_EST
= GMT10
, //!< Eastern Standard Time
145 A_ESST
= GMT11
, //!< Eastern Summer Time
148 NZST
= GMT12
, //!< Standard Time
149 NZDT
= GMT13
, //!< Daylight Saving Time
151 /// Universal Coordinated Time = the new and politically correct name
157 Several functions accept an extra parameter specifying the calendar to use
158 (although most of them only support now the Gregorian calendar). This
159 parameters is one of the following values.
163 Gregorian
, ///< calendar currently in use in Western countries
164 Julian
///< calendar in use since -45 until the 1582 (or later)
168 Values corresponding to different dates of adoption of the Gregorian
173 enum GregorianAdoption
175 Gr_Unknown
, ///< no data for this country or it's too uncertain to use
176 Gr_Standard
, ///< on the day 0 of Gregorian calendar: 15 Oct 1582
178 Gr_Alaska
, ///< Oct 1867 when Alaska became part of the USA
179 Gr_Albania
, ///< Dec 1912
181 Gr_Austria
= Gr_Unknown
, ///< Different regions on different dates
182 Gr_Austria_Brixen
, ///< 5 Oct 1583 -> 16 Oct 1583
183 Gr_Austria_Salzburg
= Gr_Austria_Brixen
,
184 Gr_Austria_Tyrol
= Gr_Austria_Brixen
,
185 Gr_Austria_Carinthia
, ///< 14 Dec 1583 -> 25 Dec 1583
186 Gr_Austria_Styria
= Gr_Austria_Carinthia
,
188 Gr_Belgium
, ///< Then part of the Netherlands
190 Gr_Bulgaria
= Gr_Unknown
, ///< Unknown precisely (from 1915 to 1920)
191 Gr_Bulgaria_1
, ///< 18 Mar 1916 -> 1 Apr 1916
192 Gr_Bulgaria_2
, ///< 31 Mar 1916 -> 14 Apr 1916
193 Gr_Bulgaria_3
, ///< 3 Sep 1920 -> 17 Sep 1920
195 Gr_Canada
= Gr_Unknown
, ///< Different regions followed the changes in
196 ///< Great Britain or France
198 Gr_China
= Gr_Unknown
, ///< Different authorities say:
199 Gr_China_1
, ///< 18 Dec 1911 -> 1 Jan 1912
200 Gr_China_2
, ///< 18 Dec 1928 -> 1 Jan 1929
202 Gr_Czechoslovakia
, ///< (Bohemia and Moravia) 6 Jan 1584 -> 17 Jan 1584
203 Gr_Denmark
, ///< (including Norway) 18 Feb 1700 -> 1 Mar 1700
205 Gr_Estonia
, ///< 1918
206 Gr_Finland
, ///< Then part of Sweden
208 Gr_France
, ///< 9 Dec 1582 -> 20 Dec 1582
209 Gr_France_Alsace
, ///< 4 Feb 1682 -> 16 Feb 1682
210 Gr_France_Lorraine
, ///< 16 Feb 1760 -> 28 Feb 1760
211 Gr_France_Strasbourg
, ///< February 1682
213 Gr_Germany
= Gr_Unknown
, ///< Different states on different dates:
214 Gr_Germany_Catholic
, ///< 1583-1585 (we take 1584)
215 Gr_Germany_Prussia
, ///< 22 Aug 1610 -> 2 Sep 1610
216 Gr_Germany_Protestant
, ///< 18 Feb 1700 -> 1 Mar 1700
218 Gr_GreatBritain
, ///< 2 Sep 1752 -> 14 Sep 1752 (use 'cal(1)')
220 Gr_Greece
, ///< 9 Mar 1924 -> 23 Mar 1924
221 Gr_Hungary
, ///< 21 Oct 1587 -> 1 Nov 1587
222 Gr_Ireland
= Gr_GreatBritain
,
223 Gr_Italy
= Gr_Standard
,
225 Gr_Japan
= Gr_Unknown
, ///< Different authorities say:
226 Gr_Japan_1
, ///< 19 Dec 1872 -> 1 Jan 1873
227 Gr_Japan_2
, ///< 19 Dec 1892 -> 1 Jan 1893
228 Gr_Japan_3
, ///< 18 Dec 1918 -> 1 Jan 1919
230 Gr_Latvia
, ///< 1915-1918 (we take 1915)
231 Gr_Lithuania
, ///< 1915
232 Gr_Luxemburg
, ///< 14 Dec 1582 -> 25 Dec 1582
233 Gr_Netherlands
= Gr_Belgium
, ///< (including Belgium) 1 Jan 1583
236 Special case of Groningen.
238 The Gregorian calendar was introduced twice in Groningen, first
239 time 28 Feb 1583 was followed by 11 Mar 1583, then it has gone back
240 to Julian in the summer of 1584 and then 13 Dec 1700 was followed
241 by 12 Jan 1701 -- which is the date we take into account here.
243 Gr_Netherlands_Groningen
, ///< 13 Dec 1700 -> 12 Jan 1701
244 Gr_Netherlands_Gelderland
, ///< 30 Jun 1700 -> 12 Jul 1700
245 Gr_Netherlands_Utrecht
, ///< (and Overijssel) 30 Nov 1700->12 Dec 1700
246 Gr_Netherlands_Friesland
, ///< (and Drenthe) 31 Dec 1700 -> 12 Jan 1701
248 Gr_Norway
= Gr_Denmark
, ///< Then part of Denmark
249 Gr_Poland
= Gr_Standard
,
250 Gr_Portugal
= Gr_Standard
,
251 Gr_Romania
, ///< 31 Mar 1919 -> 14 Apr 1919
252 Gr_Russia
, ///< 31 Jan 1918 -> 14 Feb 1918
253 Gr_Scotland
= Gr_GreatBritain
,
254 Gr_Spain
= Gr_Standard
,
257 Special case of Sweden.
259 Sweden has a curious history. Sweden decided to make a gradual
260 change from the Julian to the Gregorian calendar. By dropping every
261 leap year from 1700 through 1740 the eleven superfluous days would
262 be omitted and from 1 Mar 1740 they would be in sync with the
263 Gregorian calendar. (But in the meantime they would be in sync with
266 So 1700 (which should have been a leap year in the Julian calendar)
267 was not a leap year in Sweden. However, by mistake 1704 and 1708
268 became leap years. This left Sweden out of synchronisation with
269 both the Julian and the Gregorian world, so they decided to go back
270 to the Julian calendar. In order to do this, they inserted an extra
271 day in 1712, making that year a double leap year! So in 1712,
272 February had 30 days in Sweden.
274 Later, in 1753, Sweden changed to the Gregorian calendar by
275 dropping 11 days like everyone else and this is what we use here.
277 Gr_Sweden
= Gr_Finland
, ///< 17 Feb 1753 -> 1 Mar 1753
279 Gr_Switzerland
= Gr_Unknown
,///< Different cantons used different dates
280 Gr_Switzerland_Catholic
, ///< 1583, 1584 or 1597 (we take 1584)
281 Gr_Switzerland_Protestant
, ///< 31 Dec 1700 -> 12 Jan 1701
283 Gr_Turkey
, ///< 1 Jan 1927
284 Gr_USA
= Gr_GreatBritain
,
285 Gr_Wales
= Gr_GreatBritain
,
286 Gr_Yugoslavia
///< 1919
290 Date calculations often depend on the country and wxDateTime allows to set
291 the country whose conventions should be used using SetCountry(). It takes
292 one of the following values as parameter.
296 Country_Unknown
, ///< no special information for this country
297 Country_Default
, ///< set the default country with SetCountry() method
298 ///< or use the default country with any other
300 Country_WesternEurope_Start
,
301 Country_EEC
= Country_WesternEurope_Start
,
305 Country_WesternEurope_End
= UK
,
312 /// symbolic names for the months
315 Jan
, Feb
, Mar
, Apr
, May
, Jun
, Jul
, Aug
, Sep
, Oct
, Nov
, Dec
,
317 /// Invalid month value.
321 /// symbolic names for the weekdays
324 Sun
, Mon
, Tue
, Wed
, Thu
, Fri
, Sat
,
326 /// Invalid week day value.
330 /// invalid value for the year
333 Inv_Year
= SHRT_MIN
// should hold in wxDateTime_t
337 Flags to be used with GetMonthName() and GetWeekDayName() functions.
341 Name_Full
= 0x01, ///< return full name
342 Name_Abbr
= 0x02 ///< return abbreviated name
346 Different parts of the world use different conventions for the week start.
347 In some countries, the week starts on Sunday, while in others -- on Monday.
348 The ISO standard doesn't address this issue, so we support both conventions
349 in the functions whose result depends on it (GetWeekOfYear() and
352 The desired behaviour may be specified by giving one of the following
353 constants as argument to these functions.
357 Default_First
, ///< Sunday_First for US, Monday_First for the rest
358 Monday_First
, ///< week starts with a Monday
359 Sunday_First
///< week starts with a Sunday
364 Class representing a time zone.
366 The representation is simply the offset, in seconds, from UTC.
368 class WXDLLIMPEXP_BASE TimeZone
371 /// Constructor for a named time zone.
374 /// Constructor for the given offset in seconds.
375 TimeZone(long offset
= 0);
377 /// Create a time zone with the given offset in seconds.
378 static TimeZone
Make(long offset
);
380 /// Return the offset of this time zone from UTC, in seconds.
381 long GetOffset() const;
385 Contains broken down date-time representation.
387 This struct is analogous to standard C <code>struct tm</code> and uses
388 the same, not always immediately obvious, conventions for its members:
389 notably its mon and mday fields count from 0 while yday counts from 1.
393 wxDateTime_t msec
, ///< Number of milliseconds.
394 sec
, ///< Seconds in 0..59 (60 with leap seconds) range.
395 min
, ///< Minutes in 0..59 range.
396 hour
, ///< Hours since midnight in 0..23 range.
397 mday
, ///< Day of the month in 1..31 range.
398 yday
; ///< Day of the year in 0..365 range.
399 Month mon
; ///< Month, as an enumerated constant.
403 Check if the given date/time is valid (in Gregorian calendar).
405 Return @false if the components don't correspond to a correct date.
407 bool IsValid() const;
410 Return the week day corresponding to this date.
412 Unlike the other fields, the week day is not always available and
413 so must be accessed using this method as it is computed on demand
416 WeekDay
GetWeekDay();
421 @name Constructors, Assignment Operators and Setters
423 Constructors and various Set() methods are collected here. If you
424 construct a date object from separate values for day, month and year,
425 you should use IsValid() method to check that the values were correct
426 as constructors cannot return an error code.
431 Default constructor. Use one of the Set() functions to initialize the
439 wxDateTime(const wxDateTime
& date
);
444 wxDateTime(time_t timet
);
448 wxDateTime(const struct tm
& tm
);
452 wxDateTime(double jdn
);
456 wxDateTime(wxDateTime_t hour
, wxDateTime_t minute
= 0,
457 wxDateTime_t second
= 0, wxDateTime_t millisec
= 0);
461 wxDateTime(wxDateTime_t day
, Month month
,
462 int year
= Inv_Year
, wxDateTime_t hour
= 0,
463 wxDateTime_t minute
= 0, wxDateTime_t second
= 0,
464 wxDateTime_t millisec
= 0);
467 Same as SetFromMSWSysTime.
470 Input, Windows SYSTEMTIME reference
475 wxDateTime(const struct _SYSTEMTIME
& st
);
479 Reset time to midnight (00:00:00) without changing the date.
481 wxDateTime
& ResetTime();
484 Constructs the object from @a timet value holding the number of seconds
487 If @a timet is invalid, i.e. @code (time_t)-1 @endcode, wxDateTime
488 becomes invalid too, i.e. its IsValid() will return @false.
490 wxDateTime
& Set(time_t timet
);
492 Sets the date and time from the broken down representation in the
493 standard @a tm structure.
495 wxDateTime
& Set(const struct tm
& tm
);
498 Sets the date and time from the broken down representation in the
499 @a wxDateTime::Tm structure.
501 wxDateTime
& Set(const Tm
& tm
);
504 Sets the date from the so-called Julian Day Number.
506 By definition, the Julian Day Number, usually abbreviated as JDN, of a
507 particular instant is the fractional number of days since 12 hours
508 Universal Coordinated Time (Greenwich mean noon) on January 1 of the
509 year -4712 in the Julian proleptic calendar.
511 wxDateTime
& Set(double jdn
);
513 Sets the date to be equal to Today() and the time from supplied
516 wxDateTime
& Set(wxDateTime_t hour
, wxDateTime_t minute
= 0,
517 wxDateTime_t second
= 0, wxDateTime_t millisec
= 0);
519 Sets the date and time from the parameters.
521 wxDateTime
& Set(wxDateTime_t day
, Month month
,
522 int year
= Inv_Year
, wxDateTime_t hour
= 0,
523 wxDateTime_t minute
= 0, wxDateTime_t second
= 0,
524 wxDateTime_t millisec
= 0);
527 Sets the day without changing other date components.
529 wxDateTime
& SetDay(unsigned short day
);
532 Sets the date from the date and time in DOS format.
534 wxDateTime
& SetFromDOS(unsigned long ddt
);
537 Sets the hour without changing other date components.
539 wxDateTime
& SetHour(unsigned short hour
);
542 Sets the millisecond without changing other date components.
544 wxDateTime
& SetMillisecond(unsigned short millisecond
);
547 Sets the minute without changing other date components.
549 wxDateTime
& SetMinute(unsigned short minute
);
552 Sets the month without changing other date components.
554 wxDateTime
& SetMonth(Month month
);
557 Sets the second without changing other date components.
559 wxDateTime
& SetSecond(unsigned short second
);
562 Sets the date and time of to the current values. Same as assigning the
563 result of Now() to this object.
565 wxDateTime
& SetToCurrent();
568 Sets the year without changing other date components.
570 wxDateTime
& SetYear(int year
);
575 wxDateTime
& operator=(time_t timet
);
579 wxDateTime
& operator=(const struct tm
& tm
);
588 Here are the trivial accessors. Other functions, which might have to
589 perform some more complicated calculations to find the answer are under
590 the "Date Arithmetics" section.
595 Returns the date and time in DOS format.
597 unsigned long GetAsDOS() const;
600 Initialize using the Windows SYSTEMTIME structure.
602 Input, Windows SYSTEMTIME reference
607 wxDateTime
& SetFromMSWSysTime(const struct _SYSTEMTIME
& st
);
610 Returns the date and time in the Windows SYSTEMTIME format.
612 Output, pointer to Windows SYSTEMTIME
617 void GetAsMSWSysTime(struct _SYSTEMTIME
* st
) const;
620 Returns the century of this date.
622 int GetCentury(const TimeZone
& tz
= Local
) const;
625 Returns the object having the same date component as this one but time
632 wxDateTime
GetDateOnly() const;
635 Returns the day in the given timezone (local one by default).
637 unsigned short GetDay(const TimeZone
& tz
= Local
) const;
640 Returns the day of the year (in 1-366 range) in the given timezone
641 (local one by default).
643 unsigned short GetDayOfYear(const TimeZone
& tz
= Local
) const;
646 Returns the hour in the given timezone (local one by default).
648 unsigned short GetHour(const TimeZone
& tz
= Local
) const;
651 Returns the milliseconds in the given timezone (local one by default).
653 unsigned short GetMillisecond(const TimeZone
& tz
= Local
) const;
656 Returns the minute in the given timezone (local one by default).
658 unsigned short GetMinute(const TimeZone
& tz
= Local
) const;
661 Returns the month in the given timezone (local one by default).
663 Month
GetMonth(const TimeZone
& tz
= Local
) const;
666 Returns the seconds in the given timezone (local one by default).
668 unsigned short GetSecond(const TimeZone
& tz
= Local
) const;
671 Returns the number of seconds since Jan 1, 1970. An assert failure will
672 occur if the date is not in the range covered by @c time_t type.
674 time_t GetTicks() const;
677 Returns broken down representation of the date and time.
679 Tm
GetTm(const TimeZone
& tz
= Local
) const;
682 Returns the week day in the given timezone (local one by default).
684 WeekDay
GetWeekDay(const TimeZone
& tz
= Local
) const;
687 Returns the ordinal number of the week in the month (in 1-5 range).
689 As GetWeekOfYear(), this function supports both conventions for the
692 wxDateTime_t
GetWeekOfMonth(WeekFlags flags
= Monday_First
,
693 const TimeZone
& tz
= Local
) const;
696 Returns the number of the week of the year this date is in. The first
697 week of the year is, according to international standards, the one
698 containing Jan 4 or, equivalently, the first week which has Thursday in
699 this year. Both of these definitions are the same as saying that the
700 first week of the year must contain more than half of its days in this
701 year. Accordingly, the week number will always be in 1-53 range (52 for
704 The function depends on the week start convention specified by the @a flags
705 argument but its results for @c Sunday_First are not well-defined as the
706 ISO definition quoted above applies to the weeks starting on Monday only.
708 wxDateTime_t
GetWeekOfYear(WeekFlags flags
= Monday_First
,
709 const TimeZone
& tz
= Local
) const;
712 Returns the year in the given timezone (local one by default).
714 int GetYear(const TimeZone
& tz
= Local
) const;
717 Returns @true if the given date is later than the date of adoption of
718 the Gregorian calendar in the given country (and hence the Gregorian
719 calendar calculations make sense for it).
721 bool IsGregorianDate(GregorianAdoption country
= Gr_Standard
) const;
724 Returns @true if the object represents a valid time moment.
726 bool IsValid() const;
729 Returns @true is this day is not a holiday in the given country.
731 bool IsWorkDay(Country country
= Country_Default
) const;
738 @name Date Comparison
740 There are several functions to allow date comparison. To supplement
741 them, a few global operators, etc taking wxDateTime are defined.
746 Returns @true if this date precedes the given one.
748 bool IsEarlierThan(const wxDateTime
& datetime
) const;
751 Returns @true if the two dates are strictly identical.
753 bool IsEqualTo(const wxDateTime
& datetime
) const;
756 Returns @true if the date is equal to another one up to the given time
757 interval, i.e. if the absolute difference between the two dates is less
760 bool IsEqualUpTo(const wxDateTime
& dt
, const wxTimeSpan
& ts
) const;
763 Returns @true if this date is later than the given one.
765 bool IsLaterThan(const wxDateTime
& datetime
) const;
768 Returns @true if the date is the same without comparing the time parts.
770 bool IsSameDate(const wxDateTime
& dt
) const;
773 Returns @true if the time is the same (although dates may differ).
775 bool IsSameTime(const wxDateTime
& dt
) const;
778 Returns @true if this date lies strictly between the two given dates.
782 bool IsStrictlyBetween(const wxDateTime
& t1
,
783 const wxDateTime
& t2
) const;
786 Returns @true if IsStrictlyBetween() is @true or if the date is equal
787 to one of the limit values.
789 @see IsStrictlyBetween()
791 bool IsBetween(const wxDateTime
& t1
, const wxDateTime
& t2
) const;
798 @name Date Arithmetics
800 These functions carry out
801 @ref overview_datetime_arithmetics "arithmetics" on the wxDateTime
802 objects. As explained in the overview, either wxTimeSpan or wxDateSpan
803 may be added to wxDateTime, hence all functions are overloaded to
804 accept both arguments.
806 Also, both Add() and Subtract() have both const and non-const version.
807 The first one returns a new object which represents the sum/difference
808 of the original one with the argument while the second form modifies
809 the object to which it is applied. The operators "-=" and "+=" are
810 defined to be equivalent to the second forms of these functions.
815 Adds the given date span to this object.
817 wxDateTime
Add(const wxDateSpan
& diff
) const;
819 Adds the given date span to this object.
821 wxDateTime
Add(const wxDateSpan
& diff
);
823 Adds the given time span to this object.
825 wxDateTime
Add(const wxTimeSpan
& diff
) const;
827 Adds the given time span to this object.
829 wxDateTime
& Add(const wxTimeSpan
& diff
);
832 Subtracts the given time span from this object.
834 wxDateTime
Subtract(const wxTimeSpan
& diff
) const;
836 Subtracts the given time span from this object.
838 wxDateTime
& Subtract(const wxTimeSpan
& diff
);
840 Subtracts the given date span from this object.
842 wxDateTime
Subtract(const wxDateSpan
& diff
) const;
844 Subtracts the given date span from this object.
846 wxDateTime
& Subtract(const wxDateSpan
& diff
);
848 Subtracts another date from this one and returns the difference between
849 them as a wxTimeSpan.
851 wxTimeSpan
Subtract(const wxDateTime
& dt
) const;
853 Returns the difference between this object and @a dt as a wxDateSpan.
855 This method allows to find the number of entire years, months, weeks and
856 days between @a dt and this date.
860 wxDateSpan
DiffAsDateSpan(const wxDateTime
& dt
) const;
863 Adds the given date span to this object.
865 wxDateTime
& operator+=(const wxDateSpan
& diff
);
867 Subtracts the given date span from this object.
869 wxDateTime
& operator-=(const wxDateSpan
& diff
);
871 Adds the given time span to this object.
873 wxDateTime
& operator+=(const wxTimeSpan
& diff
);
875 Subtracts the given time span from this object.
877 wxDateTime
& operator-=(const wxTimeSpan
& diff
);
884 @name Date Formatting and Parsing
886 See @ref datetime_formatting
891 This function does the same as the standard ANSI C @c strftime(3)
892 function (http://www.cplusplus.com/reference/clibrary/ctime/strftime.html).
893 Please see its description for the meaning of @a format parameter.
895 It also accepts a few wxWidgets-specific extensions: you can optionally
896 specify the width of the field to follow using @c printf(3)-like syntax
897 and the format specification @c "%l" can be used to get the number of
902 wxString
Format(const wxString
& format
= wxDefaultDateTimeFormat
,
903 const TimeZone
& tz
= Local
) const;
906 Identical to calling Format() with @c "%x" argument (which means
907 "preferred date representation for the current locale").
909 wxString
FormatDate() const;
912 Returns the combined date-time representation in the ISO 8601 format
913 @c "YYYY-MM-DDTHH:MM:SS". The @a sep parameter default value produces
914 the result exactly corresponding to the ISO standard, but it can also
915 be useful to use a space as separator if a more human-readable combined
916 date-time representation is needed.
918 @see FormatISODate(), FormatISOTime(), ParseISOCombined()
920 wxString
FormatISOCombined(char sep
= 'T') const;
923 This function returns the date representation in the ISO 8601 format
926 wxString
FormatISODate() const;
929 This function returns the time representation in the ISO 8601 format
932 wxString
FormatISOTime() const;
935 Identical to calling Format() with @c "%X" argument (which means
936 "preferred time representation for the current locale").
938 wxString
FormatTime() const;
941 This function is like ParseDateTime(), but it only allows the date to
944 It is thus less flexible then ParseDateTime(), but also has less
945 chances to misinterpret the user input.
947 See ParseFormat() for the description of function parameters and return
952 bool ParseDate(const wxString
& date
, wxString::const_iterator
*end
);
955 Parses the string @a datetime containing the date and time in free
958 This function tries as hard as it can to interpret the given string as
959 date and time. Unlike ParseRfc822Date(), it will accept anything that
960 may be accepted and will only reject strings which cannot be parsed in
961 any way at all. Notice that the function will fail if either date or
962 time part is present but not both, use ParseDate() or ParseTime() to
963 parse strings containing just the date or time component.
965 See ParseFormat() for the description of function parameters and return
968 bool ParseDateTime(const wxString
& datetime
, wxString::const_iterator
*end
);
971 This function parses the string @a date according to the given
972 @e format. The system @c strptime(3) function is used whenever
973 available, but even if it is not, this function is still implemented,
974 although support for locale-dependent format specifiers such as
975 @c "%c", @c "%x" or @c "%X" may not be perfect and GNU extensions such
976 as @c "%z" and @c "%Z" are not implemented. This function does handle
977 the month and weekday names in the current locale on all platforms,
980 Please see the description of the ANSI C function @c strftime(3) for
981 the syntax of the format string.
983 The @a dateDef parameter is used to fill in the fields which could not
984 be determined from the format string. For example, if the format is
985 @c "%d" (the day of the month), the month and the year are taken from
986 @a dateDef. If it is not specified, Today() is used as the default
989 Example of using this function:
992 wxString str = "...";
993 wxString::const_iterator end;
994 if ( !dt.ParseFormat(str, "%Y-%m-%d", &end) )
995 ... parsing failed ...
996 else if ( end == str.end() )
997 ... entire string parsed ...
999 ... wxString(end, str.end()) left over ...
1003 The string to be parsed.
1005 strptime()-like format string.
1007 Used to fill in the date components not specified in the @a date
1010 Will be filled with the iterator pointing to the location where the
1011 parsing stopped if the function returns @true. If the entire string
1012 was consumed, it is set to @c date.end(). Notice that this argument
1015 @true if at least part of the string was parsed successfully,
1020 bool ParseFormat(const wxString
& date
,
1021 const wxString
& format
,
1022 const wxDateTime
& dateDef
,
1023 wxString::const_iterator
*end
);
1028 bool ParseFormat(const wxString
& date
,
1029 const wxString
& format
,
1030 wxString::const_iterator
*end
);
1035 bool ParseFormat(const wxString
& date
, wxString::const_iterator
*end
);
1038 This function parses the string containing the date and time in ISO
1039 8601 combined format @c "YYYY-MM-DDTHH:MM:SS". The separator between
1040 the date and time parts must be equal to @a sep for the function to
1043 @return @true if the entire string was parsed successfully, @false
1046 bool ParseISOCombined(const wxString
& date
, char sep
= 'T');
1049 This function parses the date in ISO 8601 format @c "YYYY-MM-DD".
1051 @return @true if the entire string was parsed successfully, @false
1054 bool ParseISODate(const wxString
& date
);
1057 This function parses the time in ISO 8601 format @c "HH:MM:SS".
1059 @return @true if the entire string was parsed successfully, @false
1062 bool ParseISOTime(const wxString
& date
);
1065 Parses the string @a date looking for a date formatted according to the
1066 RFC 822 in it. The exact description of this format may, of course, be
1067 found in the RFC (section 5), but, briefly, this is the format used in
1068 the headers of Internet email messages and one of the most common
1069 strings expressing date in this format may be something like
1070 @c "Sat, 18 Dec 1999 00:48:30 +0100".
1072 Returns @NULL if the conversion failed, otherwise return the pointer to
1073 the character immediately following the part of the string which could
1074 be parsed. If the entire string contains only the date in RFC 822
1075 format, the returned pointer will be pointing to a @c NUL character.
1077 This function is intentionally strict, it will return an error for any
1078 string which is not RFC 822 compliant. If you need to parse date
1079 formatted in more free ways, you should use ParseDateTime() or
1080 ParseDate() instead.
1082 See ParseFormat() for the description of function parameters and return
1085 bool ParseRfc822Date(const wxString
& date
, wxString::const_iterator
*end
);
1088 This functions is like ParseDateTime(), but only allows the time to be
1089 specified in the input string.
1091 See ParseFormat() for the description of function parameters and return
1094 bool ParseTime(const wxString
& time
, wxString::const_iterator
*end
);
1101 @name Calendar Calculations
1103 The functions in this section perform the basic calendar calculations,
1104 mostly related to the week days. They allow to find the given week day
1105 in the week with given number (either in the month or in the year) and
1108 None of the functions in this section modify the time part of the
1109 wxDateTime, they only work with the date part of it.
1114 Returns the copy of this object to which SetToLastMonthDay() was
1117 wxDateTime
GetLastMonthDay(Month month
= Inv_Month
,
1118 int year
= Inv_Year
) const;
1121 Returns the copy of this object to which SetToLastWeekDay() was
1124 wxDateTime
GetLastWeekDay(WeekDay weekday
, Month month
= Inv_Month
,
1125 int year
= Inv_Year
);
1128 Returns the copy of this object to which SetToNextWeekDay() was
1131 wxDateTime
GetNextWeekDay(WeekDay weekday
) const;
1134 Returns the copy of this object to which SetToPrevWeekDay() was
1137 wxDateTime
GetPrevWeekDay(WeekDay weekday
) const;
1140 Returns the copy of this object to which SetToWeekDay() was applied.
1142 wxDateTime
GetWeekDay(WeekDay weekday
, int n
= 1, Month month
= Inv_Month
,
1143 int year
= Inv_Year
) const;
1146 Returns the copy of this object to which SetToWeekDayInSameWeek() was
1149 wxDateTime
GetWeekDayInSameWeek(WeekDay weekday
,
1150 WeekFlags flags
= Monday_First
) const;
1153 Returns the copy of this object to which SetToYearDay() was applied.
1155 wxDateTime
GetYearDay(wxDateTime_t yday
) const;
1158 Sets the date to the last day in the specified month (the current one
1161 @return The reference to the modified object itself.
1163 wxDateTime
& SetToLastMonthDay(Month month
= Inv_Month
, int year
= Inv_Year
);
1166 The effect of calling this function is the same as of calling
1167 @c SetToWeekDay(-1, weekday, month, year). The date will be set to the
1168 last @a weekday in the given month and year (the current ones by
1169 default). Always returns @true.
1171 bool SetToLastWeekDay(WeekDay weekday
, Month month
= Inv_Month
,
1172 int year
= Inv_Year
);
1175 Sets the date so that it will be the first @a weekday following the
1178 @return The reference to the modified object itself.
1180 wxDateTime
& SetToNextWeekDay(WeekDay weekday
);
1183 Sets the date so that it will be the last @a weekday before the current
1186 @return The reference to the modified object itself.
1188 wxDateTime
& SetToPrevWeekDay(WeekDay weekday
);
1191 Sets the date to the @e n-th @a weekday in the given month of the given
1192 year (the current month and year are used by default). The parameter
1193 @a n may be either positive (counting from the beginning of the month)
1194 or negative (counting from the end of it).
1196 For example, SetToWeekDay(2, wxDateTime::Wed) will set the date to the
1197 second Wednesday in the current month and
1198 SetToWeekDay(-1, wxDateTime::Sun) will set the date to the last Sunday
1199 in the current month.
1201 @return @true if the date was modified successfully, @false otherwise
1202 meaning that the specified date doesn't exist.
1204 bool SetToWeekDay(WeekDay weekday
, int n
= 1,
1205 Month month
= Inv_Month
, int year
= Inv_Year
);
1208 Adjusts the date so that it will still lie in the same week as before,
1209 but its week day will be the given one.
1211 @return The reference to the modified object itself.
1213 wxDateTime
& SetToWeekDayInSameWeek(WeekDay weekday
,
1214 WeekFlags flags
= Monday_First
);
1217 Sets the date to the day number @a yday in the same year (i.e., unlike
1218 the other functions, this one does not use the current year). The day
1219 number should be in the range 1-366 for the leap years and 1-365 for
1222 @return The reference to the modified object itself.
1224 wxDateTime
& SetToYearDay(wxDateTime_t yday
);
1231 @name Astronomical/Historical Functions
1233 Some degree of support for the date units used in astronomy and/or
1234 history is provided. You can construct a wxDateTime object from a
1235 JDN and you may also get its JDN, MJD or Rata Die number from it.
1237 Related functions in other groups: wxDateTime(double), Set(double)
1242 Synonym for GetJulianDayNumber().
1244 double GetJDN() const;
1247 Returns the JDN corresponding to this date. Beware of rounding errors!
1249 @see GetModifiedJulianDayNumber()
1251 double GetJulianDayNumber() const;
1254 Synonym for GetModifiedJulianDayNumber().
1256 double GetMJD() const;
1259 Returns the @e "Modified Julian Day Number" (MJD) which is, by
1260 definition, is equal to JDN - 2400000.5.
1261 The MJDs are simpler to work with as the integral MJDs correspond to
1262 midnights of the dates in the Gregorian calendar and not the noons like
1263 JDN. The MJD 0 represents Nov 17, 1858.
1265 double GetModifiedJulianDayNumber() const;
1268 Return the @e Rata Die number of this date.
1270 By definition, the Rata Die number is a date specified as the number of
1271 days relative to a base date of December 31 of the year 0. Thus January
1272 1 of the year 1 is Rata Die day 1.
1274 double GetRataDie() const;
1281 @name Time Zone and DST Support
1283 Please see the @ref overview_datetime_timezones "time zone overview"
1284 for more information about time zones. Normally, these functions should
1287 Related functions in other groups: GetBeginDST(), GetEndDST()
1292 Transform the date from the given time zone to the local one. If
1293 @a noDST is @true, no DST adjustments will be made.
1295 @return The date in the local time zone.
1297 wxDateTime
FromTimezone(const TimeZone
& tz
, bool noDST
= false) const;
1300 Returns @true if the DST is applied for this date in the given country.
1302 @see GetBeginDST(), GetEndDST()
1304 int IsDST(Country country
= Country_Default
) const;
1307 Same as FromTimezone() but modifies the object in place.
1309 wxDateTime
& MakeFromTimezone(const TimeZone
& tz
, bool noDST
= false);
1312 Modifies the object in place to represent the date in another time
1313 zone. If @a noDST is @true, no DST adjustments will be made.
1315 wxDateTime
& MakeTimezone(const TimeZone
& tz
, bool noDST
= false);
1318 This is the same as calling MakeTimezone() with the argument @c GMT0.
1320 wxDateTime
& MakeUTC(bool noDST
= false);
1323 Transform the date to the given time zone. If @a noDST is @true, no DST
1324 adjustments will be made.
1326 @return The date in the new time zone.
1328 wxDateTime
ToTimezone(const TimeZone
& tz
, bool noDST
= false) const;
1331 This is the same as calling ToTimezone() with the argument @c GMT0.
1333 wxDateTime
ToUTC(bool noDST
= false) const;
1342 Converts the year in absolute notation (i.e. a number which can be
1343 negative, positive or zero) to the year in BC/AD notation. For the
1344 positive years, nothing is done, but the year 0 is year 1 BC and so for
1345 other years there is a difference of 1.
1347 This function should be used like this:
1351 int y = dt.GetYear();
1352 printf("The year is %d%s", wxDateTime::ConvertYearToBC(y), y > 0 ? "AD" : "BC");
1355 static int ConvertYearToBC(int year
);
1358 Returns the translations of the strings @c AM and @c PM used for time
1359 formatting for the current locale. Either of the pointers may be @NULL
1360 if the corresponding value is not needed.
1362 static void GetAmPmStrings(wxString
* am
, wxString
* pm
);
1365 Get the beginning of DST for the given country in the given year
1366 (current one by default). This function suffers from limitations
1367 described in the @ref overview_datetime_dst "DST overview".
1371 static wxDateTime
GetBeginDST(int year
= Inv_Year
,
1372 Country country
= Country_Default
);
1375 Returns the end of DST for the given country in the given year (current
1380 static wxDateTime
GetEndDST(int year
= Inv_Year
,
1381 Country country
= Country_Default
);
1384 Get the current century, i.e. first two digits of the year, in given
1385 calendar (only Gregorian is currently supported).
1387 static int GetCentury(int year
);
1390 Returns the current default country. The default country is used for
1391 DST calculations, for example.
1395 static Country
GetCountry();
1398 Get the current month in given calendar (only Gregorian is currently
1401 static Month
GetCurrentMonth(Calendar cal
= Gregorian
);
1404 Get the current year in given calendar (only Gregorian is currently
1407 static int GetCurrentYear(Calendar cal
= Gregorian
);
1410 Return the standard English name of the given month.
1412 This function always returns "January" or "Jan" for January, use
1413 GetMonthName() to retrieve the name of the month in the users current
1417 One of wxDateTime::Jan, ..., wxDateTime::Dec values.
1419 Either Name_Full (default) or Name_Abbr.
1421 @see GetEnglishWeekDayName()
1425 static wxString
GetEnglishMonthName(Month month
,
1426 NameFlags flags
= Name_Full
);
1429 Return the standard English name of the given week day.
1431 This function always returns "Monday" or "Mon" for Monday, use
1432 GetWeekDayName() to retrieve the name of the month in the users current
1436 One of wxDateTime::Sun, ..., wxDateTime::Sat values.
1438 Either Name_Full (default) or Name_Abbr.
1440 @see GetEnglishMonthName()
1444 static wxString
GetEnglishWeekDayName(WeekDay weekday
,
1445 NameFlags flags
= Name_Full
);
1448 Gets the full (default) or abbreviated name of the given month.
1450 This function returns the name in the current locale, use
1451 GetEnglishMonthName() to get the untranslated name if necessary.
1454 One of wxDateTime::Jan, ..., wxDateTime::Dec values.
1456 Either Name_Full (default) or Name_Abbr.
1458 @see GetWeekDayName()
1460 static wxString
GetMonthName(Month month
, NameFlags flags
= Name_Full
);
1463 Returns the number of days in the given year. The only supported value
1464 for @a cal currently is @c Gregorian.
1466 static wxDateTime_t
GetNumberOfDays(int year
, Calendar cal
= Gregorian
);
1469 Returns the number of days in the given month of the given year. The
1470 only supported value for @a cal currently is @c Gregorian.
1472 static wxDateTime_t
GetNumberOfDays(Month month
, int year
= Inv_Year
,
1473 Calendar cal
= Gregorian
);
1476 Returns the current time.
1478 static time_t GetTimeNow();
1481 Returns the current time broken down using the buffer whose address is
1482 passed to the function with @a tm to store the result.
1484 static tm
* GetTmNow(struct tm
*tm
);
1487 Returns the current time broken down. Note that this function returns a
1488 pointer to a static buffer that's reused by calls to this function and
1489 certain C library functions (e.g. localtime). If there is any chance
1490 your code might be used in a multi-threaded application, you really
1491 should use GetTmNow(struct tm *) instead.
1493 static tm
* GetTmNow();
1496 Gets the full (default) or abbreviated name of the given week day.
1498 This function returns the name in the current locale, use
1499 GetEnglishWeekDayName() to get the untranslated name if necessary.
1502 One of wxDateTime::Sun, ..., wxDateTime::Sat values.
1504 Either Name_Full (default) or Name_Abbr.
1508 static wxString
GetWeekDayName(WeekDay weekday
,
1509 NameFlags flags
= Name_Full
);
1512 Returns @true if DST was used in the given year (the current one by
1513 default) in the given country.
1515 static bool IsDSTApplicable(int year
= Inv_Year
,
1516 Country country
= Country_Default
);
1519 Returns @true if the @a year is a leap one in the specified calendar.
1520 This functions supports Gregorian and Julian calendars.
1522 static bool IsLeapYear(int year
= Inv_Year
, Calendar cal
= Gregorian
);
1525 This function returns @true if the specified (or default) country is
1526 one of Western European ones. It is used internally by wxDateTime to
1527 determine the DST convention and date and time formatting rules.
1529 static bool IsWestEuropeanCountry(Country country
= Country_Default
);
1532 Returns the object corresponding to the current time.
1537 wxDateTime now = wxDateTime::Now();
1538 printf("Current time in Paris:\t%s\n", now.Format("%c", wxDateTime::CET).c_str());
1541 @note This function is accurate up to seconds. UNow() can be used if
1542 better precision is required.
1546 static wxDateTime
Now();
1549 Sets the country to use by default. This setting influences the DST
1550 calculations, date formatting and other things.
1554 static void SetCountry(Country country
);
1557 Set the date to the given @a weekday in the week number @a numWeek of
1558 the given @a year . The number should be in range 1-53.
1560 Note that the returned date may be in a different year than the one
1561 passed to this function because both the week 1 and week 52 or 53 (for
1562 leap years) contain days from different years. See GetWeekOfYear() for
1563 the explanation of how the year weeks are counted.
1565 static wxDateTime
SetToWeekOfYear(int year
, wxDateTime_t numWeek
,
1566 WeekDay weekday
= Mon
);
1569 Returns the object corresponding to the midnight of the current day
1570 (i.e. the same as Now(), but the time part is set to 0).
1574 static wxDateTime
Today();
1577 Returns the object corresponding to the current UTC time including the
1580 Notice that unlike Now(), this method creates a wxDateTime object
1581 corresponding to UTC, not local, time.
1583 @see Now(), wxGetUTCTimeMillis()
1585 static wxDateTime
UNow();
1589 Global instance of an empty wxDateTime object.
1591 @todo Would it be better to rename this wxNullDateTime so it's consistent
1592 with the rest of the "empty/invalid/null" global objects?
1594 const wxDateTime wxDefaultDateTime
;
1597 wxInvalidDateTime is an alias for wxDefaultDateTime.
1599 #define wxInvalidDateTime wxDefaultDateTime
1603 @class wxDateTimeWorkDays
1605 @todo Write wxDateTimeWorkDays documentation.
1610 class wxDateTimeWorkDays
1621 This class is a "logical time span" and is useful for implementing program
1622 logic for such things as "add one month to the date" which, in general,
1623 doesn't mean to add 60*60*24*31 seconds to it, but to take the same date
1624 the next month (to understand that this is indeed different consider adding
1625 one month to Feb, 15 -- we want to get Mar, 15, of course).
1627 When adding a month to the date, all lesser components (days, hours, ...)
1628 won't be changed unless the resulting date would be invalid: for example,
1629 Jan 31 + 1 month will be Feb 28, not (non-existing) Feb 31.
1631 Because of this feature, adding and subtracting back again the same
1632 wxDateSpan will @b not, in general, give back the original date: Feb 28 - 1
1633 month will be Jan 28, not Jan 31!
1635 wxDateSpan objects can be either positive or negative. They may be
1636 multiplied by scalars which multiply all deltas by the scalar: i.e.
1637 2*(1 month and 1 day) is 2 months and 2 days. They can be added together
1638 with wxDateTime or wxTimeSpan, but the type of result is different for each
1641 @warning If you specify both weeks and days, the total number of days added
1642 will be 7*weeks + days! See also GetTotalDays().
1644 Equality operators are defined for wxDateSpans. Two wxDateSpans are equal
1645 if and only if they both give the same target date when added to @b every
1646 source date. Thus wxDateSpan::Months(1) is not equal to
1647 wxDateSpan::Days(30), because they don't give the same date when added to
1648 Feb 1st. But wxDateSpan::Days(14) is equal to wxDateSpan::Weeks(2).
1650 Finally, notice that for adding hours, minutes and so on you don't need
1651 this class at all: wxTimeSpan will do the job because there are no
1652 subtleties associated with those (we don't support leap seconds).
1657 @see @ref overview_datetime, wxDateTime
1663 Constructs the date span object for the given number of years, months,
1664 weeks and days. Note that the weeks and days add together if both are
1667 wxDateSpan(int years
= 0, int months
= 0, int weeks
= 0, int days
= 0);
1670 Returns the sum of two date spans.
1672 @return A new wxDateSpan object with the result.
1674 wxDateSpan
Add(const wxDateSpan
& other
) const;
1676 Adds the given wxDateSpan to this wxDateSpan and returns a reference
1679 wxDateSpan
& Add(const wxDateSpan
& other
);
1682 Returns a date span object corresponding to one day.
1686 static wxDateSpan
Day();
1689 Returns a date span object corresponding to the given number of days.
1693 static wxDateSpan
Days(int days
);
1696 Returns the number of days (not counting the weeks component) in this
1701 int GetDays() const;
1704 Returns the number of the months (not counting the years) in this date
1707 int GetMonths() const;
1710 Returns the combined number of months in this date span, counting both
1713 @see GetYears(), GetMonths()
1717 int GetTotalMonths() const;
1720 Returns the combined number of days in this date span, counting both
1721 weeks and days. This doesn't take months or years into account.
1723 @see GetWeeks(), GetDays()
1725 int GetTotalDays() const;
1728 Returns the number of weeks in this date span.
1732 int GetWeeks() const;
1735 Returns the number of years in this date span.
1737 int GetYears() const;
1740 Returns a date span object corresponding to one month.
1744 static wxDateSpan
Month();
1747 Returns a date span object corresponding to the given number of months.
1751 static wxDateSpan
Months(int mon
);
1754 Returns the product of the date span by the specified @a factor. The
1755 product is computed by multiplying each of the components by the
1758 @return A new wxDateSpan object with the result.
1760 wxDateSpan
Multiply(int factor
) const;
1762 Multiplies this date span by the specified @a factor. The product is
1763 computed by multiplying each of the components by the @a factor.
1765 @return A reference to this wxDateSpan object modified in place.
1767 wxDateSpan
& Multiply(int factor
);
1770 Changes the sign of this date span.
1777 Returns a date span with the opposite sign.
1781 wxDateSpan
Negate() const;
1784 Sets the number of days (without modifying any other components) in
1787 wxDateSpan
& SetDays(int n
);
1790 Sets the number of months (without modifying any other components) in
1793 wxDateSpan
& SetMonths(int n
);
1796 Sets the number of weeks (without modifying any other components) in
1799 wxDateSpan
& SetWeeks(int n
);
1802 Sets the number of years (without modifying any other components) in
1805 wxDateSpan
& SetYears(int n
);
1808 Returns the difference of two date spans.
1810 @return A new wxDateSpan object with the result.
1812 wxDateSpan
Subtract(const wxDateSpan
& other
) const;
1814 Subtracts the given wxDateSpan to this wxDateSpan and returns a
1815 reference to itself.
1817 wxDateSpan
& Subtract(const wxDateSpan
& other
);
1820 Returns a date span object corresponding to one week.
1824 static wxDateSpan
Week();
1827 Returns a date span object corresponding to the given number of weeks.
1831 static wxDateSpan
Weeks(int weeks
);
1834 Returns a date span object corresponding to one year.
1838 static wxDateSpan
Year();
1841 Returns a date span object corresponding to the given number of years.
1845 static wxDateSpan
Years(int years
);
1848 Adds the given wxDateSpan to this wxDateSpan and returns the result.
1850 wxDateSpan
& operator+=(const wxDateSpan
& other
);
1853 Subtracts the given wxDateSpan to this wxDateSpan and returns the
1856 wxDateSpan
& operator-=(const wxDateSpan
& other
);
1859 Changes the sign of this date span.
1863 wxDateSpan
& operator-();
1866 Multiplies this date span by the specified @a factor. The product is
1867 computed by multiplying each of the components by the @a factor.
1869 @return A reference to this wxDateSpan object modified in place.
1871 wxDateSpan
& operator*=(int factor
);
1874 Returns @true if this date span is different from the other one.
1876 bool operator!=(const wxDateSpan
& other
) const;
1879 Returns @true if this date span is equal to the other one. Two date
1880 spans are considered equal if and only if they have the same number of
1881 years and months and the same total number of days (counting both days
1884 bool operator==(const wxDateSpan
& other
) const;
1892 wxTimeSpan class represents a time interval.
1897 @see @ref overview_datetime, wxDateTime
1903 Default constructor, constructs a zero timespan.
1907 Constructs timespan from separate values for each component, with the
1908 date set to 0. Hours are not restricted to 0-24 range, neither are
1909 minutes, seconds or milliseconds.
1911 wxTimeSpan(long hours
, long min
= 0, wxLongLong sec
= 0, wxLongLong msec
= 0);
1914 Returns the absolute value of the timespan: does not modify the object.
1916 wxTimeSpan
Abs() const;
1919 Returns the sum of two time spans.
1921 @return A new wxDateSpan object with the result.
1923 wxTimeSpan
Add(const wxTimeSpan
& diff
) const;
1925 Adds the given wxTimeSpan to this wxTimeSpan and returns a reference
1928 wxTimeSpan
& Add(const wxTimeSpan
& diff
);
1931 Returns the timespan for one day.
1933 static wxTimeSpan
Day();
1936 Returns the timespan for the given number of days.
1938 static wxTimeSpan
Days(long days
);
1941 Returns the string containing the formatted representation of the time
1942 span. The following format specifiers are allowed after %:
1944 - @c H - Number of Hours
1945 - @c M - Number of Minutes
1946 - @c S - Number of Seconds
1947 - @c l - Number of Milliseconds
1948 - @c D - Number of Days
1949 - @c E - Number of Weeks
1950 - @c % - The percent character
1952 Note that, for example, the number of hours in the description above is
1953 not well defined: it can be either the total number of hours (for
1954 example, for a time span of 50 hours this would be 50) or just the hour
1955 part of the time span, which would be 2 in this case as 50 hours is
1956 equal to 2 days and 2 hours.
1958 wxTimeSpan resolves this ambiguity in the following way: if there had
1959 been, indeed, the @c %D format specified preceding the @c %H, then it
1960 is interpreted as 2. Otherwise, it is 50.
1962 The same applies to all other format specifiers: if they follow a
1963 specifier of larger unit, only the rest part is taken, otherwise the
1966 wxString
Format(const wxString
& format
= wxDefaultTimeSpanFormat
) const;
1969 Returns the difference in number of days.
1971 int GetDays() const;
1974 Returns the difference in number of hours.
1976 int GetHours() const;
1979 Returns the difference in number of milliseconds.
1981 wxLongLong
GetMilliseconds() const;
1984 Returns the difference in number of minutes.
1986 int GetMinutes() const;
1989 Returns the difference in number of seconds.
1991 wxLongLong
GetSeconds() const;
1994 Returns the internal representation of timespan.
1996 wxLongLong
GetValue() const;
1999 Returns the difference in number of weeks.
2001 int GetWeeks() const;
2004 Returns the timespan for one hour.
2006 static wxTimeSpan
Hour();
2009 Returns the timespan for the given number of hours.
2011 static wxTimeSpan
Hours(long hours
);
2014 Returns @true if two timespans are equal.
2016 bool IsEqualTo(const wxTimeSpan
& ts
) const;
2019 Compares two timespans: works with the absolute values, i.e. -2 hours
2020 is longer than 1 hour. Also, it will return @false if the timespans are
2021 equal in absolute value.
2023 bool IsLongerThan(const wxTimeSpan
& ts
) const;
2026 Returns @true if the timespan is negative.
2028 bool IsNegative() const;
2031 Returns @true if the timespan is empty.
2033 bool IsNull() const;
2036 Returns @true if the timespan is positive.
2038 bool IsPositive() const;
2041 Compares two timespans: works with the absolute values, i.e. 1 hour is
2042 shorter than -2 hours. Also, it will return @false if the timespans are
2043 equal in absolute value.
2045 bool IsShorterThan(const wxTimeSpan
& ts
) const;
2048 Returns the timespan for one millisecond.
2050 static wxTimeSpan
Millisecond();
2053 Returns the timespan for the given number of milliseconds.
2055 static wxTimeSpan
Milliseconds(wxLongLong ms
);
2058 Returns the timespan for one minute.
2060 static wxTimeSpan
Minute();
2063 Returns the timespan for the given number of minutes.
2065 static wxTimeSpan
Minutes(long min
);
2068 Returns the product of this time span by @a n.
2070 @return A new wxTimeSpan object with the result.
2072 wxTimeSpan
Multiply(int n
) const;
2074 Multiplies this time span by @a n.
2076 @return A reference to this wxTimeSpan object modified in place.
2078 wxTimeSpan
& Multiply(int n
);
2081 Negate the value of the timespan.
2088 Returns timespan with inverted sign.
2092 wxTimeSpan
Negate() const;
2095 Returns the timespan for one second.
2097 static wxTimeSpan
Second();
2100 Returns the timespan for the given number of seconds.
2102 static wxTimeSpan
Seconds(wxLongLong sec
);
2105 Returns the difference of two time spans.
2107 @return A new wxDateSpan object with the result.
2109 wxTimeSpan
Subtract(const wxTimeSpan
& diff
) const;
2111 Subtracts the given wxTimeSpan to this wxTimeSpan and returns a
2112 reference to itself.
2114 wxTimeSpan
& Subtract(const wxTimeSpan
& diff
);
2117 Returns the timespan for one week.
2119 static wxTimeSpan
Week();
2122 Returns the timespan for the given number of weeks.
2124 static wxTimeSpan
Weeks(long weeks
);
2127 Adds the given wxTimeSpan to this wxTimeSpan and returns the result.
2129 wxTimeSpan
& operator+=(const wxTimeSpan
& diff
);
2132 Multiplies this time span by @a n.
2134 @return A reference to this wxTimeSpan object modified in place.
2136 wxTimeSpan
& operator*=(int n
);
2139 Negate the value of the timespan.
2143 wxTimeSpan
& operator-();
2146 Subtracts the given wxTimeSpan to this wxTimeSpan and returns the
2149 wxTimeSpan
& operator-=(const wxTimeSpan
& diff
);
2155 @class wxDateTimeHolidayAuthority
2157 @todo Write wxDateTimeHolidayAuthority documentation.
2162 class wxDateTimeHolidayAuthority