1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: declarations of time/date related classes (wxDateTime,
5 // Author: Vadim Zeitlin
9 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_DATETIME_H
14 #define _WX_DATETIME_H
23 #include "wx/msw/wince/time.h"
26 #include <limits.h> // for INT_MIN
28 #include "wx/longlong.h"
30 class WXDLLIMPEXP_BASE wxDateTime
;
31 class WXDLLIMPEXP_BASE wxTimeSpan
;
32 class WXDLLIMPEXP_BASE wxDateSpan
;
34 #include "wx/dynarray.h"
36 // not all c-runtimes are based on 1/1/1970 being (time_t) 0
37 // set this to the corresponding value in seconds 1/1/1970 has on your
40 #if defined(__WXMAC__) && !defined(__DARWIN__) && __MSL__ < 0x6000
41 #define WX_TIME_BASE_OFFSET ( 2082844800L + 126144000L )
43 #define WX_TIME_BASE_OFFSET 0
48 * + 1. Time zones with minutes (make TimeZone a class)
49 * ? 2. getdate() function like under Solaris
50 * + 3. text conversion for wxDateSpan
51 * + 4. pluggable modules for the workdays calculations
52 * 5. wxDateTimeHolidayAuthority for Easter and other christian feasts
55 /* Two wrapper functions for thread safety */
56 #ifdef HAVE_LOCALTIME_R
57 #define wxLocaltime_r localtime_r
59 struct tm
*wxLocaltime_r(const time_t*, struct tm
*);
60 #if wxUSE_THREADS && !defined(__WINDOWS__)
61 // On Windows, localtime _is_ threadsafe!
62 #warning using pseudo thread-safe wrapper for localtime to emulate localtime_r
67 #define wxGmtime_r gmtime_r
69 struct tm
*wxGmtime_r(const time_t*, struct tm
*);
70 #if wxUSE_THREADS && !defined(__WINDOWS__)
71 // On Windows, gmtime _is_ threadsafe!
72 #warning using pseudo thread-safe wrapper for gmtime to emulate gmtime_r
77 The three (main) classes declared in this header represent:
79 1. An absolute moment in the time (wxDateTime)
80 2. A difference between two moments in the time, positive or negative
82 3. A logical difference between two dates expressed in
83 years/months/weeks/days (wxDateSpan)
85 The following arithmetic operations are permitted (all others are not):
90 wxDateTime + wxTimeSpan = wxDateTime
91 wxDateTime + wxDateSpan = wxDateTime
92 wxTimeSpan + wxTimeSpan = wxTimeSpan
93 wxDateSpan + wxDateSpan = wxDateSpan
97 wxDateTime - wxDateTime = wxTimeSpan
98 wxDateTime - wxTimeSpan = wxDateTime
99 wxDateTime - wxDateSpan = wxDateTime
100 wxTimeSpan - wxTimeSpan = wxTimeSpan
101 wxDateSpan - wxDateSpan = wxDateSpan
105 wxTimeSpan * number = wxTimeSpan
106 number * wxTimeSpan = wxTimeSpan
107 wxDateSpan * number = wxDateSpan
108 number * wxDateSpan = wxDateSpan
112 -wxTimeSpan = wxTimeSpan
113 -wxDateSpan = wxDateSpan
115 For each binary operation OP (+, -, *) we have the following operatorOP=() as
116 a method and the method with a symbolic name OPER (Add, Subtract, Multiply)
117 as a synonym for it and another const method with the same name which returns
118 the changed copy of the object and operatorOP() as a global function which is
119 implemented in terms of the const version of OPEN. For the unary - we have
120 operator-() as a method, Neg() as synonym for it and Negate() which returns
121 the copy of the object with the changed sign.
124 // an invalid/default date time object which may be used as the default
125 // argument for arguments of type wxDateTime; it is also returned by all
126 // functions returning wxDateTime on failure (this is why it is also called
127 // wxInvalidDateTime)
128 class WXDLLIMPEXP_BASE wxDateTime
;
130 extern WXDLLIMPEXP_DATA_BASE(const wxChar
*) wxDefaultDateTimeFormat
;
131 extern WXDLLIMPEXP_DATA_BASE(const wxChar
*) wxDefaultTimeSpanFormat
;
132 extern WXDLLIMPEXP_DATA_BASE(const wxDateTime
) wxDefaultDateTime
;
134 #define wxInvalidDateTime wxDefaultDateTime
136 // ----------------------------------------------------------------------------
137 // wxDateTime represents an absolute moment in the time
138 // ----------------------------------------------------------------------------
140 class WXDLLIMPEXP_BASE wxDateTime
144 // ------------------------------------------------------------------------
146 // a small unsigned integer type for storing things like minutes,
147 // seconds &c. It should be at least short (i.e. not char) to contain
148 // the number of milliseconds - it may also be 'int' because there is
149 // no size penalty associated with it in our code, we don't store any
150 // data in this format
151 typedef unsigned short wxDateTime_t
;
154 // ------------------------------------------------------------------------
159 // the time in the current time zone
162 // zones from GMT (= Greenwhich Mean Time): they're guaranteed to be
163 // consequent numbers, so writing something like `GMT0 + offset' is
164 // safe if abs(offset) <= 12
166 // underscore stands for minus
167 GMT_12
, GMT_11
, GMT_10
, GMT_9
, GMT_8
, GMT_7
,
168 GMT_6
, GMT_5
, GMT_4
, GMT_3
, GMT_2
, GMT_1
,
170 GMT1
, GMT2
, GMT3
, GMT4
, GMT5
, GMT6
,
171 GMT7
, GMT8
, GMT9
, GMT10
, GMT11
, GMT12
,
172 // Note that GMT12 and GMT_12 are not the same: there is a difference
173 // of exactly one day between them
175 // some symbolic names for TZ
178 WET
= GMT0
, // Western Europe Time
179 WEST
= GMT1
, // Western Europe Summer Time
180 CET
= GMT1
, // Central Europe Time
181 CEST
= GMT2
, // Central Europe Summer Time
182 EET
= GMT2
, // Eastern Europe Time
183 EEST
= GMT3
, // Eastern Europe Summer Time
184 MSK
= GMT3
, // Moscow Time
185 MSD
= GMT4
, // Moscow Summer Time
188 AST
= GMT_4
, // Atlantic Standard Time
189 ADT
= GMT_3
, // Atlantic Daylight Time
190 EST
= GMT_5
, // Eastern Standard Time
191 EDT
= GMT_4
, // Eastern Daylight Saving Time
192 CST
= GMT_6
, // Central Standard Time
193 CDT
= GMT_5
, // Central Daylight Saving Time
194 MST
= GMT_7
, // Mountain Standard Time
195 MDT
= GMT_6
, // Mountain Daylight Saving Time
196 PST
= GMT_8
, // Pacific Standard Time
197 PDT
= GMT_7
, // Pacific Daylight Saving Time
198 HST
= GMT_10
, // Hawaiian Standard Time
199 AKST
= GMT_9
, // Alaska Standard Time
200 AKDT
= GMT_8
, // Alaska Daylight Saving Time
204 A_WST
= GMT8
, // Western Standard Time
205 A_CST
= GMT12
+ 1, // Central Standard Time (+9.5)
206 A_EST
= GMT10
, // Eastern Standard Time
207 A_ESST
= GMT11
, // Eastern Summer Time
209 // TODO add more symbolic timezone names here
211 // Universal Coordinated Time = the new and politically correct name
216 // the calendar systems we know about: notice that it's valid (for
217 // this classes purpose anyhow) to work with any of these calendars
218 // even with the dates before the historical appearance of the
222 Gregorian
, // current calendar
223 Julian
// calendar in use since -45 until the 1582 (or later)
225 // TODO Hebrew, Chinese, Maya, ... (just kidding) (or then may be not?)
228 // these values only are used to identify the different dates of
229 // adoption of the Gregorian calendar (see IsGregorian())
231 // All data and comments taken verbatim from "The Calendar FAQ (v 2.0)"
232 // by Claus Tøndering, http://www.pip.dknet.dk/~c-t/calendar.html
233 // except for the comments "we take".
235 // Symbol "->" should be read as "was followed by" in the comments
237 enum GregorianAdoption
239 Gr_Unknown
, // no data for this country or it's too uncertain to use
240 Gr_Standard
, // on the day 0 of Gregorian calendar: 15 Oct 1582
242 Gr_Alaska
, // Oct 1867 when Alaska became part of the USA
243 Gr_Albania
, // Dec 1912
245 Gr_Austria
= Gr_Unknown
, // Different regions on different dates
246 Gr_Austria_Brixen
, // 5 Oct 1583 -> 16 Oct 1583
247 Gr_Austria_Salzburg
= Gr_Austria_Brixen
,
248 Gr_Austria_Tyrol
= Gr_Austria_Brixen
,
249 Gr_Austria_Carinthia
, // 14 Dec 1583 -> 25 Dec 1583
250 Gr_Austria_Styria
= Gr_Austria_Carinthia
,
252 Gr_Belgium
, // Then part of the Netherlands
254 Gr_Bulgaria
= Gr_Unknown
, // Unknown precisely (from 1915 to 1920)
255 Gr_Bulgaria_1
, // 18 Mar 1916 -> 1 Apr 1916
256 Gr_Bulgaria_2
, // 31 Mar 1916 -> 14 Apr 1916
257 Gr_Bulgaria_3
, // 3 Sep 1920 -> 17 Sep 1920
259 Gr_Canada
= Gr_Unknown
, // Different regions followed the changes in
260 // Great Britain or France
262 Gr_China
= Gr_Unknown
, // Different authorities say:
263 Gr_China_1
, // 18 Dec 1911 -> 1 Jan 1912
264 Gr_China_2
, // 18 Dec 1928 -> 1 Jan 1929
266 Gr_Czechoslovakia
, // (Bohemia and Moravia) 6 Jan 1584 -> 17 Jan 1584
267 Gr_Denmark
, // (including Norway) 18 Feb 1700 -> 1 Mar 1700
270 Gr_Finland
, // Then part of Sweden
272 Gr_France
, // 9 Dec 1582 -> 20 Dec 1582
273 Gr_France_Alsace
, // 4 Feb 1682 -> 16 Feb 1682
274 Gr_France_Lorraine
, // 16 Feb 1760 -> 28 Feb 1760
275 Gr_France_Strasbourg
, // February 1682
277 Gr_Germany
= Gr_Unknown
, // Different states on different dates:
278 Gr_Germany_Catholic
, // 1583-1585 (we take 1584)
279 Gr_Germany_Prussia
, // 22 Aug 1610 -> 2 Sep 1610
280 Gr_Germany_Protestant
, // 18 Feb 1700 -> 1 Mar 1700
282 Gr_GreatBritain
, // 2 Sep 1752 -> 14 Sep 1752 (use 'cal(1)')
284 Gr_Greece
, // 9 Mar 1924 -> 23 Mar 1924
285 Gr_Hungary
, // 21 Oct 1587 -> 1 Nov 1587
286 Gr_Ireland
= Gr_GreatBritain
,
287 Gr_Italy
= Gr_Standard
,
289 Gr_Japan
= Gr_Unknown
, // Different authorities say:
290 Gr_Japan_1
, // 19 Dec 1872 -> 1 Jan 1873
291 Gr_Japan_2
, // 19 Dec 1892 -> 1 Jan 1893
292 Gr_Japan_3
, // 18 Dec 1918 -> 1 Jan 1919
294 Gr_Latvia
, // 1915-1918 (we take 1915)
295 Gr_Lithuania
, // 1915
296 Gr_Luxemburg
, // 14 Dec 1582 -> 25 Dec 1582
297 Gr_Netherlands
= Gr_Belgium
, // (including Belgium) 1 Jan 1583
299 // this is too weird to take into account: the Gregorian calendar was
300 // introduced twice in Groningen, first time 28 Feb 1583 was followed
301 // by 11 Mar 1583, then it has gone back to Julian in the summer of
302 // 1584 and then 13 Dec 1700 -> 12 Jan 1701 - which is
303 // the date we take here
304 Gr_Netherlands_Groningen
, // 13 Dec 1700 -> 12 Jan 1701
305 Gr_Netherlands_Gelderland
, // 30 Jun 1700 -> 12 Jul 1700
306 Gr_Netherlands_Utrecht
, // (and Overijssel) 30 Nov 1700->12 Dec 1700
307 Gr_Netherlands_Friesland
, // (and Drenthe) 31 Dec 1700 -> 12 Jan 1701
309 Gr_Norway
= Gr_Denmark
, // Then part of Denmark
310 Gr_Poland
= Gr_Standard
,
311 Gr_Portugal
= Gr_Standard
,
312 Gr_Romania
, // 31 Mar 1919 -> 14 Apr 1919
313 Gr_Russia
, // 31 Jan 1918 -> 14 Feb 1918
314 Gr_Scotland
= Gr_GreatBritain
,
315 Gr_Spain
= Gr_Standard
,
317 // Sweden has a curious history. Sweden decided to make a gradual
318 // change from the Julian to the Gregorian calendar. By dropping every
319 // leap year from 1700 through 1740 the eleven superfluous days would
320 // be omitted and from 1 Mar 1740 they would be in sync with the
321 // Gregorian calendar. (But in the meantime they would be in sync with
324 // So 1700 (which should have been a leap year in the Julian calendar)
325 // was not a leap year in Sweden. However, by mistake 1704 and 1708
326 // became leap years. This left Sweden out of synchronisation with
327 // both the Julian and the Gregorian world, so they decided to go back
328 // to the Julian calendar. In order to do this, they inserted an extra
329 // day in 1712, making that year a double leap year! So in 1712,
330 // February had 30 days in Sweden.
332 // Later, in 1753, Sweden changed to the Gregorian calendar by
333 // dropping 11 days like everyone else.
334 Gr_Sweden
= Gr_Finland
, // 17 Feb 1753 -> 1 Mar 1753
336 Gr_Switzerland
= Gr_Unknown
,// Different cantons used different dates
337 Gr_Switzerland_Catholic
, // 1583, 1584 or 1597 (we take 1584)
338 Gr_Switzerland_Protestant
, // 31 Dec 1700 -> 12 Jan 1701
340 Gr_Turkey
, // 1 Jan 1927
341 Gr_USA
= Gr_GreatBritain
,
342 Gr_Wales
= Gr_GreatBritain
,
343 Gr_Yugoslavia
// 1919
346 // the country parameter is used so far for calculating the start and
347 // the end of DST period and for deciding whether the date is a work
350 // TODO move this to intl.h
352 // Required for WinCE
359 Country_Unknown
, // no special information for this country
360 Country_Default
, // set the default country with SetCountry() method
361 // or use the default country with any other
363 // TODO add more countries (for this we must know about DST and/or
364 // holidays for this country)
366 // Western European countries: we assume that they all follow the same
367 // DST rules (true or false?)
368 Country_WesternEurope_Start
,
369 Country_EEC
= Country_WesternEurope_Start
,
373 Country_WesternEurope_End
= UK
,
378 // symbolic names for the months
381 Jan
, Feb
, Mar
, Apr
, May
, Jun
, Jul
, Aug
, Sep
, Oct
, Nov
, Dec
, Inv_Month
384 // symbolic names for the weekdays
387 Sun
, Mon
, Tue
, Wed
, Thu
, Fri
, Sat
, Inv_WeekDay
390 // invalid value for the year
393 Inv_Year
= SHRT_MIN
// should hold in wxDateTime_t
396 // flags for GetWeekDayName and GetMonthName
399 Name_Full
= 0x01, // return full name
400 Name_Abbr
= 0x02 // return abbreviated name
403 // flags for GetWeekOfYear and GetWeekOfMonth
406 Default_First
, // Sunday_First for US, Monday_First for the rest
407 Monday_First
, // week starts with a Monday
408 Sunday_First
// week starts with a Sunday
412 // ------------------------------------------------------------------------
414 // a class representing a time zone: basicly, this is just an offset
415 // (in seconds) from GMT
416 class WXDLLIMPEXP_BASE TimeZone
420 TimeZone(wxDateTime_t offset
= 0) { m_offset
= offset
; }
422 long GetOffset() const { return m_offset
; }
425 // offset for this timezone from GMT in seconds
429 // standard struct tm is limited to the years from 1900 (because
430 // tm_year field is the offset from 1900), so we use our own struct
431 // instead to represent broken down time
433 // NB: this struct should always be kept normalized (i.e. mon should
434 // be < 12, 1 <= day <= 31 &c), so use AddMonths(), AddDays()
435 // instead of modifying the member fields directly!
436 struct WXDLLIMPEXP_BASE Tm
438 wxDateTime_t msec
, sec
, min
, hour
, mday
;
442 // default ctor inits the object to an invalid value
445 // ctor from struct tm and the timezone
446 Tm(const struct tm
& tm
, const TimeZone
& tz
);
448 // check that the given date/time is valid (in Gregorian calendar)
449 bool IsValid() const;
452 WeekDay
GetWeekDay() // not const because wday may be changed
454 if ( wday
== Inv_WeekDay
)
457 return (WeekDay
)wday
;
460 // add the given number of months to the date keeping it normalized
461 void AddMonths(int monDiff
);
463 // add the given number of months to the date keeping it normalized
464 void AddDays(int dayDiff
);
467 // compute the weekday from other fields
468 void ComputeWeekDay();
470 // the timezone we correspond to
473 // these values can't be accessed directly because they're not always
474 // computed and we calculate them on demand
475 wxDateTime_t wday
, yday
;
479 // ------------------------------------------------------------------------
481 // set the current country
482 static void SetCountry(Country country
);
483 // get the current country
484 static Country
GetCountry();
486 // return true if the country is a West European one (in practice,
487 // this means that the same DST rules as for EEC apply)
488 static bool IsWestEuropeanCountry(Country country
= Country_Default
);
490 // return the current year
491 static int GetCurrentYear(Calendar cal
= Gregorian
);
493 // convert the year as returned by wxDateTime::GetYear() to a year
494 // suitable for BC/AD notation. The difference is that BC year 1
495 // corresponds to the year 0 (while BC year 0 didn't exist) and AD
496 // year N is just year N.
497 static int ConvertYearToBC(int year
);
499 // return the current month
500 static Month
GetCurrentMonth(Calendar cal
= Gregorian
);
502 // returns true if the given year is a leap year in the given calendar
503 static bool IsLeapYear(int year
= Inv_Year
, Calendar cal
= Gregorian
);
505 // get the century (19 for 1999, 20 for 2000 and -5 for 492 BC)
506 static int GetCentury(int year
= Inv_Year
);
508 // returns the number of days in this year (356 or 355 for Gregorian
509 // calendar usually :-)
510 static wxDateTime_t
GetNumberOfDays(int year
, Calendar cal
= Gregorian
);
512 // get the number of the days in the given month (default value for
513 // the year means the current one)
514 static wxDateTime_t
GetNumberOfDays(Month month
,
516 Calendar cal
= Gregorian
);
518 // get the full (default) or abbreviated month name in the current
519 // locale, returns empty string on error
520 static wxString
GetMonthName(Month month
,
521 NameFlags flags
= Name_Full
);
523 // get the full (default) or abbreviated weekday name in the current
524 // locale, returns empty string on error
525 static wxString
GetWeekDayName(WeekDay weekday
,
526 NameFlags flags
= Name_Full
);
528 // get the AM and PM strings in the current locale (may be empty)
529 static void GetAmPmStrings(wxString
*am
, wxString
*pm
);
531 // return true if the given country uses DST for this year
532 static bool IsDSTApplicable(int year
= Inv_Year
,
533 Country country
= Country_Default
);
535 // get the beginning of DST for this year, will return invalid object
536 // if no DST applicable in this year. The default value of the
537 // parameter means to take the current year.
538 static wxDateTime
GetBeginDST(int year
= Inv_Year
,
539 Country country
= Country_Default
);
540 // get the end of DST for this year, will return invalid object
541 // if no DST applicable in this year. The default value of the
542 // parameter means to take the current year.
543 static wxDateTime
GetEndDST(int year
= Inv_Year
,
544 Country country
= Country_Default
);
546 // return the wxDateTime object for the current time
547 static inline wxDateTime
Now();
549 // return the wxDateTime object for the current time with millisecond
550 // precision (if available on this platform)
551 static wxDateTime
UNow();
553 // return the wxDateTime object for today midnight: i.e. as Now() but
554 // with time set to 0
555 static inline wxDateTime
Today();
557 // constructors: you should test whether the constructor succeeded with
558 // IsValid() function. The values Inv_Month and Inv_Year for the
559 // parameters mean take current month and/or year values.
560 // ------------------------------------------------------------------------
562 // default ctor does not initialize the object, use Set()!
563 wxDateTime() { m_time
= wxLongLong((long)ULONG_MAX
, ULONG_MAX
); }
565 // from time_t: seconds since the Epoch 00:00:00 UTC, Jan 1, 1970)
566 #if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400))
567 // VA C++ confuses this with wxDateTime(double jdn) thinking it is a duplicate declaration
568 inline wxDateTime(time_t timet
);
570 // from broken down time/date (only for standard Unix range)
571 inline wxDateTime(const struct tm
& tm
);
572 // from broken down time/date (any range)
573 inline wxDateTime(const Tm
& tm
);
575 // from JDN (beware of rounding errors)
576 inline wxDateTime(double jdn
);
578 // from separate values for each component, date set to today
579 inline wxDateTime(wxDateTime_t hour
,
580 wxDateTime_t minute
= 0,
581 wxDateTime_t second
= 0,
582 wxDateTime_t millisec
= 0);
583 // from separate values for each component with explicit date
584 inline wxDateTime(wxDateTime_t day
, // day of the month
586 int year
= Inv_Year
, // 1999, not 99 please!
587 wxDateTime_t hour
= 0,
588 wxDateTime_t minute
= 0,
589 wxDateTime_t second
= 0,
590 wxDateTime_t millisec
= 0);
592 // default copy ctor ok
596 // assignment operators and Set() functions: all non const methods return
597 // the reference to this object. IsValid() should be used to test whether
598 // the function succeeded.
599 // ------------------------------------------------------------------------
601 // set to the current time
602 inline wxDateTime
& SetToCurrent();
604 #if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400))
605 // VA C++ confuses this with wxDateTime(double jdn) thinking it is a duplicate declaration
606 // set to given time_t value
607 inline wxDateTime
& Set(time_t timet
);
610 // set to given broken down time/date
611 wxDateTime
& Set(const struct tm
& tm
);
613 // set to given broken down time/date
614 inline wxDateTime
& Set(const Tm
& tm
);
616 // set to given JDN (beware of rounding errors)
617 wxDateTime
& Set(double jdn
);
619 // set to given time, date = today
620 wxDateTime
& Set(wxDateTime_t hour
,
621 wxDateTime_t minute
= 0,
622 wxDateTime_t second
= 0,
623 wxDateTime_t millisec
= 0);
625 // from separate values for each component with explicit date
626 // (defaults for month and year are the current values)
627 wxDateTime
& Set(wxDateTime_t day
,
629 int year
= Inv_Year
, // 1999, not 99 please!
630 wxDateTime_t hour
= 0,
631 wxDateTime_t minute
= 0,
632 wxDateTime_t second
= 0,
633 wxDateTime_t millisec
= 0);
635 // resets time to 00:00:00, doesn't change the date
636 wxDateTime
& ResetTime();
638 // the following functions don't change the values of the other
639 // fields, i.e. SetMinute() won't change either hour or seconds value
642 wxDateTime
& SetYear(int year
);
644 wxDateTime
& SetMonth(Month month
);
645 // set the day of the month
646 wxDateTime
& SetDay(wxDateTime_t day
);
648 wxDateTime
& SetHour(wxDateTime_t hour
);
650 wxDateTime
& SetMinute(wxDateTime_t minute
);
652 wxDateTime
& SetSecond(wxDateTime_t second
);
654 wxDateTime
& SetMillisecond(wxDateTime_t millisecond
);
656 // assignment operator from time_t
657 wxDateTime
& operator=(time_t timet
) { return Set(timet
); }
659 // assignment operator from broken down time/date
660 wxDateTime
& operator=(const struct tm
& tm
) { return Set(tm
); }
662 // assignment operator from broken down time/date
663 wxDateTime
& operator=(const Tm
& tm
) { return Set(tm
); }
665 // default assignment operator is ok
667 // calendar calculations (functions which set the date only leave the time
668 // unchanged, e.g. don't explictly zero it): SetXXX() functions modify the
669 // object itself, GetXXX() ones return a new object.
670 // ------------------------------------------------------------------------
672 // set to the given week day in the same week as this one
673 wxDateTime
& SetToWeekDayInSameWeek(WeekDay weekday
,
674 WeekFlags flags
= Monday_First
);
675 inline wxDateTime
GetWeekDayInSameWeek(WeekDay weekday
,
676 WeekFlags flags
= Monday_First
) const;
678 // set to the next week day following this one
679 wxDateTime
& SetToNextWeekDay(WeekDay weekday
);
680 inline wxDateTime
GetNextWeekDay(WeekDay weekday
) const;
682 // set to the previous week day before this one
683 wxDateTime
& SetToPrevWeekDay(WeekDay weekday
);
684 inline wxDateTime
GetPrevWeekDay(WeekDay weekday
) const;
686 // set to Nth occurence of given weekday in the given month of the
687 // given year (time is set to 0), return true on success and false on
688 // failure. n may be positive (1..5) or negative to count from the end
689 // of the month (see helper function SetToLastWeekDay())
690 bool SetToWeekDay(WeekDay weekday
,
692 Month month
= Inv_Month
,
693 int year
= Inv_Year
);
694 inline wxDateTime
GetWeekDay(WeekDay weekday
,
696 Month month
= Inv_Month
,
697 int year
= Inv_Year
) const;
699 // sets to the last weekday in the given month, year
700 inline bool SetToLastWeekDay(WeekDay weekday
,
701 Month month
= Inv_Month
,
702 int year
= Inv_Year
);
703 inline wxDateTime
GetLastWeekDay(WeekDay weekday
,
704 Month month
= Inv_Month
,
705 int year
= Inv_Year
);
707 // sets the date to the given day of the given week in the year,
708 // returns true on success and false if given date doesn't exist (e.g.
711 // these functions are badly defined as they're not the reverse of
712 // GetWeekOfYear(), use SetToTheWeekOfYear() instead
713 wxDEPRECATED( bool SetToTheWeek(wxDateTime_t numWeek
,
714 WeekDay weekday
= Mon
,
715 WeekFlags flags
= Monday_First
) );
716 wxDEPRECATED( wxDateTime
GetWeek(wxDateTime_t numWeek
,
717 WeekDay weekday
= Mon
,
718 WeekFlags flags
= Monday_First
) const );
720 // returns the date corresponding to the given week day of the given
721 // week (in ISO notation) of the specified year
722 static wxDateTime
SetToWeekOfYear(int year
,
723 wxDateTime_t numWeek
,
724 WeekDay weekday
= Mon
);
726 // sets the date to the last day of the given (or current) month or the
727 // given (or current) year
728 wxDateTime
& SetToLastMonthDay(Month month
= Inv_Month
,
729 int year
= Inv_Year
);
730 inline wxDateTime
GetLastMonthDay(Month month
= Inv_Month
,
731 int year
= Inv_Year
) const;
733 // sets to the given year day (1..365 or 366)
734 wxDateTime
& SetToYearDay(wxDateTime_t yday
);
735 inline wxDateTime
GetYearDay(wxDateTime_t yday
) const;
737 // The definitions below were taken verbatim from
739 // http://www.capecod.net/~pbaum/date/date0.htm
741 // (Peter Baum's home page)
743 // definition: The Julian Day Number, Julian Day, or JD of a
744 // particular instant of time is the number of days and fractions of a
745 // day since 12 hours Universal Time (Greenwich mean noon) on January
746 // 1 of the year -4712, where the year is given in the Julian
747 // proleptic calendar. The idea of using this reference date was
748 // originally proposed by Joseph Scalizer in 1582 to count years but
749 // it was modified by 19th century astronomers to count days. One
750 // could have equivalently defined the reference time to be noon of
751 // November 24, -4713 if were understood that Gregorian calendar rules
752 // were applied. Julian days are Julian Day Numbers and are not to be
753 // confused with Julian dates.
755 // definition: The Rata Die number is a date specified as the number
756 // of days relative to a base date of December 31 of the year 0. Thus
757 // January 1 of the year 1 is Rata Die day 1.
759 // get the Julian Day number (the fractional part specifies the time of
760 // the day, related to noon - beware of rounding errors!)
761 double GetJulianDayNumber() const;
762 double GetJDN() const { return GetJulianDayNumber(); }
764 // get the Modified Julian Day number: it is equal to JDN - 2400000.5
765 // and so integral MJDs correspond to the midnights (and not noons).
766 // MJD 0 is Nov 17, 1858
767 double GetModifiedJulianDayNumber() const { return GetJDN() - 2400000.5; }
768 double GetMJD() const { return GetModifiedJulianDayNumber(); }
770 // get the Rata Die number
771 double GetRataDie() const;
773 // TODO algorithms for calculating some important dates, such as
774 // religious holidays (Easter...) or moon/solar eclipses? Some
775 // algorithms can be found in the calendar FAQ
778 // Timezone stuff: a wxDateTime object constructed using given
779 // day/month/year/hour/min/sec values is interpreted as this moment in
780 // local time. Using the functions below, it may be converted to another
781 // time zone (e.g., the Unix epoch is wxDateTime(1, Jan, 1970).ToGMT()).
783 // These functions try to handle DST internally, but there is no magical
784 // way to know all rules for it in all countries in the world, so if the
785 // program can handle it itself (or doesn't want to handle it at all for
786 // whatever reason), the DST handling can be disabled with noDST.
787 // ------------------------------------------------------------------------
789 // transform to any given timezone
790 inline wxDateTime
ToTimezone(const TimeZone
& tz
, bool noDST
= false) const;
791 wxDateTime
& MakeTimezone(const TimeZone
& tz
, bool noDST
= false);
793 // interpret current value as being in another timezone and transform
795 inline wxDateTime
FromTimezone(const TimeZone
& tz
, bool noDST
= false) const;
796 wxDateTime
& MakeFromTimezone(const TimeZone
& tz
, bool noDST
= false);
798 // transform to/from GMT/UTC
799 wxDateTime
ToUTC(bool noDST
= false) const { return ToTimezone(UTC
, noDST
); }
800 wxDateTime
& MakeUTC(bool noDST
= false) { return MakeTimezone(UTC
, noDST
); }
802 wxDateTime
ToGMT(bool noDST
= false) const { return ToUTC(noDST
); }
803 wxDateTime
& MakeGMT(bool noDST
= false) { return MakeUTC(noDST
); }
805 wxDateTime
FromUTC(bool noDST
= false) const
806 { return FromTimezone(UTC
, noDST
); }
807 wxDateTime
& MakeFromUTC(bool noDST
= false)
808 { return MakeFromTimezone(UTC
, noDST
); }
810 // is daylight savings time in effect at this moment according to the
811 // rules of the specified country?
813 // Return value is > 0 if DST is in effect, 0 if it is not and -1 if
814 // the information is not available (this is compatible with ANSI C)
815 int IsDST(Country country
= Country_Default
) const;
818 // accessors: many of them take the timezone parameter which indicates the
819 // timezone for which to make the calculations and the default value means
820 // to do it for the current timezone of this machine (even if the function
821 // only operates with the date it's necessary because a date may wrap as
822 // result of timezone shift)
823 // ------------------------------------------------------------------------
825 // is the date valid?
826 inline bool IsValid() const { return m_time
!= wxInvalidDateTime
.m_time
; }
828 // get the broken down date/time representation in the given timezone
830 // If you wish to get several time components (day, month and year),
831 // consider getting the whole Tm strcuture first and retrieving the
832 // value from it - this is much more efficient
833 Tm
GetTm(const TimeZone
& tz
= Local
) const;
835 // get the number of seconds since the Unix epoch - returns (time_t)-1
836 // if the value is out of range
837 inline time_t GetTicks() const;
839 // get the year (returns Inv_Year if date is invalid)
840 int GetYear(const TimeZone
& tz
= Local
) const
841 { return GetTm(tz
).year
; }
842 // get the month (Inv_Month if date is invalid)
843 Month
GetMonth(const TimeZone
& tz
= Local
) const
844 { return (Month
)GetTm(tz
).mon
; }
845 // get the month day (in 1..31 range, 0 if date is invalid)
846 wxDateTime_t
GetDay(const TimeZone
& tz
= Local
) const
847 { return GetTm(tz
).mday
; }
848 // get the day of the week (Inv_WeekDay if date is invalid)
849 WeekDay
GetWeekDay(const TimeZone
& tz
= Local
) const
850 { return GetTm(tz
).GetWeekDay(); }
851 // get the hour of the day
852 wxDateTime_t
GetHour(const TimeZone
& tz
= Local
) const
853 { return GetTm(tz
).hour
; }
855 wxDateTime_t
GetMinute(const TimeZone
& tz
= Local
) const
856 { return GetTm(tz
).min
; }
858 wxDateTime_t
GetSecond(const TimeZone
& tz
= Local
) const
859 { return GetTm(tz
).sec
; }
861 wxDateTime_t
GetMillisecond(const TimeZone
& tz
= Local
) const
862 { return GetTm(tz
).msec
; }
864 // get the day since the year start (1..366, 0 if date is invalid)
865 wxDateTime_t
GetDayOfYear(const TimeZone
& tz
= Local
) const;
866 // get the week number since the year start (1..52 or 53, 0 if date is
868 wxDateTime_t
GetWeekOfYear(WeekFlags flags
= Monday_First
,
869 const TimeZone
& tz
= Local
) const;
870 // get the week number since the month start (1..5, 0 if date is
872 wxDateTime_t
GetWeekOfMonth(WeekFlags flags
= Monday_First
,
873 const TimeZone
& tz
= Local
) const;
875 // is this date a work day? This depends on a country, of course,
876 // because the holidays are different in different countries
877 bool IsWorkDay(Country country
= Country_Default
) const;
879 // is this date later than Gregorian calendar introduction for the
880 // given country (see enum GregorianAdoption)?
882 // NB: this function shouldn't be considered as absolute authority in
883 // the matter. Besides, for some countries the exact date of
884 // adoption of the Gregorian calendar is simply unknown.
885 bool IsGregorianDate(GregorianAdoption country
= Gr_Standard
) const;
887 // dos date and time format
888 // ------------------------------------------------------------------------
890 // set from the DOS packed format
891 wxDateTime
& SetFromDOS(unsigned long ddt
);
893 // pack the date in DOS format
894 unsigned long GetAsDOS() const;
896 // comparison (see also functions below for operator versions)
897 // ------------------------------------------------------------------------
899 // returns true if the two moments are strictly identical
900 inline bool IsEqualTo(const wxDateTime
& datetime
) const;
902 // returns true if the date is strictly earlier than the given one
903 inline bool IsEarlierThan(const wxDateTime
& datetime
) const;
905 // returns true if the date is strictly later than the given one
906 inline bool IsLaterThan(const wxDateTime
& datetime
) const;
908 // returns true if the date is strictly in the given range
909 inline bool IsStrictlyBetween(const wxDateTime
& t1
,
910 const wxDateTime
& t2
) const;
912 // returns true if the date is in the given range
913 inline bool IsBetween(const wxDateTime
& t1
, const wxDateTime
& t2
) const;
915 // do these two objects refer to the same date?
916 inline bool IsSameDate(const wxDateTime
& dt
) const;
918 // do these two objects have the same time?
919 inline bool IsSameTime(const wxDateTime
& dt
) const;
921 // are these two objects equal up to given timespan?
922 inline bool IsEqualUpTo(const wxDateTime
& dt
, const wxTimeSpan
& ts
) const;
924 inline bool operator<(const wxDateTime
& dt
) const
926 wxASSERT_MSG( IsValid() && dt
.IsValid(), _T("invalid wxDateTime") );
927 return GetValue() < dt
.GetValue();
930 inline bool operator<=(const wxDateTime
& dt
) const
932 wxASSERT_MSG( IsValid() && dt
.IsValid(), _T("invalid wxDateTime") );
933 return GetValue() <= dt
.GetValue();
936 inline bool operator>(const wxDateTime
& dt
) const
938 wxASSERT_MSG( IsValid() && dt
.IsValid(), _T("invalid wxDateTime") );
939 return GetValue() > dt
.GetValue();
942 inline bool operator>=(const wxDateTime
& dt
) const
944 wxASSERT_MSG( IsValid() && dt
.IsValid(), _T("invalid wxDateTime") );
945 return GetValue() >= dt
.GetValue();
948 inline bool operator==(const wxDateTime
& dt
) const
950 wxASSERT_MSG( IsValid() && dt
.IsValid(), _T("invalid wxDateTime") );
951 return GetValue() == dt
.GetValue();
954 inline bool operator!=(const wxDateTime
& dt
) const
956 wxASSERT_MSG( IsValid() && dt
.IsValid(), _T("invalid wxDateTime") );
957 return GetValue() != dt
.GetValue();
960 // arithmetics with dates (see also below for more operators)
961 // ------------------------------------------------------------------------
963 // return the sum of the date with a time span (positive or negative)
964 inline wxDateTime
Add(const wxTimeSpan
& diff
) const;
965 // add a time span (positive or negative)
966 inline wxDateTime
& Add(const wxTimeSpan
& diff
);
967 // add a time span (positive or negative)
968 inline wxDateTime
& operator+=(const wxTimeSpan
& diff
);
969 inline wxDateTime
operator+(const wxTimeSpan
& ts
) const
971 wxDateTime
dt(*this);
976 // return the difference of the date with a time span
977 inline wxDateTime
Subtract(const wxTimeSpan
& diff
) const;
978 // subtract a time span (positive or negative)
979 inline wxDateTime
& Subtract(const wxTimeSpan
& diff
);
980 // subtract a time span (positive or negative)
981 inline wxDateTime
& operator-=(const wxTimeSpan
& diff
);
982 inline wxDateTime
operator-(const wxTimeSpan
& ts
) const
984 wxDateTime
dt(*this);
989 // return the sum of the date with a date span
990 inline wxDateTime
Add(const wxDateSpan
& diff
) const;
991 // add a date span (positive or negative)
992 wxDateTime
& Add(const wxDateSpan
& diff
);
993 // add a date span (positive or negative)
994 inline wxDateTime
& operator+=(const wxDateSpan
& diff
);
995 inline wxDateTime
operator+(const wxDateSpan
& ds
) const
997 wxDateTime
dt(*this);
1002 // return the difference of the date with a date span
1003 inline wxDateTime
Subtract(const wxDateSpan
& diff
) const;
1004 // subtract a date span (positive or negative)
1005 inline wxDateTime
& Subtract(const wxDateSpan
& diff
);
1006 // subtract a date span (positive or negative)
1007 inline wxDateTime
& operator-=(const wxDateSpan
& diff
);
1008 inline wxDateTime
operator-(const wxDateSpan
& ds
) const
1010 wxDateTime
dt(*this);
1015 // return the difference between two dates
1016 inline wxTimeSpan
Subtract(const wxDateTime
& dt
) const;
1017 inline wxTimeSpan
operator-(const wxDateTime
& dt2
) const;
1019 // conversion to/from text: all conversions from text return the pointer to
1020 // the next character following the date specification (i.e. the one where
1021 // the scan had to stop) or NULL on failure.
1022 // ------------------------------------------------------------------------
1024 // parse a string in RFC 822 format (found e.g. in mail headers and
1025 // having the form "Wed, 10 Feb 1999 19:07:07 +0100")
1026 const wxChar
*ParseRfc822Date(const wxChar
* date
);
1027 // parse a date/time in the given format (see strptime(3)), fill in
1028 // the missing (in the string) fields with the values of dateDef (by
1029 // default, they will not change if they had valid values or will
1030 // default to Today() otherwise)
1031 const wxChar
*ParseFormat(const wxChar
*date
,
1032 const wxChar
*format
= wxDefaultDateTimeFormat
,
1033 const wxDateTime
& dateDef
= wxDefaultDateTime
);
1034 // parse a string containing the date/time in "free" format, this
1035 // function will try to make an educated guess at the string contents
1036 const wxChar
*ParseDateTime(const wxChar
*datetime
);
1037 // parse a string containing the date only in "free" format (less
1038 // flexible than ParseDateTime)
1039 const wxChar
*ParseDate(const wxChar
*date
);
1040 // parse a string containing the time only in "free" format
1041 const wxChar
*ParseTime(const wxChar
*time
);
1043 // this function accepts strftime()-like format string (default
1044 // argument corresponds to the preferred date and time representation
1045 // for the current locale) and returns the string containing the
1046 // resulting text representation
1047 wxString
Format(const wxChar
*format
= wxDefaultDateTimeFormat
,
1048 const TimeZone
& tz
= Local
) const;
1049 // preferred date representation for the current locale
1050 wxString
FormatDate() const { return Format(_T("%x")); }
1051 // preferred time representation for the current locale
1052 wxString
FormatTime() const { return Format(_T("%X")); }
1053 // returns the string representing the date in ISO 8601 format
1055 wxString
FormatISODate() const { return Format(_T("%Y-%m-%d")); }
1056 // returns the string representing the time in ISO 8601 format
1058 wxString
FormatISOTime() const { return Format(_T("%H:%M:%S")); }
1061 // ------------------------------------------------------------------------
1063 // construct from internal representation
1064 wxDateTime(const wxLongLong
& time
) { m_time
= time
; }
1066 // get the internal representation
1067 inline wxLongLong
GetValue() const;
1069 // a helper function to get the current time_t
1070 static time_t GetTimeNow() { return time((time_t *)NULL
); }
1072 // another one to get the current time broken down
1073 static struct tm
*GetTmNow()
1075 time_t t
= GetTimeNow();
1076 return localtime(&t
);
1079 // get current time using thread-safe function
1080 static struct tm
*GetTmNow(struct tm
*tmstruct
);
1083 // the current country - as it's the same for all program objects (unless
1084 // it runs on a _really_ big cluster system :-), this is a static member:
1085 // see SetCountry() and GetCountry()
1086 static Country ms_country
;
1088 // this constant is used to transform a time_t value to the internal
1089 // representation, as time_t is in seconds and we use milliseconds it's
1091 static const long TIME_T_FACTOR
;
1093 // returns true if we fall in range in which we can use standard ANSI C
1095 inline bool IsInStdRange() const;
1097 // the internal representation of the time is the amount of milliseconds
1098 // elapsed since the origin which is set by convention to the UNIX/C epoch
1099 // value: the midnight of January 1, 1970 (UTC)
1103 // ----------------------------------------------------------------------------
1104 // This class contains a difference between 2 wxDateTime values, so it makes
1105 // sense to add it to wxDateTime and it is the result of subtraction of 2
1106 // objects of that class. See also wxDateSpan.
1107 // ----------------------------------------------------------------------------
1109 class WXDLLIMPEXP_BASE wxTimeSpan
1113 // ------------------------------------------------------------------------
1115 // return the timespan for the given number of seconds
1116 static wxTimeSpan
Seconds(long sec
) { return wxTimeSpan(0, 0, sec
); }
1117 static wxTimeSpan
Second() { return Seconds(1); }
1119 // return the timespan for the given number of minutes
1120 static wxTimeSpan
Minutes(long min
) { return wxTimeSpan(0, min
, 0 ); }
1121 static wxTimeSpan
Minute() { return Minutes(1); }
1123 // return the timespan for the given number of hours
1124 static wxTimeSpan
Hours(long hours
) { return wxTimeSpan(hours
, 0, 0); }
1125 static wxTimeSpan
Hour() { return Hours(1); }
1127 // return the timespan for the given number of days
1128 static wxTimeSpan
Days(long days
) { return Hours(24 * days
); }
1129 static wxTimeSpan
Day() { return Days(1); }
1131 // return the timespan for the given number of weeks
1132 static wxTimeSpan
Weeks(long days
) { return Days(7 * days
); }
1133 static wxTimeSpan
Week() { return Weeks(1); }
1135 // default ctor constructs the 0 time span
1138 // from separate values for each component, date set to 0 (hours are
1139 // not restricted to 0..24 range, neither are minutes, seconds or
1141 inline wxTimeSpan(long hours
,
1144 long milliseconds
= 0);
1146 // default copy ctor is ok
1150 // arithmetics with time spans (see also below for more operators)
1151 // ------------------------------------------------------------------------
1153 // return the sum of two timespans
1154 inline wxTimeSpan
Add(const wxTimeSpan
& diff
) const;
1155 // add two timespans together
1156 inline wxTimeSpan
& Add(const wxTimeSpan
& diff
);
1157 // add two timespans together
1158 wxTimeSpan
& operator+=(const wxTimeSpan
& diff
) { return Add(diff
); }
1159 inline wxTimeSpan
operator+(const wxTimeSpan
& ts
) const
1161 return wxTimeSpan(GetValue() + ts
.GetValue());
1164 // return the difference of two timespans
1165 inline wxTimeSpan
Subtract(const wxTimeSpan
& diff
) const;
1166 // subtract another timespan
1167 inline wxTimeSpan
& Subtract(const wxTimeSpan
& diff
);
1168 // subtract another timespan
1169 wxTimeSpan
& operator-=(const wxTimeSpan
& diff
) { return Subtract(diff
); }
1170 inline wxTimeSpan
operator-(const wxTimeSpan
& ts
)
1172 return wxTimeSpan(GetValue() - ts
.GetValue());
1175 // multiply timespan by a scalar
1176 inline wxTimeSpan
Multiply(int n
) const;
1177 // multiply timespan by a scalar
1178 inline wxTimeSpan
& Multiply(int n
);
1179 // multiply timespan by a scalar
1180 wxTimeSpan
& operator*=(int n
) { return Multiply(n
); }
1181 inline wxTimeSpan
operator*(int n
) const
1183 return wxTimeSpan(*this).Multiply(n
);
1186 // return this timespan with opposite sign
1187 wxTimeSpan
Negate() const { return wxTimeSpan(-GetValue()); }
1188 // negate the value of the timespan
1189 wxTimeSpan
& Neg() { m_diff
= -GetValue(); return *this; }
1190 // negate the value of the timespan
1191 wxTimeSpan
& operator-() { return Neg(); }
1193 // return the absolute value of the timespan: does _not_ modify the
1195 inline wxTimeSpan
Abs() const;
1197 // there is intentionally no division because we don't want to
1198 // introduce rounding errors in time calculations
1200 // comparaison (see also operator versions below)
1201 // ------------------------------------------------------------------------
1203 // is the timespan null?
1204 bool IsNull() const { return m_diff
== 0l; }
1205 // returns true if the timespan is null
1206 bool operator!() const { return !IsNull(); }
1208 // is the timespan positive?
1209 bool IsPositive() const { return m_diff
> 0l; }
1211 // is the timespan negative?
1212 bool IsNegative() const { return m_diff
< 0l; }
1214 // are two timespans equal?
1215 inline bool IsEqualTo(const wxTimeSpan
& ts
) const;
1216 // compare two timestamps: works with the absolute values, i.e. -2
1217 // hours is longer than 1 hour. Also, it will return false if the
1218 // timespans are equal in absolute value.
1219 inline bool IsLongerThan(const wxTimeSpan
& ts
) const;
1220 // compare two timestamps: works with the absolute values, i.e. 1
1221 // hour is shorter than -2 hours. Also, it will return false if the
1222 // timespans are equal in absolute value.
1223 bool IsShorterThan(const wxTimeSpan
& t
) const { return !IsLongerThan(t
); }
1225 inline bool operator<(const wxTimeSpan
&ts
) const
1227 return GetValue() < ts
.GetValue();
1230 inline bool operator<=(const wxTimeSpan
&ts
) const
1232 return GetValue() <= ts
.GetValue();
1235 inline bool operator>(const wxTimeSpan
&ts
) const
1237 return GetValue() > ts
.GetValue();
1240 inline bool operator>=(const wxTimeSpan
&ts
) const
1242 return GetValue() >= ts
.GetValue();
1245 inline bool operator==(const wxTimeSpan
&ts
) const
1247 return GetValue() == ts
.GetValue();
1250 inline bool operator!=(const wxTimeSpan
&ts
) const
1252 return GetValue() != ts
.GetValue();
1255 // breaking into days, hours, minutes and seconds
1256 // ------------------------------------------------------------------------
1258 // get the max number of weeks in this timespan
1259 inline int GetWeeks() const;
1260 // get the max number of days in this timespan
1261 inline int GetDays() const;
1262 // get the max number of hours in this timespan
1263 inline int GetHours() const;
1264 // get the max number of minutes in this timespan
1265 inline int GetMinutes() const;
1266 // get the max number of seconds in this timespan
1267 inline wxLongLong
GetSeconds() const;
1268 // get the number of milliseconds in this timespan
1269 wxLongLong
GetMilliseconds() const { return m_diff
; }
1271 // conversion to text
1272 // ------------------------------------------------------------------------
1274 // this function accepts strftime()-like format string (default
1275 // argument corresponds to the preferred date and time representation
1276 // for the current locale) and returns the string containing the
1277 // resulting text representation. Notice that only some of format
1278 // specifiers valid for wxDateTime are valid for wxTimeSpan: hours,
1279 // minutes and seconds make sense, but not "PM/AM" string for example.
1280 wxString
Format(const wxChar
*format
= wxDefaultTimeSpanFormat
) const;
1283 // ------------------------------------------------------------------------
1285 // construct from internal representation
1286 wxTimeSpan(const wxLongLong
& diff
) { m_diff
= diff
; }
1288 // get the internal representation
1289 wxLongLong
GetValue() const { return m_diff
; }
1292 // the (signed) time span in milliseconds
1296 // ----------------------------------------------------------------------------
1297 // This class is a "logical time span" and is useful for implementing program
1298 // logic for such things as "add one month to the date" which, in general,
1299 // doesn't mean to add 60*60*24*31 seconds to it, but to take the same date
1300 // the next month (to understand that this is indeed different consider adding
1301 // one month to Feb, 15 - we want to get Mar, 15, of course).
1303 // When adding a month to the date, all lesser components (days, hours, ...)
1304 // won't be changed unless the resulting date would be invalid: for example,
1305 // Jan 31 + 1 month will be Feb 28, not (non existing) Feb 31.
1307 // Because of this feature, adding and subtracting back again the same
1308 // wxDateSpan will *not*, in general give back the original date: Feb 28 - 1
1309 // month will be Jan 28, not Jan 31!
1311 // wxDateSpan can be either positive or negative. They may be
1312 // multiplied by scalars which multiply all deltas by the scalar: i.e. 2*(1
1313 // month and 1 day) is 2 months and 2 days. They can be added together and
1314 // with wxDateTime or wxTimeSpan, but the type of result is different for each
1317 // Beware about weeks: if you specify both weeks and days, the total number of
1318 // days added will be 7*weeks + days! See also GetTotalDays() function.
1320 // Equality operators are defined for wxDateSpans. Two datespans are equal if
1321 // they both give the same target date when added to *every* source date.
1322 // Thus wxDateSpan::Months(1) is not equal to wxDateSpan::Days(30), because
1323 // they not give the same date when added to 1 Feb. But wxDateSpan::Days(14) is
1324 // equal to wxDateSpan::Weeks(2)
1326 // Finally, notice that for adding hours, minutes &c you don't need this
1327 // class: wxTimeSpan will do the job because there are no subtleties
1328 // associated with those.
1329 // ----------------------------------------------------------------------------
1331 class WXDLLIMPEXP_BASE wxDateSpan
1335 // ------------------------------------------------------------------------
1337 // this many years/months/weeks/days
1338 wxDateSpan(int years
= 0, int months
= 0, int weeks
= 0, int days
= 0)
1346 // get an object for the given number of days
1347 static wxDateSpan
Days(int days
) { return wxDateSpan(0, 0, 0, days
); }
1348 static wxDateSpan
Day() { return Days(1); }
1350 // get an object for the given number of weeks
1351 static wxDateSpan
Weeks(int weeks
) { return wxDateSpan(0, 0, weeks
, 0); }
1352 static wxDateSpan
Week() { return Weeks(1); }
1354 // get an object for the given number of months
1355 static wxDateSpan
Months(int mon
) { return wxDateSpan(0, mon
, 0, 0); }
1356 static wxDateSpan
Month() { return Months(1); }
1358 // get an object for the given number of years
1359 static wxDateSpan
Years(int years
) { return wxDateSpan(years
, 0, 0, 0); }
1360 static wxDateSpan
Year() { return Years(1); }
1362 // default copy ctor is ok
1366 // accessors (all SetXXX() return the (modified) wxDateSpan object)
1367 // ------------------------------------------------------------------------
1369 // set number of years
1370 wxDateSpan
& SetYears(int n
) { m_years
= n
; return *this; }
1371 // set number of months
1372 wxDateSpan
& SetMonths(int n
) { m_months
= n
; return *this; }
1373 // set number of weeks
1374 wxDateSpan
& SetWeeks(int n
) { m_weeks
= n
; return *this; }
1375 // set number of days
1376 wxDateSpan
& SetDays(int n
) { m_days
= n
; return *this; }
1378 // get number of years
1379 int GetYears() const { return m_years
; }
1380 // get number of months
1381 int GetMonths() const { return m_months
; }
1382 // get number of weeks
1383 int GetWeeks() const { return m_weeks
; }
1384 // get number of days
1385 int GetDays() const { return m_days
; }
1386 // returns 7*GetWeeks() + GetDays()
1387 int GetTotalDays() const { return 7*m_weeks
+ m_days
; }
1389 // arithmetics with date spans (see also below for more operators)
1390 // ------------------------------------------------------------------------
1392 // return sum of two date spans
1393 inline wxDateSpan
Add(const wxDateSpan
& other
) const;
1394 // add another wxDateSpan to us
1395 inline wxDateSpan
& Add(const wxDateSpan
& other
);
1396 // add another wxDateSpan to us
1397 inline wxDateSpan
& operator+=(const wxDateSpan
& other
);
1398 inline wxDateSpan
operator+(const wxDateSpan
& ds
) const
1400 return wxDateSpan(GetYears() + ds
.GetYears(),
1401 GetMonths() + ds
.GetMonths(),
1402 GetWeeks() + ds
.GetWeeks(),
1403 GetDays() + ds
.GetDays());
1406 // return difference of two date spans
1407 inline wxDateSpan
Subtract(const wxDateSpan
& other
) const;
1408 // subtract another wxDateSpan from us
1409 inline wxDateSpan
& Subtract(const wxDateSpan
& other
);
1410 // subtract another wxDateSpan from us
1411 inline wxDateSpan
& operator-=(const wxDateSpan
& other
);
1412 inline wxDateSpan
operator-(const wxDateSpan
& ds
) const
1414 return wxDateSpan(GetYears() - ds
.GetYears(),
1415 GetMonths() - ds
.GetMonths(),
1416 GetWeeks() - ds
.GetWeeks(),
1417 GetDays() - ds
.GetDays());
1420 // return a copy of this time span with changed sign
1421 inline wxDateSpan
Negate() const;
1422 // inverse the sign of this timespan
1423 inline wxDateSpan
& Neg();
1424 // inverse the sign of this timespan
1425 wxDateSpan
& operator-() { return Neg(); }
1427 // return the date span proportional to this one with given factor
1428 inline wxDateSpan
Multiply(int factor
) const;
1429 // multiply all components by a (signed) number
1430 inline wxDateSpan
& Multiply(int factor
);
1431 // multiply all components by a (signed) number
1432 inline wxDateSpan
& operator*=(int factor
) { return Multiply(factor
); }
1433 inline wxDateSpan
operator*(int n
) const
1435 return wxDateSpan(*this).Multiply(n
);
1438 // ds1 == d2 if and only if for every wxDateTime t t + ds1 == t + ds2
1439 inline bool operator==(const wxDateSpan
& ds
) const
1441 return GetYears() == ds
.GetYears() &&
1442 GetMonths() == ds
.GetMonths() &&
1443 GetTotalDays() == ds
.GetTotalDays();
1446 inline bool operator!=(const wxDateSpan
& ds
) const
1448 return !(*this == ds
);
1458 // ----------------------------------------------------------------------------
1459 // wxDateTimeArray: array of dates.
1460 // ----------------------------------------------------------------------------
1462 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxDateTime
, wxDateTimeArray
, WXDLLIMPEXP_BASE
);
1464 // ----------------------------------------------------------------------------
1465 // wxDateTimeHolidayAuthority: an object of this class will decide whether a
1466 // given date is a holiday and is used by all functions working with "work
1469 // NB: the base class is an ABC, derived classes must implement the pure
1470 // virtual methods to work with the holidays they correspond to.
1471 // ----------------------------------------------------------------------------
1473 class WXDLLIMPEXP_BASE wxDateTimeHolidayAuthority
;
1474 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxDateTimeHolidayAuthority
*,
1475 wxHolidayAuthoritiesArray
,
1476 class WXDLLIMPEXP_BASE
);
1478 class wxDateTimeHolidaysModule
;
1479 class WXDLLIMPEXP_BASE wxDateTimeHolidayAuthority
1481 friend class wxDateTimeHolidaysModule
;
1483 // returns true if the given date is a holiday
1484 static bool IsHoliday(const wxDateTime
& dt
);
1486 // fills the provided array with all holidays in the given range, returns
1487 // the number of them
1488 static size_t GetHolidaysInRange(const wxDateTime
& dtStart
,
1489 const wxDateTime
& dtEnd
,
1490 wxDateTimeArray
& holidays
);
1492 // clear the list of holiday authorities
1493 static void ClearAllAuthorities();
1495 // add a new holiday authority (the pointer will be deleted by
1496 // wxDateTimeHolidayAuthority)
1497 static void AddAuthority(wxDateTimeHolidayAuthority
*auth
);
1499 // the base class must have a virtual dtor
1500 virtual ~wxDateTimeHolidayAuthority();
1503 // this function is called to determine whether a given day is a holiday
1504 virtual bool DoIsHoliday(const wxDateTime
& dt
) const = 0;
1506 // this function should fill the array with all holidays between the two
1507 // given dates - it is implemented in the base class, but in a very
1508 // inefficient way (it just iterates over all days and uses IsHoliday() for
1509 // each of them), so it must be overridden in the derived class where the
1510 // base class version may be explicitly used if needed
1512 // returns the number of holidays in the given range and fills holidays
1514 virtual size_t DoGetHolidaysInRange(const wxDateTime
& dtStart
,
1515 const wxDateTime
& dtEnd
,
1516 wxDateTimeArray
& holidays
) const = 0;
1519 // all holiday authorities
1520 static wxHolidayAuthoritiesArray ms_authorities
;
1523 // the holidays for this class are all Saturdays and Sundays
1524 class WXDLLIMPEXP_BASE wxDateTimeWorkDays
: public wxDateTimeHolidayAuthority
1527 virtual bool DoIsHoliday(const wxDateTime
& dt
) const;
1528 virtual size_t DoGetHolidaysInRange(const wxDateTime
& dtStart
,
1529 const wxDateTime
& dtEnd
,
1530 wxDateTimeArray
& holidays
) const;
1533 // ============================================================================
1534 // inline functions implementation
1535 // ============================================================================
1537 // ----------------------------------------------------------------------------
1539 // ----------------------------------------------------------------------------
1541 #define MILLISECONDS_PER_DAY 86400000l
1543 // some broken compilers (HP-UX CC) refuse to compile the "normal" version, but
1544 // using a temp variable always might prevent other compilers from optimising
1545 // it away - hence use of this ugly macro
1547 #define MODIFY_AND_RETURN(op) return wxDateTime(*this).op
1549 #define MODIFY_AND_RETURN(op) wxDateTime dt(*this); dt.op; return dt
1552 // ----------------------------------------------------------------------------
1553 // wxDateTime construction
1554 // ----------------------------------------------------------------------------
1556 inline bool wxDateTime::IsInStdRange() const
1558 return m_time
>= 0l && (m_time
/ TIME_T_FACTOR
) < LONG_MAX
;
1562 inline wxDateTime
wxDateTime::Now()
1565 return wxDateTime(*GetTmNow(&tmstruct
));
1569 inline wxDateTime
wxDateTime::Today()
1571 wxDateTime
dt(Now());
1577 #if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400))
1578 inline wxDateTime
& wxDateTime::Set(time_t timet
)
1580 // assign first to avoid long multiplication overflow!
1581 m_time
= timet
- WX_TIME_BASE_OFFSET
;
1582 m_time
*= TIME_T_FACTOR
;
1588 inline wxDateTime
& wxDateTime::SetToCurrent()
1594 #if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400))
1595 inline wxDateTime::wxDateTime(time_t timet
)
1601 inline wxDateTime::wxDateTime(const struct tm
& tm
)
1606 inline wxDateTime::wxDateTime(const Tm
& tm
)
1611 inline wxDateTime::wxDateTime(double jdn
)
1616 inline wxDateTime
& wxDateTime::Set(const Tm
& tm
)
1618 wxASSERT_MSG( tm
.IsValid(), _T("invalid broken down date/time") );
1620 return Set(tm
.mday
, (Month
)tm
.mon
, tm
.year
,
1621 tm
.hour
, tm
.min
, tm
.sec
, tm
.msec
);
1624 inline wxDateTime::wxDateTime(wxDateTime_t hour
,
1625 wxDateTime_t minute
,
1626 wxDateTime_t second
,
1627 wxDateTime_t millisec
)
1629 Set(hour
, minute
, second
, millisec
);
1632 inline wxDateTime::wxDateTime(wxDateTime_t day
,
1636 wxDateTime_t minute
,
1637 wxDateTime_t second
,
1638 wxDateTime_t millisec
)
1640 Set(day
, month
, year
, hour
, minute
, second
, millisec
);
1643 // ----------------------------------------------------------------------------
1644 // wxDateTime accessors
1645 // ----------------------------------------------------------------------------
1647 inline wxLongLong
wxDateTime::GetValue() const
1649 wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
1654 inline time_t wxDateTime::GetTicks() const
1656 wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
1657 if ( !IsInStdRange() )
1662 return (time_t)((m_time
/ (long)TIME_T_FACTOR
).GetLo())+WX_TIME_BASE_OFFSET
;
1665 inline bool wxDateTime::SetToLastWeekDay(WeekDay weekday
,
1669 return SetToWeekDay(weekday
, -1, month
, year
);
1673 wxDateTime::GetWeekDayInSameWeek(WeekDay weekday
,
1674 WeekFlags
WXUNUSED(flags
)) const
1676 MODIFY_AND_RETURN( SetToWeekDayInSameWeek(weekday
) );
1679 inline wxDateTime
wxDateTime::GetNextWeekDay(WeekDay weekday
) const
1681 MODIFY_AND_RETURN( SetToNextWeekDay(weekday
) );
1684 inline wxDateTime
wxDateTime::GetPrevWeekDay(WeekDay weekday
) const
1686 MODIFY_AND_RETURN( SetToPrevWeekDay(weekday
) );
1689 inline wxDateTime
wxDateTime::GetWeekDay(WeekDay weekday
,
1694 wxDateTime
dt(*this);
1696 return dt
.SetToWeekDay(weekday
, n
, month
, year
) ? dt
: wxInvalidDateTime
;
1699 inline wxDateTime
wxDateTime::GetLastWeekDay(WeekDay weekday
,
1703 wxDateTime
dt(*this);
1705 return dt
.SetToLastWeekDay(weekday
, month
, year
) ? dt
: wxInvalidDateTime
;
1708 inline wxDateTime
wxDateTime::GetLastMonthDay(Month month
, int year
) const
1710 MODIFY_AND_RETURN( SetToLastMonthDay(month
, year
) );
1713 inline wxDateTime
wxDateTime::GetYearDay(wxDateTime_t yday
) const
1715 MODIFY_AND_RETURN( SetToYearDay(yday
) );
1718 // ----------------------------------------------------------------------------
1719 // wxDateTime comparison
1720 // ----------------------------------------------------------------------------
1722 inline bool wxDateTime::IsEqualTo(const wxDateTime
& datetime
) const
1724 wxASSERT_MSG( IsValid() && datetime
.IsValid(), _T("invalid wxDateTime"));
1726 return m_time
== datetime
.m_time
;
1729 inline bool wxDateTime::IsEarlierThan(const wxDateTime
& datetime
) const
1731 wxASSERT_MSG( IsValid() && datetime
.IsValid(), _T("invalid wxDateTime"));
1733 return m_time
< datetime
.m_time
;
1736 inline bool wxDateTime::IsLaterThan(const wxDateTime
& datetime
) const
1738 wxASSERT_MSG( IsValid() && datetime
.IsValid(), _T("invalid wxDateTime"));
1740 return m_time
> datetime
.m_time
;
1743 inline bool wxDateTime::IsStrictlyBetween(const wxDateTime
& t1
,
1744 const wxDateTime
& t2
) const
1746 // no need for assert, will be checked by the functions we call
1747 return IsLaterThan(t1
) && IsEarlierThan(t2
);
1750 inline bool wxDateTime::IsBetween(const wxDateTime
& t1
,
1751 const wxDateTime
& t2
) const
1753 // no need for assert, will be checked by the functions we call
1754 return IsEqualTo(t1
) || IsEqualTo(t2
) || IsStrictlyBetween(t1
, t2
);
1757 inline bool wxDateTime::IsSameDate(const wxDateTime
& dt
) const
1762 return tm1
.year
== tm2
.year
&&
1763 tm1
.mon
== tm2
.mon
&&
1764 tm1
.mday
== tm2
.mday
;
1767 inline bool wxDateTime::IsSameTime(const wxDateTime
& dt
) const
1769 // notice that we can't do something like this:
1771 // m_time % MILLISECONDS_PER_DAY == dt.m_time % MILLISECONDS_PER_DAY
1773 // because we have also to deal with (possibly) different DST settings!
1777 return tm1
.hour
== tm2
.hour
&&
1778 tm1
.min
== tm2
.min
&&
1779 tm1
.sec
== tm2
.sec
&&
1780 tm1
.msec
== tm2
.msec
;
1783 inline bool wxDateTime::IsEqualUpTo(const wxDateTime
& dt
,
1784 const wxTimeSpan
& ts
) const
1786 return IsBetween(dt
.Subtract(ts
), dt
.Add(ts
));
1789 // ----------------------------------------------------------------------------
1790 // wxDateTime arithmetics
1791 // ----------------------------------------------------------------------------
1793 inline wxDateTime
wxDateTime::Add(const wxTimeSpan
& diff
) const
1795 wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
1797 return wxDateTime(m_time
+ diff
.GetValue());
1800 inline wxDateTime
& wxDateTime::Add(const wxTimeSpan
& diff
)
1802 wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
1804 m_time
+= diff
.GetValue();
1809 inline wxDateTime
& wxDateTime::operator+=(const wxTimeSpan
& diff
)
1814 inline wxDateTime
wxDateTime::Subtract(const wxTimeSpan
& diff
) const
1816 wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
1818 return wxDateTime(m_time
- diff
.GetValue());
1821 inline wxDateTime
& wxDateTime::Subtract(const wxTimeSpan
& diff
)
1823 wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
1825 m_time
-= diff
.GetValue();
1830 inline wxDateTime
& wxDateTime::operator-=(const wxTimeSpan
& diff
)
1832 return Subtract(diff
);
1835 inline wxTimeSpan
wxDateTime::Subtract(const wxDateTime
& datetime
) const
1837 wxASSERT_MSG( IsValid() && datetime
.IsValid(), _T("invalid wxDateTime"));
1839 return wxTimeSpan(GetValue() - datetime
.GetValue());
1842 inline wxTimeSpan
wxDateTime::operator-(const wxDateTime
& dt2
) const
1844 return this->Subtract(dt2
);
1847 inline wxDateTime
wxDateTime::Add(const wxDateSpan
& diff
) const
1849 return wxDateTime(*this).Add(diff
);
1852 inline wxDateTime
& wxDateTime::Subtract(const wxDateSpan
& diff
)
1854 return Add(diff
.Negate());
1857 inline wxDateTime
wxDateTime::Subtract(const wxDateSpan
& diff
) const
1859 return wxDateTime(*this).Subtract(diff
);
1862 inline wxDateTime
& wxDateTime::operator-=(const wxDateSpan
& diff
)
1864 return Subtract(diff
);
1867 inline wxDateTime
& wxDateTime::operator+=(const wxDateSpan
& diff
)
1872 // ----------------------------------------------------------------------------
1873 // wxDateTime and timezones
1874 // ----------------------------------------------------------------------------
1877 wxDateTime::ToTimezone(const wxDateTime::TimeZone
& tz
, bool noDST
) const
1879 MODIFY_AND_RETURN( MakeTimezone(tz
, noDST
) );
1883 wxDateTime::FromTimezone(const wxDateTime::TimeZone
& tz
, bool noDST
) const
1885 MODIFY_AND_RETURN( MakeFromTimezone(tz
, noDST
) );
1888 // ----------------------------------------------------------------------------
1889 // wxTimeSpan construction
1890 // ----------------------------------------------------------------------------
1892 inline wxTimeSpan::wxTimeSpan(long hours
,
1897 // assign first to avoid precision loss
1904 m_diff
+= milliseconds
;
1907 // ----------------------------------------------------------------------------
1908 // wxTimeSpan accessors
1909 // ----------------------------------------------------------------------------
1911 inline wxLongLong
wxTimeSpan::GetSeconds() const
1913 return m_diff
/ 1000l;
1916 inline int wxTimeSpan::GetMinutes() const
1918 return (GetSeconds() / 60l).GetLo();
1921 inline int wxTimeSpan::GetHours() const
1923 return GetMinutes() / 60;
1926 inline int wxTimeSpan::GetDays() const
1928 return GetHours() / 24;
1931 inline int wxTimeSpan::GetWeeks() const
1933 return GetDays() / 7;
1936 // ----------------------------------------------------------------------------
1937 // wxTimeSpan arithmetics
1938 // ----------------------------------------------------------------------------
1940 inline wxTimeSpan
wxTimeSpan::Add(const wxTimeSpan
& diff
) const
1942 return wxTimeSpan(m_diff
+ diff
.GetValue());
1945 inline wxTimeSpan
& wxTimeSpan::Add(const wxTimeSpan
& diff
)
1947 m_diff
+= diff
.GetValue();
1952 inline wxTimeSpan
wxTimeSpan::Subtract(const wxTimeSpan
& diff
) const
1954 return wxTimeSpan(m_diff
- diff
.GetValue());
1957 inline wxTimeSpan
& wxTimeSpan::Subtract(const wxTimeSpan
& diff
)
1959 m_diff
-= diff
.GetValue();
1964 inline wxTimeSpan
& wxTimeSpan::Multiply(int n
)
1971 inline wxTimeSpan
wxTimeSpan::Multiply(int n
) const
1973 return wxTimeSpan(m_diff
* (long)n
);
1976 inline wxTimeSpan
wxTimeSpan::Abs() const
1978 return wxTimeSpan(GetValue().Abs());
1981 inline bool wxTimeSpan::IsEqualTo(const wxTimeSpan
& ts
) const
1983 return GetValue() == ts
.GetValue();
1986 inline bool wxTimeSpan::IsLongerThan(const wxTimeSpan
& ts
) const
1988 return GetValue().Abs() > ts
.GetValue().Abs();
1991 // ----------------------------------------------------------------------------
1993 // ----------------------------------------------------------------------------
1995 inline wxDateSpan
& wxDateSpan::operator+=(const wxDateSpan
& other
)
1997 m_years
+= other
.m_years
;
1998 m_months
+= other
.m_months
;
1999 m_weeks
+= other
.m_weeks
;
2000 m_days
+= other
.m_days
;
2005 inline wxDateSpan
& wxDateSpan::Add(const wxDateSpan
& other
)
2007 return *this += other
;
2010 inline wxDateSpan
wxDateSpan::Add(const wxDateSpan
& other
) const
2012 wxDateSpan
ds(*this);
2017 inline wxDateSpan
& wxDateSpan::Multiply(int factor
)
2027 inline wxDateSpan
wxDateSpan::Multiply(int factor
) const
2029 wxDateSpan
ds(*this);
2030 ds
.Multiply(factor
);
2034 inline wxDateSpan
wxDateSpan::Negate() const
2036 return wxDateSpan(-m_years
, -m_months
, -m_weeks
, -m_days
);
2039 inline wxDateSpan
& wxDateSpan::Neg()
2042 m_months
= -m_months
;
2049 inline wxDateSpan
& wxDateSpan::operator-=(const wxDateSpan
& other
)
2051 return *this += other
.Negate();
2054 inline wxDateSpan
& wxDateSpan::Subtract(const wxDateSpan
& other
)
2056 return *this -= other
;
2059 inline wxDateSpan
wxDateSpan::Subtract(const wxDateSpan
& other
) const
2061 wxDateSpan
ds(*this);
2066 #undef MILLISECONDS_PER_DAY
2068 #undef MODIFY_AND_RETURN
2070 // ============================================================================
2072 // ============================================================================
2074 // ----------------------------------------------------------------------------
2075 // wxTimeSpan operators
2076 // ----------------------------------------------------------------------------
2078 wxTimeSpan WXDLLIMPEXP_BASE
operator*(int n
, const wxTimeSpan
& ts
);
2080 // ----------------------------------------------------------------------------
2082 // ----------------------------------------------------------------------------
2084 wxDateSpan WXDLLIMPEXP_BASE
operator*(int n
, const wxDateSpan
& ds
);
2086 // ============================================================================
2087 // other helper functions
2088 // ============================================================================
2090 // ----------------------------------------------------------------------------
2091 // iteration helpers: can be used to write a for loop over enum variable like
2093 // for ( m = wxDateTime::Jan; m < wxDateTime::Inv_Month; wxNextMonth(m) )
2094 // ----------------------------------------------------------------------------
2096 WXDLLIMPEXP_BASE
void wxNextMonth(wxDateTime::Month
& m
);
2097 WXDLLIMPEXP_BASE
void wxPrevMonth(wxDateTime::Month
& m
);
2098 WXDLLIMPEXP_BASE
void wxNextWDay(wxDateTime::WeekDay
& wd
);
2099 WXDLLIMPEXP_BASE
void wxPrevWDay(wxDateTime::WeekDay
& wd
);
2101 #endif // wxUSE_DATETIME
2103 #endif // _WX_DATETIME_H