]> git.saurik.com Git - wxWidgets.git/blame - include/wx/datetime.h
remove mentions of wxEVENTS_COMPATIBILITY_2_8
[wxWidgets.git] / include / wx / datetime.h
CommitLineData
0979c962
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/datetime.h
3// Purpose: declarations of time/date related classes (wxDateTime,
4// wxTimeSpan)
5// Author: Vadim Zeitlin
6// Modified by:
7// Created: 10.02.99
8// RCS-ID: $Id$
9// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 10// Licence: wxWindows licence
0979c962
VZ
11/////////////////////////////////////////////////////////////////////////////
12
2f02cb89
VZ
13#ifndef _WX_DATETIME_H
14#define _WX_DATETIME_H
0979c962 15
2b5f62a0
VZ
16#include "wx/defs.h"
17
e421922f
VZ
18#if wxUSE_DATETIME
19
9b4da627
VZ
20#ifdef __WXWINCE__
21 #include "wx/msw/wince/time.h"
22#elif !defined(__WXPALMOS5__)
23 #include <time.h>
24#endif // OS
5e967044 25
b76b015e 26#include <limits.h> // for INT_MIN
0979c962
VZ
27
28#include "wx/longlong.h"
254696bb 29#include "wx/anystr.h"
0979c962 30
b5dbe15d
VS
31class WXDLLIMPEXP_FWD_BASE wxDateTime;
32class WXDLLIMPEXP_FWD_BASE wxTimeSpan;
33class WXDLLIMPEXP_FWD_BASE wxDateSpan;
154014d6
VZ
34#ifdef __WXMSW__
35struct _SYSTEMTIME;
36#endif
0979c962 37
df5168c4 38#include "wx/dynarray.h"
2f02cb89 39
5b781a67
SC
40// not all c-runtimes are based on 1/1/1970 being (time_t) 0
41// set this to the corresponding value in seconds 1/1/1970 has on your
42// systems c-runtime
43
92f89387
SC
44#define WX_TIME_BASE_OFFSET 0
45
0979c962 46/*
f6bcfd97 47 * TODO
0979c962 48 *
299fcbfe 49 * + 1. Time zones with minutes (make TimeZone a class)
4f6aed9c 50 * ? 2. getdate() function like under Solaris
299fcbfe 51 * + 3. text conversion for wxDateSpan
4f6aed9c
VZ
52 * + 4. pluggable modules for the workdays calculations
53 * 5. wxDateTimeHolidayAuthority for Easter and other christian feasts
0979c962
VZ
54 */
55
a452689b
SN
56/* Two wrapper functions for thread safety */
57#ifdef HAVE_LOCALTIME_R
58#define wxLocaltime_r localtime_r
59#else
56560c38 60WXDLLIMPEXP_BASE struct tm *wxLocaltime_r(const time_t*, struct tm*);
740af654 61#if wxUSE_THREADS && !defined(__WINDOWS__) && !defined(__WATCOMC__)
cf44a61c 62 // On Windows, localtime _is_ threadsafe!
a452689b
SN
63#warning using pseudo thread-safe wrapper for localtime to emulate localtime_r
64#endif
cf44a61c 65#endif
a452689b
SN
66
67#ifdef HAVE_GMTIME_R
68#define wxGmtime_r gmtime_r
69#else
56560c38 70WXDLLIMPEXP_BASE struct tm *wxGmtime_r(const time_t*, struct tm*);
740af654 71#if wxUSE_THREADS && !defined(__WINDOWS__) && !defined(__WATCOMC__)
cf44a61c 72 // On Windows, gmtime _is_ threadsafe!
a452689b
SN
73#warning using pseudo thread-safe wrapper for gmtime to emulate gmtime_r
74#endif
cf44a61c 75#endif
a452689b 76
0979c962 77/*
299fcbfe 78 The three (main) classes declared in this header represent:
0979c962
VZ
79
80 1. An absolute moment in the time (wxDateTime)
81 2. A difference between two moments in the time, positive or negative
82 (wxTimeSpan)
83 3. A logical difference between two dates expressed in
84 years/months/weeks/days (wxDateSpan)
85
86 The following arithmetic operations are permitted (all others are not):
87
88 addition
89 --------
90
91 wxDateTime + wxTimeSpan = wxDateTime
92 wxDateTime + wxDateSpan = wxDateTime
93 wxTimeSpan + wxTimeSpan = wxTimeSpan
94 wxDateSpan + wxDateSpan = wxDateSpan
95
f6bcfd97 96 subtraction
0979c962
VZ
97 ------------
98 wxDateTime - wxDateTime = wxTimeSpan
cd0b1709
VZ
99 wxDateTime - wxTimeSpan = wxDateTime
100 wxDateTime - wxDateSpan = wxDateTime
0979c962
VZ
101 wxTimeSpan - wxTimeSpan = wxTimeSpan
102 wxDateSpan - wxDateSpan = wxDateSpan
103
104 multiplication
105 --------------
106 wxTimeSpan * number = wxTimeSpan
cd0b1709 107 number * wxTimeSpan = wxTimeSpan
0979c962 108 wxDateSpan * number = wxDateSpan
cd0b1709 109 number * wxDateSpan = wxDateSpan
0979c962
VZ
110
111 unitary minus
112 -------------
113 -wxTimeSpan = wxTimeSpan
114 -wxDateSpan = wxDateSpan
cd0b1709
VZ
115
116 For each binary operation OP (+, -, *) we have the following operatorOP=() as
f6bcfd97 117 a method and the method with a symbolic name OPER (Add, Subtract, Multiply)
cd0b1709
VZ
118 as a synonym for it and another const method with the same name which returns
119 the changed copy of the object and operatorOP() as a global function which is
120 implemented in terms of the const version of OPEN. For the unary - we have
121 operator-() as a method, Neg() as synonym for it and Negate() which returns
122 the copy of the object with the changed sign.
0979c962
VZ
123*/
124
2ef31e80
VZ
125// an invalid/default date time object which may be used as the default
126// argument for arguments of type wxDateTime; it is also returned by all
127// functions returning wxDateTime on failure (this is why it is also called
128// wxInvalidDateTime)
b5dbe15d 129class WXDLLIMPEXP_FWD_BASE wxDateTime;
2ef31e80 130
71ebd60b
VZ
131extern WXDLLIMPEXP_DATA_BASE(const char *) wxDefaultDateTimeFormat;
132extern WXDLLIMPEXP_DATA_BASE(const char *) wxDefaultTimeSpanFormat;
bddd7a8d 133extern WXDLLIMPEXP_DATA_BASE(const wxDateTime) wxDefaultDateTime;
1aaf88d2 134
2ef31e80
VZ
135#define wxInvalidDateTime wxDefaultDateTime
136
48fd6e9d
FM
137
138// ----------------------------------------------------------------------------
139// conditional compilation
140// ----------------------------------------------------------------------------
141
48fd6e9d
FM
142// everyone has strftime except Win CE unless VC8 is used
143#if !defined(__WXWINCE__) || defined(__VISUALC8__)
144 #define HAVE_STRFTIME
145#endif
146
0979c962 147// ----------------------------------------------------------------------------
cd0b1709 148// wxDateTime represents an absolute moment in the time
0979c962 149// ----------------------------------------------------------------------------
b76b015e 150
bddd7a8d 151class WXDLLIMPEXP_BASE wxDateTime
0979c962
VZ
152{
153public:
154 // types
155 // ------------------------------------------------------------------------
156
cd0b1709
VZ
157 // a small unsigned integer type for storing things like minutes,
158 // seconds &c. It should be at least short (i.e. not char) to contain
159 // the number of milliseconds - it may also be 'int' because there is
160 // no size penalty associated with it in our code, we don't store any
161 // data in this format
0979c962
VZ
162 typedef unsigned short wxDateTime_t;
163
f0f951fa
VZ
164 // constants
165 // ------------------------------------------------------------------------
166
0979c962 167 // the timezones
b76b015e 168 enum TZ
0979c962
VZ
169 {
170 // the time in the current time zone
171 Local,
172
173 // zones from GMT (= Greenwhich Mean Time): they're guaranteed to be
174 // consequent numbers, so writing something like `GMT0 + offset' is
175 // safe if abs(offset) <= 12
176
177 // underscore stands for minus
178 GMT_12, GMT_11, GMT_10, GMT_9, GMT_8, GMT_7,
179 GMT_6, GMT_5, GMT_4, GMT_3, GMT_2, GMT_1,
180 GMT0,
181 GMT1, GMT2, GMT3, GMT4, GMT5, GMT6,
34f90a1c 182 GMT7, GMT8, GMT9, GMT10, GMT11, GMT12, GMT13,
0979c962
VZ
183 // Note that GMT12 and GMT_12 are not the same: there is a difference
184 // of exactly one day between them
185
fcc3d7cb
VZ
186 // some symbolic names for TZ
187
188 // Europe
189 WET = GMT0, // Western Europe Time
190 WEST = GMT1, // Western Europe Summer Time
191 CET = GMT1, // Central Europe Time
192 CEST = GMT2, // Central Europe Summer Time
193 EET = GMT2, // Eastern Europe Time
194 EEST = GMT3, // Eastern Europe Summer Time
195 MSK = GMT3, // Moscow Time
196 MSD = GMT4, // Moscow Summer Time
197
198 // US and Canada
199 AST = GMT_4, // Atlantic Standard Time
200 ADT = GMT_3, // Atlantic Daylight Time
201 EST = GMT_5, // Eastern Standard Time
202 EDT = GMT_4, // Eastern Daylight Saving Time
203 CST = GMT_6, // Central Standard Time
204 CDT = GMT_5, // Central Daylight Saving Time
205 MST = GMT_7, // Mountain Standard Time
206 MDT = GMT_6, // Mountain Daylight Saving Time
207 PST = GMT_8, // Pacific Standard Time
208 PDT = GMT_7, // Pacific Daylight Saving Time
209 HST = GMT_10, // Hawaiian Standard Time
210 AKST = GMT_9, // Alaska Standard Time
211 AKDT = GMT_8, // Alaska Daylight Saving Time
212
213 // Australia
214
215 A_WST = GMT8, // Western Standard Time
34f90a1c 216 A_CST = GMT13 + 1, // Central Standard Time (+9.5)
fcc3d7cb
VZ
217 A_EST = GMT10, // Eastern Standard Time
218 A_ESST = GMT11, // Eastern Summer Time
219
34f90a1c
VZ
220 // New Zealand
221 NZST = GMT12, // Standard Time
222 NZDT = GMT13, // Daylight Saving Time
223
fcc3d7cb
VZ
224 // TODO add more symbolic timezone names here
225
226 // Universal Coordinated Time = the new and politically correct name
227 // for GMT
0979c962 228 UTC = GMT0
0979c962
VZ
229 };
230
231 // the calendar systems we know about: notice that it's valid (for
232 // this classes purpose anyhow) to work with any of these calendars
233 // even with the dates before the historical appearance of the
234 // calendar
235 enum Calendar
236 {
237 Gregorian, // current calendar
238 Julian // calendar in use since -45 until the 1582 (or later)
239
240 // TODO Hebrew, Chinese, Maya, ... (just kidding) (or then may be not?)
241 };
242
243 // these values only are used to identify the different dates of
244 // adoption of the Gregorian calendar (see IsGregorian())
245 //
246 // All data and comments taken verbatim from "The Calendar FAQ (v 2.0)"
48fd6e9d 247 // by Claus T�ndering, http://www.pip.dknet.dk/~c-t/calendar.html
0979c962
VZ
248 // except for the comments "we take".
249 //
250 // Symbol "->" should be read as "was followed by" in the comments
251 // which follow.
252 enum GregorianAdoption
253 {
254 Gr_Unknown, // no data for this country or it's too uncertain to use
255 Gr_Standard, // on the day 0 of Gregorian calendar: 15 Oct 1582
256
257 Gr_Alaska, // Oct 1867 when Alaska became part of the USA
258 Gr_Albania, // Dec 1912
259
260 Gr_Austria = Gr_Unknown, // Different regions on different dates
261 Gr_Austria_Brixen, // 5 Oct 1583 -> 16 Oct 1583
262 Gr_Austria_Salzburg = Gr_Austria_Brixen,
263 Gr_Austria_Tyrol = Gr_Austria_Brixen,
264 Gr_Austria_Carinthia, // 14 Dec 1583 -> 25 Dec 1583
265 Gr_Austria_Styria = Gr_Austria_Carinthia,
266
267 Gr_Belgium, // Then part of the Netherlands
268
269 Gr_Bulgaria = Gr_Unknown, // Unknown precisely (from 1915 to 1920)
270 Gr_Bulgaria_1, // 18 Mar 1916 -> 1 Apr 1916
271 Gr_Bulgaria_2, // 31 Mar 1916 -> 14 Apr 1916
272 Gr_Bulgaria_3, // 3 Sep 1920 -> 17 Sep 1920
273
274 Gr_Canada = Gr_Unknown, // Different regions followed the changes in
275 // Great Britain or France
276
277 Gr_China = Gr_Unknown, // Different authorities say:
278 Gr_China_1, // 18 Dec 1911 -> 1 Jan 1912
279 Gr_China_2, // 18 Dec 1928 -> 1 Jan 1929
280
281 Gr_Czechoslovakia, // (Bohemia and Moravia) 6 Jan 1584 -> 17 Jan 1584
282 Gr_Denmark, // (including Norway) 18 Feb 1700 -> 1 Mar 1700
283 Gr_Egypt, // 1875
284 Gr_Estonia, // 1918
285 Gr_Finland, // Then part of Sweden
286
287 Gr_France, // 9 Dec 1582 -> 20 Dec 1582
288 Gr_France_Alsace, // 4 Feb 1682 -> 16 Feb 1682
289 Gr_France_Lorraine, // 16 Feb 1760 -> 28 Feb 1760
290 Gr_France_Strasbourg, // February 1682
291
292 Gr_Germany = Gr_Unknown, // Different states on different dates:
293 Gr_Germany_Catholic, // 1583-1585 (we take 1584)
294 Gr_Germany_Prussia, // 22 Aug 1610 -> 2 Sep 1610
295 Gr_Germany_Protestant, // 18 Feb 1700 -> 1 Mar 1700
296
297 Gr_GreatBritain, // 2 Sep 1752 -> 14 Sep 1752 (use 'cal(1)')
298
299 Gr_Greece, // 9 Mar 1924 -> 23 Mar 1924
300 Gr_Hungary, // 21 Oct 1587 -> 1 Nov 1587
301 Gr_Ireland = Gr_GreatBritain,
302 Gr_Italy = Gr_Standard,
303
304 Gr_Japan = Gr_Unknown, // Different authorities say:
305 Gr_Japan_1, // 19 Dec 1872 -> 1 Jan 1873
306 Gr_Japan_2, // 19 Dec 1892 -> 1 Jan 1893
307 Gr_Japan_3, // 18 Dec 1918 -> 1 Jan 1919
308
309 Gr_Latvia, // 1915-1918 (we take 1915)
310 Gr_Lithuania, // 1915
311 Gr_Luxemburg, // 14 Dec 1582 -> 25 Dec 1582
312 Gr_Netherlands = Gr_Belgium, // (including Belgium) 1 Jan 1583
313
314 // this is too weird to take into account: the Gregorian calendar was
315 // introduced twice in Groningen, first time 28 Feb 1583 was followed
316 // by 11 Mar 1583, then it has gone back to Julian in the summer of
317 // 1584 and then 13 Dec 1700 -> 12 Jan 1701 - which is
318 // the date we take here
319 Gr_Netherlands_Groningen, // 13 Dec 1700 -> 12 Jan 1701
320 Gr_Netherlands_Gelderland, // 30 Jun 1700 -> 12 Jul 1700
321 Gr_Netherlands_Utrecht, // (and Overijssel) 30 Nov 1700->12 Dec 1700
322 Gr_Netherlands_Friesland, // (and Drenthe) 31 Dec 1700 -> 12 Jan 1701
323
324 Gr_Norway = Gr_Denmark, // Then part of Denmark
325 Gr_Poland = Gr_Standard,
326 Gr_Portugal = Gr_Standard,
327 Gr_Romania, // 31 Mar 1919 -> 14 Apr 1919
328 Gr_Russia, // 31 Jan 1918 -> 14 Feb 1918
329 Gr_Scotland = Gr_GreatBritain,
330 Gr_Spain = Gr_Standard,
331
332 // Sweden has a curious history. Sweden decided to make a gradual
333 // change from the Julian to the Gregorian calendar. By dropping every
334 // leap year from 1700 through 1740 the eleven superfluous days would
335 // be omitted and from 1 Mar 1740 they would be in sync with the
336 // Gregorian calendar. (But in the meantime they would be in sync with
337 // nobody!)
338 //
339 // So 1700 (which should have been a leap year in the Julian calendar)
340 // was not a leap year in Sweden. However, by mistake 1704 and 1708
341 // became leap years. This left Sweden out of synchronisation with
342 // both the Julian and the Gregorian world, so they decided to go back
343 // to the Julian calendar. In order to do this, they inserted an extra
344 // day in 1712, making that year a double leap year! So in 1712,
345 // February had 30 days in Sweden.
346 //
347 // Later, in 1753, Sweden changed to the Gregorian calendar by
348 // dropping 11 days like everyone else.
349 Gr_Sweden = Gr_Finland, // 17 Feb 1753 -> 1 Mar 1753
350
351 Gr_Switzerland = Gr_Unknown,// Different cantons used different dates
352 Gr_Switzerland_Catholic, // 1583, 1584 or 1597 (we take 1584)
353 Gr_Switzerland_Protestant, // 31 Dec 1700 -> 12 Jan 1701
354
355 Gr_Turkey, // 1 Jan 1927
356 Gr_USA = Gr_GreatBritain,
357 Gr_Wales = Gr_GreatBritain,
358 Gr_Yugoslavia // 1919
359 };
360
361 // the country parameter is used so far for calculating the start and
362 // the end of DST period and for deciding whether the date is a work
363 // day or not
364 //
365 // TODO move this to intl.h
5e967044
JS
366
367// Required for WinCE
368#ifdef USA
369#undef USA
370#endif
371
0979c962
VZ
372 enum Country
373 {
374 Country_Unknown, // no special information for this country
375 Country_Default, // set the default country with SetCountry() method
239446b4 376 // or use the default country with any other
0979c962
VZ
377
378 // TODO add more countries (for this we must know about DST and/or
379 // holidays for this country)
239446b4
VZ
380
381 // Western European countries: we assume that they all follow the same
382 // DST rules (true or false?)
383 Country_WesternEurope_Start,
384 Country_EEC = Country_WesternEurope_Start,
0979c962 385 France,
239446b4
VZ
386 Germany,
387 UK,
388 Country_WesternEurope_End = UK,
389
390 Russia,
0979c962
VZ
391 USA
392 };
0979c962
VZ
393 // symbolic names for the months
394 enum Month
395 {
396 Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, Inv_Month
397 };
398
399 // symbolic names for the weekdays
400 enum WeekDay
401 {
402 Sun, Mon, Tue, Wed, Thu, Fri, Sat, Inv_WeekDay
403 };
404
405 // invalid value for the year
406 enum Year
407 {
b76b015e
VZ
408 Inv_Year = SHRT_MIN // should hold in wxDateTime_t
409 };
410
f0f951fa
VZ
411 // flags for GetWeekDayName and GetMonthName
412 enum NameFlags
413 {
414 Name_Full = 0x01, // return full name
415 Name_Abbr = 0x02 // return abbreviated name
416 };
417
9d9b7755
VZ
418 // flags for GetWeekOfYear and GetWeekOfMonth
419 enum WeekFlags
420 {
421 Default_First, // Sunday_First for US, Monday_First for the rest
422 Monday_First, // week starts with a Monday
423 Sunday_First // week starts with a Sunday
424 };
425
b76b015e
VZ
426 // helper classes
427 // ------------------------------------------------------------------------
428
299fcbfe
VZ
429 // a class representing a time zone: basicly, this is just an offset
430 // (in seconds) from GMT
bddd7a8d 431 class WXDLLIMPEXP_BASE TimeZone
299fcbfe
VZ
432 {
433 public:
434 TimeZone(TZ tz);
1cf57808
VZ
435
436 // create time zone object with the given offset
437 TimeZone(long offset = 0) { m_offset = offset; }
438
439 static TimeZone Make(long offset)
440 {
441 TimeZone tz;
442 tz.m_offset = offset;
443 return tz;
444 }
299fcbfe 445
cd0b1709 446 long GetOffset() const { return m_offset; }
299fcbfe
VZ
447
448 private:
449 // offset for this timezone from GMT in seconds
cd0b1709 450 long m_offset;
299fcbfe
VZ
451 };
452
b76b015e
VZ
453 // standard struct tm is limited to the years from 1900 (because
454 // tm_year field is the offset from 1900), so we use our own struct
455 // instead to represent broken down time
fcc3d7cb
VZ
456 //
457 // NB: this struct should always be kept normalized (i.e. mon should
458 // be < 12, 1 <= day <= 31 &c), so use AddMonths(), AddDays()
459 // instead of modifying the member fields directly!
bddd7a8d 460 struct WXDLLIMPEXP_BASE Tm
b76b015e 461 {
e6ec579c 462 wxDateTime_t msec, sec, min, hour, mday;
fcc3d7cb
VZ
463 Month mon;
464 int year;
b76b015e
VZ
465
466 // default ctor inits the object to an invalid value
467 Tm();
468
299fcbfe
VZ
469 // ctor from struct tm and the timezone
470 Tm(const struct tm& tm, const TimeZone& tz);
b76b015e
VZ
471
472 // check that the given date/time is valid (in Gregorian calendar)
473 bool IsValid() const;
474
475 // get the week day
476 WeekDay GetWeekDay() // not const because wday may be changed
477 {
478 if ( wday == Inv_WeekDay )
479 ComputeWeekDay();
480
481 return (WeekDay)wday;
482 }
483
fcc3d7cb 484 // add the given number of months to the date keeping it normalized
e6ec579c 485 void AddMonths(int monDiff);
fcc3d7cb
VZ
486
487 // add the given number of months to the date keeping it normalized
e6ec579c 488 void AddDays(int dayDiff);
fcc3d7cb 489
b76b015e
VZ
490 private:
491 // compute the weekday from other fields
492 void ComputeWeekDay();
493
299fcbfe
VZ
494 // the timezone we correspond to
495 TimeZone m_tz;
496
b76b015e
VZ
497 // these values can't be accessed directly because they're not always
498 // computed and we calculate them on demand
499 wxDateTime_t wday, yday;
500 };
501
0979c962
VZ
502 // static methods
503 // ------------------------------------------------------------------------
504
505 // set the current country
506 static void SetCountry(Country country);
507 // get the current country
239446b4
VZ
508 static Country GetCountry();
509
68379eaf 510 // return true if the country is a West European one (in practice,
239446b4
VZ
511 // this means that the same DST rules as for EEC apply)
512 static bool IsWestEuropeanCountry(Country country = Country_Default);
0979c962
VZ
513
514 // return the current year
515 static int GetCurrentYear(Calendar cal = Gregorian);
516
517 // convert the year as returned by wxDateTime::GetYear() to a year
518 // suitable for BC/AD notation. The difference is that BC year 1
519 // corresponds to the year 0 (while BC year 0 didn't exist) and AD
520 // year N is just year N.
521 static int ConvertYearToBC(int year);
522
523 // return the current month
524 static Month GetCurrentMonth(Calendar cal = Gregorian);
525
68379eaf 526 // returns true if the given year is a leap year in the given calendar
2f02cb89
VZ
527 static bool IsLeapYear(int year = Inv_Year, Calendar cal = Gregorian);
528
529 // get the century (19 for 1999, 20 for 2000 and -5 for 492 BC)
a333edbd 530 static int GetCentury(int year);
0979c962 531
b76b015e
VZ
532 // returns the number of days in this year (356 or 355 for Gregorian
533 // calendar usually :-)
0979c962
VZ
534 static wxDateTime_t GetNumberOfDays(int year, Calendar cal = Gregorian);
535
536 // get the number of the days in the given month (default value for
537 // the year means the current one)
538 static wxDateTime_t GetNumberOfDays(Month month,
539 int year = Inv_Year,
540 Calendar cal = Gregorian);
541
e538985e 542
b76b015e
VZ
543 // get the full (default) or abbreviated month name in the current
544 // locale, returns empty string on error
f0f951fa
VZ
545 static wxString GetMonthName(Month month,
546 NameFlags flags = Name_Full);
0979c962 547
e538985e
VZ
548 // get the standard English full (default) or abbreviated month name
549 static wxString GetEnglishMonthName(Month month,
550 NameFlags flags = Name_Full);
551
b76b015e
VZ
552 // get the full (default) or abbreviated weekday name in the current
553 // locale, returns empty string on error
f0f951fa
VZ
554 static wxString GetWeekDayName(WeekDay weekday,
555 NameFlags flags = Name_Full);
556
e538985e
VZ
557 // get the standard English full (default) or abbreviated weekday name
558 static wxString GetEnglishWeekDayName(WeekDay weekday,
559 NameFlags flags = Name_Full);
560
f0f951fa
VZ
561 // get the AM and PM strings in the current locale (may be empty)
562 static void GetAmPmStrings(wxString *am, wxString *pm);
0979c962 563
68379eaf 564 // return true if the given country uses DST for this year
239446b4
VZ
565 static bool IsDSTApplicable(int year = Inv_Year,
566 Country country = Country_Default);
567
0979c962
VZ
568 // get the beginning of DST for this year, will return invalid object
569 // if no DST applicable in this year. The default value of the
570 // parameter means to take the current year.
239446b4
VZ
571 static wxDateTime GetBeginDST(int year = Inv_Year,
572 Country country = Country_Default);
0979c962
VZ
573 // get the end of DST for this year, will return invalid object
574 // if no DST applicable in this year. The default value of the
575 // parameter means to take the current year.
239446b4
VZ
576 static wxDateTime GetEndDST(int year = Inv_Year,
577 Country country = Country_Default);
0979c962 578
b76b015e
VZ
579 // return the wxDateTime object for the current time
580 static inline wxDateTime Now();
581
f6bcfd97
BP
582 // return the wxDateTime object for the current time with millisecond
583 // precision (if available on this platform)
584 static wxDateTime UNow();
585
cd0b1709
VZ
586 // return the wxDateTime object for today midnight: i.e. as Now() but
587 // with time set to 0
588 static inline wxDateTime Today();
589
0979c962
VZ
590 // constructors: you should test whether the constructor succeeded with
591 // IsValid() function. The values Inv_Month and Inv_Year for the
592 // parameters mean take current month and/or year values.
593 // ------------------------------------------------------------------------
594
595 // default ctor does not initialize the object, use Set()!
4bd53224 596 wxDateTime() { m_time = wxLongLong(wxINT32_MIN, 0); }
0979c962
VZ
597
598 // from time_t: seconds since the Epoch 00:00:00 UTC, Jan 1, 1970)
16ee521a
DW
599#if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400))
600// VA C++ confuses this with wxDateTime(double jdn) thinking it is a duplicate declaration
0979c962 601 inline wxDateTime(time_t timet);
16ee521a 602#endif
b76b015e 603 // from broken down time/date (only for standard Unix range)
0979c962 604 inline wxDateTime(const struct tm& tm);
b76b015e
VZ
605 // from broken down time/date (any range)
606 inline wxDateTime(const Tm& tm);
0979c962 607
e6ec579c
VZ
608 // from JDN (beware of rounding errors)
609 inline wxDateTime(double jdn);
610
0979c962
VZ
611 // from separate values for each component, date set to today
612 inline wxDateTime(wxDateTime_t hour,
613 wxDateTime_t minute = 0,
614 wxDateTime_t second = 0,
615 wxDateTime_t millisec = 0);
616 // from separate values for each component with explicit date
b76b015e 617 inline wxDateTime(wxDateTime_t day, // day of the month
33ac7e6f 618 Month month,
0979c962
VZ
619 int year = Inv_Year, // 1999, not 99 please!
620 wxDateTime_t hour = 0,
621 wxDateTime_t minute = 0,
622 wxDateTime_t second = 0,
623 wxDateTime_t millisec = 0);
154014d6
VZ
624#ifdef __WXMSW__
625 wxDateTime(const struct _SYSTEMTIME& st)
626 {
627 SetFromMSWSysTime(st);
628 }
629#endif
0979c962
VZ
630
631 // default copy ctor ok
632
633 // no dtor
634
635 // assignment operators and Set() functions: all non const methods return
636 // the reference to this object. IsValid() should be used to test whether
637 // the function succeeded.
638 // ------------------------------------------------------------------------
639
640 // set to the current time
641 inline wxDateTime& SetToCurrent();
642
16ee521a
DW
643#if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400))
644// VA C++ confuses this with wxDateTime(double jdn) thinking it is a duplicate declaration
0979c962
VZ
645 // set to given time_t value
646 inline wxDateTime& Set(time_t timet);
16ee521a 647#endif
0979c962
VZ
648
649 // set to given broken down time/date
650 wxDateTime& Set(const struct tm& tm);
651
b76b015e
VZ
652 // set to given broken down time/date
653 inline wxDateTime& Set(const Tm& tm);
654
e6ec579c
VZ
655 // set to given JDN (beware of rounding errors)
656 wxDateTime& Set(double jdn);
657
0979c962
VZ
658 // set to given time, date = today
659 wxDateTime& Set(wxDateTime_t hour,
660 wxDateTime_t minute = 0,
661 wxDateTime_t second = 0,
662 wxDateTime_t millisec = 0);
663
664 // from separate values for each component with explicit date
665 // (defaults for month and year are the current values)
666 wxDateTime& Set(wxDateTime_t day,
33ac7e6f 667 Month month,
0979c962
VZ
668 int year = Inv_Year, // 1999, not 99 please!
669 wxDateTime_t hour = 0,
670 wxDateTime_t minute = 0,
671 wxDateTime_t second = 0,
672 wxDateTime_t millisec = 0);
673
674 // resets time to 00:00:00, doesn't change the date
675 wxDateTime& ResetTime();
676
fb96cf85
VZ
677 // get the date part of this object only, i.e. the object which has the
678 // same date as this one but time of 00:00:00
679 wxDateTime GetDateOnly() const;
fb96cf85 680
0979c962
VZ
681 // the following functions don't change the values of the other
682 // fields, i.e. SetMinute() won't change either hour or seconds value
683
684 // set the year
685 wxDateTime& SetYear(int year);
686 // set the month
687 wxDateTime& SetMonth(Month month);
688 // set the day of the month
689 wxDateTime& SetDay(wxDateTime_t day);
690 // set hour
691 wxDateTime& SetHour(wxDateTime_t hour);
692 // set minute
693 wxDateTime& SetMinute(wxDateTime_t minute);
694 // set second
695 wxDateTime& SetSecond(wxDateTime_t second);
696 // set millisecond
697 wxDateTime& SetMillisecond(wxDateTime_t millisecond);
698
699 // assignment operator from time_t
700 wxDateTime& operator=(time_t timet) { return Set(timet); }
701
702 // assignment operator from broken down time/date
703 wxDateTime& operator=(const struct tm& tm) { return Set(tm); }
704
b76b015e
VZ
705 // assignment operator from broken down time/date
706 wxDateTime& operator=(const Tm& tm) { return Set(tm); }
707
0979c962
VZ
708 // default assignment operator is ok
709
710 // calendar calculations (functions which set the date only leave the time
4f6aed9c
VZ
711 // unchanged, e.g. don't explictly zero it): SetXXX() functions modify the
712 // object itself, GetXXX() ones return a new object.
0979c962
VZ
713 // ------------------------------------------------------------------------
714
cd0b1709 715 // set to the given week day in the same week as this one
2b5f62a0
VZ
716 wxDateTime& SetToWeekDayInSameWeek(WeekDay weekday,
717 WeekFlags flags = Monday_First);
718 inline wxDateTime GetWeekDayInSameWeek(WeekDay weekday,
719 WeekFlags flags = Monday_First) const;
cd0b1709
VZ
720
721 // set to the next week day following this one
722 wxDateTime& SetToNextWeekDay(WeekDay weekday);
4f6aed9c 723 inline wxDateTime GetNextWeekDay(WeekDay weekday) const;
cd0b1709 724
2ef31e80 725 // set to the previous week day before this one
cd0b1709 726 wxDateTime& SetToPrevWeekDay(WeekDay weekday);
4f6aed9c 727 inline wxDateTime GetPrevWeekDay(WeekDay weekday) const;
cd0b1709 728
7929902d 729 // set to Nth occurrence of given weekday in the given month of the
68379eaf 730 // given year (time is set to 0), return true on success and false on
0979c962
VZ
731 // failure. n may be positive (1..5) or negative to count from the end
732 // of the month (see helper function SetToLastWeekDay())
733 bool SetToWeekDay(WeekDay weekday,
734 int n = 1,
2f02cb89 735 Month month = Inv_Month,
0979c962 736 int year = Inv_Year);
4f6aed9c
VZ
737 inline wxDateTime GetWeekDay(WeekDay weekday,
738 int n = 1,
739 Month month = Inv_Month,
740 int year = Inv_Year) const;
0979c962
VZ
741
742 // sets to the last weekday in the given month, year
743 inline bool SetToLastWeekDay(WeekDay weekday,
2f02cb89 744 Month month = Inv_Month,
0979c962 745 int year = Inv_Year);
4f6aed9c
VZ
746 inline wxDateTime GetLastWeekDay(WeekDay weekday,
747 Month month = Inv_Month,
748 int year = Inv_Year);
0979c962 749
ca3e85cf 750#if WXWIN_COMPATIBILITY_2_6
0979c962 751 // sets the date to the given day of the given week in the year,
68379eaf 752 // returns true on success and false if given date doesn't exist (e.g.
0979c962 753 // numWeek is > 53)
4c27e2fa
VZ
754 //
755 // these functions are badly defined as they're not the reverse of
756 // GetWeekOfYear(), use SetToTheWeekOfYear() instead
757 wxDEPRECATED( bool SetToTheWeek(wxDateTime_t numWeek,
758 WeekDay weekday = Mon,
759 WeekFlags flags = Monday_First) );
760 wxDEPRECATED( wxDateTime GetWeek(wxDateTime_t numWeek,
761 WeekDay weekday = Mon,
762 WeekFlags flags = Monday_First) const );
ca3e85cf 763#endif // WXWIN_COMPATIBILITY_2_6
4c27e2fa
VZ
764
765 // returns the date corresponding to the given week day of the given
766 // week (in ISO notation) of the specified year
767 static wxDateTime SetToWeekOfYear(int year,
768 wxDateTime_t numWeek,
769 WeekDay weekday = Mon);
0979c962 770
2f02cb89
VZ
771 // sets the date to the last day of the given (or current) month or the
772 // given (or current) year
773 wxDateTime& SetToLastMonthDay(Month month = Inv_Month,
774 int year = Inv_Year);
4f6aed9c
VZ
775 inline wxDateTime GetLastMonthDay(Month month = Inv_Month,
776 int year = Inv_Year) const;
0979c962 777
f0f951fa
VZ
778 // sets to the given year day (1..365 or 366)
779 wxDateTime& SetToYearDay(wxDateTime_t yday);
4f6aed9c 780 inline wxDateTime GetYearDay(wxDateTime_t yday) const;
f0f951fa 781
0979c962
VZ
782 // The definitions below were taken verbatim from
783 //
784 // http://www.capecod.net/~pbaum/date/date0.htm
785 //
786 // (Peter Baum's home page)
787 //
788 // definition: The Julian Day Number, Julian Day, or JD of a
789 // particular instant of time is the number of days and fractions of a
790 // day since 12 hours Universal Time (Greenwich mean noon) on January
791 // 1 of the year -4712, where the year is given in the Julian
792 // proleptic calendar. The idea of using this reference date was
793 // originally proposed by Joseph Scalizer in 1582 to count years but
794 // it was modified by 19th century astronomers to count days. One
795 // could have equivalently defined the reference time to be noon of
796 // November 24, -4713 if were understood that Gregorian calendar rules
797 // were applied. Julian days are Julian Day Numbers and are not to be
798 // confused with Julian dates.
799 //
800 // definition: The Rata Die number is a date specified as the number
801 // of days relative to a base date of December 31 of the year 0. Thus
802 // January 1 of the year 1 is Rata Die day 1.
803
e6ec579c
VZ
804 // get the Julian Day number (the fractional part specifies the time of
805 // the day, related to noon - beware of rounding errors!)
806 double GetJulianDayNumber() const;
239446b4
VZ
807 double GetJDN() const { return GetJulianDayNumber(); }
808
809 // get the Modified Julian Day number: it is equal to JDN - 2400000.5
810 // and so integral MJDs correspond to the midnights (and not noons).
811 // MJD 0 is Nov 17, 1858
812 double GetModifiedJulianDayNumber() const { return GetJDN() - 2400000.5; }
813 double GetMJD() const { return GetModifiedJulianDayNumber(); }
0979c962
VZ
814
815 // get the Rata Die number
e6ec579c 816 double GetRataDie() const;
0979c962
VZ
817
818 // TODO algorithms for calculating some important dates, such as
819 // religious holidays (Easter...) or moon/solar eclipses? Some
820 // algorithms can be found in the calendar FAQ
821
d26adb9d
VZ
822
823 // Timezone stuff: a wxDateTime object constructed using given
824 // day/month/year/hour/min/sec values is interpreted as this moment in
825 // local time. Using the functions below, it may be converted to another
826 // time zone (e.g., the Unix epoch is wxDateTime(1, Jan, 1970).ToGMT()).
299fcbfe 827 //
d26adb9d 828 // These functions try to handle DST internally, but there is no magical
41acf5c0
VZ
829 // way to know all rules for it in all countries in the world, so if the
830 // program can handle it itself (or doesn't want to handle it at all for
831 // whatever reason), the DST handling can be disabled with noDST.
b76b015e
VZ
832 // ------------------------------------------------------------------------
833
299fcbfe 834 // transform to any given timezone
68379eaf
WS
835 inline wxDateTime ToTimezone(const TimeZone& tz, bool noDST = false) const;
836 wxDateTime& MakeTimezone(const TimeZone& tz, bool noDST = false);
b76b015e 837
d26adb9d
VZ
838 // interpret current value as being in another timezone and transform
839 // it to local one
840 inline wxDateTime FromTimezone(const TimeZone& tz, bool noDST = false) const;
841 wxDateTime& MakeFromTimezone(const TimeZone& tz, bool noDST = false);
d26adb9d
VZ
842
843 // transform to/from GMT/UTC
844 wxDateTime ToUTC(bool noDST = false) const { return ToTimezone(UTC, noDST); }
845 wxDateTime& MakeUTC(bool noDST = false) { return MakeTimezone(UTC, noDST); }
846
847 wxDateTime ToGMT(bool noDST = false) const { return ToUTC(noDST); }
848 wxDateTime& MakeGMT(bool noDST = false) { return MakeUTC(noDST); }
849
d26adb9d
VZ
850 wxDateTime FromUTC(bool noDST = false) const
851 { return FromTimezone(UTC, noDST); }
852 wxDateTime& MakeFromUTC(bool noDST = false)
853 { return MakeFromTimezone(UTC, noDST); }
fcc3d7cb 854
239446b4
VZ
855 // is daylight savings time in effect at this moment according to the
856 // rules of the specified country?
857 //
858 // Return value is > 0 if DST is in effect, 0 if it is not and -1 if
859 // the information is not available (this is compatible with ANSI C)
860 int IsDST(Country country = Country_Default) const;
861
d26adb9d 862
0979c962
VZ
863 // accessors: many of them take the timezone parameter which indicates the
864 // timezone for which to make the calculations and the default value means
865 // to do it for the current timezone of this machine (even if the function
866 // only operates with the date it's necessary because a date may wrap as
867 // result of timezone shift)
868 // ------------------------------------------------------------------------
869
c3302e7e 870 // is the date valid?
384223b3 871 inline bool IsValid() const { return m_time != wxInvalidDateTime.m_time; }
0979c962 872
299fcbfe
VZ
873 // get the broken down date/time representation in the given timezone
874 //
875 // If you wish to get several time components (day, month and year),
876 // consider getting the whole Tm strcuture first and retrieving the
877 // value from it - this is much more efficient
878 Tm GetTm(const TimeZone& tz = Local) const;
b76b015e
VZ
879
880 // get the number of seconds since the Unix epoch - returns (time_t)-1
881 // if the value is out of range
882 inline time_t GetTicks() const;
883
a333edbd
VZ
884 // get the century, same as GetCentury(GetYear())
885 int GetCentury(const TimeZone& tz = Local) const
886 { return GetCentury(GetYear(tz)); }
0979c962 887 // get the year (returns Inv_Year if date is invalid)
16ee521a 888 int GetYear(const TimeZone& tz = Local) const
299fcbfe 889 { return GetTm(tz).year; }
0979c962 890 // get the month (Inv_Month if date is invalid)
16ee521a 891 Month GetMonth(const TimeZone& tz = Local) const
299fcbfe 892 { return (Month)GetTm(tz).mon; }
0979c962 893 // get the month day (in 1..31 range, 0 if date is invalid)
16ee521a 894 wxDateTime_t GetDay(const TimeZone& tz = Local) const
299fcbfe 895 { return GetTm(tz).mday; }
0979c962 896 // get the day of the week (Inv_WeekDay if date is invalid)
16ee521a 897 WeekDay GetWeekDay(const TimeZone& tz = Local) const
299fcbfe 898 { return GetTm(tz).GetWeekDay(); }
0979c962 899 // get the hour of the day
16ee521a 900 wxDateTime_t GetHour(const TimeZone& tz = Local) const
299fcbfe 901 { return GetTm(tz).hour; }
0979c962 902 // get the minute
16ee521a 903 wxDateTime_t GetMinute(const TimeZone& tz = Local) const
299fcbfe 904 { return GetTm(tz).min; }
0979c962 905 // get the second
16ee521a 906 wxDateTime_t GetSecond(const TimeZone& tz = Local) const
299fcbfe 907 { return GetTm(tz).sec; }
0979c962 908 // get milliseconds
16ee521a 909 wxDateTime_t GetMillisecond(const TimeZone& tz = Local) const
299fcbfe 910 { return GetTm(tz).msec; }
0979c962
VZ
911
912 // get the day since the year start (1..366, 0 if date is invalid)
299fcbfe 913 wxDateTime_t GetDayOfYear(const TimeZone& tz = Local) const;
cd0b1709 914 // get the week number since the year start (1..52 or 53, 0 if date is
0979c962 915 // invalid)
9d9b7755
VZ
916 wxDateTime_t GetWeekOfYear(WeekFlags flags = Monday_First,
917 const TimeZone& tz = Local) const;
cd0b1709
VZ
918 // get the week number since the month start (1..5, 0 if date is
919 // invalid)
9d9b7755
VZ
920 wxDateTime_t GetWeekOfMonth(WeekFlags flags = Monday_First,
921 const TimeZone& tz = Local) const;
0979c962
VZ
922
923 // is this date a work day? This depends on a country, of course,
924 // because the holidays are different in different countries
4f6aed9c 925 bool IsWorkDay(Country country = Country_Default) const;
0979c962
VZ
926
927 // is this date later than Gregorian calendar introduction for the
928 // given country (see enum GregorianAdoption)?
929 //
4f6aed9c 930 // NB: this function shouldn't be considered as absolute authority in
0979c962
VZ
931 // the matter. Besides, for some countries the exact date of
932 // adoption of the Gregorian calendar is simply unknown.
b76b015e 933 bool IsGregorianDate(GregorianAdoption country = Gr_Standard) const;
0979c962 934
2b5f62a0
VZ
935 // dos date and time format
936 // ------------------------------------------------------------------------
937
938 // set from the DOS packed format
939 wxDateTime& SetFromDOS(unsigned long ddt);
940
941 // pack the date in DOS format
942 unsigned long GetAsDOS() const;
943
154014d6
VZ
944 // SYSTEMTIME format
945 // ------------------------------------------------------------------------
946#ifdef __WXMSW__
947
948 // convert SYSTEMTIME to wxDateTime
949 wxDateTime& SetFromMSWSysTime(const struct _SYSTEMTIME&);
950
951 // convert wxDateTime to SYSTEMTIME
952 void GetAsMSWSysTime(struct _SYSTEMTIME*) const;
953#endif // __WXMSW__
954
0979c962
VZ
955 // comparison (see also functions below for operator versions)
956 // ------------------------------------------------------------------------
957
68379eaf 958 // returns true if the two moments are strictly identical
b76b015e
VZ
959 inline bool IsEqualTo(const wxDateTime& datetime) const;
960
68379eaf 961 // returns true if the date is strictly earlier than the given one
b76b015e 962 inline bool IsEarlierThan(const wxDateTime& datetime) const;
0979c962 963
68379eaf 964 // returns true if the date is strictly later than the given one
b76b015e 965 inline bool IsLaterThan(const wxDateTime& datetime) const;
0979c962 966
68379eaf 967 // returns true if the date is strictly in the given range
b76b015e
VZ
968 inline bool IsStrictlyBetween(const wxDateTime& t1,
969 const wxDateTime& t2) const;
970
68379eaf 971 // returns true if the date is in the given range
b76b015e 972 inline bool IsBetween(const wxDateTime& t1, const wxDateTime& t2) const;
0979c962 973
be4017f8
VZ
974 // do these two objects refer to the same date?
975 inline bool IsSameDate(const wxDateTime& dt) const;
976
977 // do these two objects have the same time?
978 inline bool IsSameTime(const wxDateTime& dt) const;
979
980 // are these two objects equal up to given timespan?
981 inline bool IsEqualUpTo(const wxDateTime& dt, const wxTimeSpan& ts) const;
982
26364344
WS
983 inline bool operator<(const wxDateTime& dt) const
984 {
985 wxASSERT_MSG( IsValid() && dt.IsValid(), _T("invalid wxDateTime") );
986 return GetValue() < dt.GetValue();
987 }
988
989 inline bool operator<=(const wxDateTime& dt) const
990 {
991 wxASSERT_MSG( IsValid() && dt.IsValid(), _T("invalid wxDateTime") );
992 return GetValue() <= dt.GetValue();
993 }
994
995 inline bool operator>(const wxDateTime& dt) const
996 {
997 wxASSERT_MSG( IsValid() && dt.IsValid(), _T("invalid wxDateTime") );
998 return GetValue() > dt.GetValue();
999 }
1000
1001 inline bool operator>=(const wxDateTime& dt) const
1002 {
1003 wxASSERT_MSG( IsValid() && dt.IsValid(), _T("invalid wxDateTime") );
1004 return GetValue() >= dt.GetValue();
1005 }
1006
1007 inline bool operator==(const wxDateTime& dt) const
1008 {
1009 wxASSERT_MSG( IsValid() && dt.IsValid(), _T("invalid wxDateTime") );
1010 return GetValue() == dt.GetValue();
1011 }
1012
1013 inline bool operator!=(const wxDateTime& dt) const
1014 {
1015 wxASSERT_MSG( IsValid() && dt.IsValid(), _T("invalid wxDateTime") );
1016 return GetValue() != dt.GetValue();
1017 }
1018
cd0b1709 1019 // arithmetics with dates (see also below for more operators)
0979c962
VZ
1020 // ------------------------------------------------------------------------
1021
cd0b1709
VZ
1022 // return the sum of the date with a time span (positive or negative)
1023 inline wxDateTime Add(const wxTimeSpan& diff) const;
0979c962 1024 // add a time span (positive or negative)
b76b015e 1025 inline wxDateTime& Add(const wxTimeSpan& diff);
0979c962 1026 // add a time span (positive or negative)
b76b015e 1027 inline wxDateTime& operator+=(const wxTimeSpan& diff);
26364344
WS
1028 inline wxDateTime operator+(const wxTimeSpan& ts) const
1029 {
1030 wxDateTime dt(*this);
1031 dt.Add(ts);
1032 return dt;
1033 }
0979c962 1034
cd0b1709 1035 // return the difference of the date with a time span
f6bcfd97
BP
1036 inline wxDateTime Subtract(const wxTimeSpan& diff) const;
1037 // subtract a time span (positive or negative)
1038 inline wxDateTime& Subtract(const wxTimeSpan& diff);
1039 // subtract a time span (positive or negative)
0979c962 1040 inline wxDateTime& operator-=(const wxTimeSpan& diff);
26364344
WS
1041 inline wxDateTime operator-(const wxTimeSpan& ts) const
1042 {
1043 wxDateTime dt(*this);
1044 dt.Subtract(ts);
1045 return dt;
1046 }
0979c962 1047
cd0b1709
VZ
1048 // return the sum of the date with a date span
1049 inline wxDateTime Add(const wxDateSpan& diff) const;
0979c962
VZ
1050 // add a date span (positive or negative)
1051 wxDateTime& Add(const wxDateSpan& diff);
1052 // add a date span (positive or negative)
b76b015e 1053 inline wxDateTime& operator+=(const wxDateSpan& diff);
26364344
WS
1054 inline wxDateTime operator+(const wxDateSpan& ds) const
1055 {
1056 wxDateTime dt(*this);
1057 dt.Add(ds);
1058 return dt;
1059 }
0979c962 1060
cd0b1709 1061 // return the difference of the date with a date span
f6bcfd97
BP
1062 inline wxDateTime Subtract(const wxDateSpan& diff) const;
1063 // subtract a date span (positive or negative)
1064 inline wxDateTime& Subtract(const wxDateSpan& diff);
1065 // subtract a date span (positive or negative)
0979c962 1066 inline wxDateTime& operator-=(const wxDateSpan& diff);
26364344
WS
1067 inline wxDateTime operator-(const wxDateSpan& ds) const
1068 {
1069 wxDateTime dt(*this);
1070 dt.Subtract(ds);
1071 return dt;
1072 }
0979c962 1073
cd0b1709 1074 // return the difference between two dates
f6bcfd97 1075 inline wxTimeSpan Subtract(const wxDateTime& dt) const;
26364344 1076 inline wxTimeSpan operator-(const wxDateTime& dt2) const;
0979c962 1077
c398434d 1078 // conversion to/from text
0979c962
VZ
1079 // ------------------------------------------------------------------------
1080
c398434d
VZ
1081 // all conversions functions return true to indicate whether parsing
1082 // succeeded or failed and fill in the provided end iterator, which must
1083 // not be NULL, with the location of the character where the parsing
1084 // stopped (this will be end() of the passed string if everything was
1085 // parsed)
1086
0979c962
VZ
1087 // parse a string in RFC 822 format (found e.g. in mail headers and
1088 // having the form "Wed, 10 Feb 1999 19:07:07 +0100")
c398434d
VZ
1089 bool ParseRfc822Date(const wxString& date,
1090 wxString::const_iterator *end);
75a29ef1 1091
f0f951fa
VZ
1092 // parse a date/time in the given format (see strptime(3)), fill in
1093 // the missing (in the string) fields with the values of dateDef (by
1094 // default, they will not change if they had valid values or will
1095 // default to Today() otherwise)
c398434d
VZ
1096 bool ParseFormat(const wxString& date,
1097 const wxString& format,
1098 const wxDateTime& dateDef,
1099 wxString::const_iterator *end);
1100
1101 bool ParseFormat(const wxString& date,
1102 const wxString& format,
1103 wxString::const_iterator *end)
71ebd60b
VZ
1104 {
1105 return ParseFormat(date, format, wxDefaultDateTime, end);
1106 }
1107
c398434d
VZ
1108 bool ParseFormat(const wxString& date,
1109 wxString::const_iterator *end)
1110 {
1111 return ParseFormat(date, wxDefaultDateTimeFormat, wxDefaultDateTime, end);
1112 }
71ebd60b 1113
f3f2e255
VZ
1114 // parse a string containing date, time or both in ISO 8601 format
1115 //
1116 // notice that these functions are new in wx 3.0 and so we don't
1117 // provide compatibility overloads for them
1118 bool ParseISODate(const wxString& date)
1119 {
a0bcd61b 1120 wxString::const_iterator end;
c398434d 1121 return ParseFormat(date, wxS("%Y-%m-%d"), &end) && end == date.end();
f3f2e255
VZ
1122 }
1123
a0bcd61b 1124 bool ParseISOTime(const wxString& time)
f3f2e255 1125 {
a0bcd61b 1126 wxString::const_iterator end;
c398434d 1127 return ParseFormat(time, wxS("%H:%M:%S"), &end) && end == time.end();
f3f2e255
VZ
1128 }
1129
a0bcd61b 1130 bool ParseISOCombined(const wxString& datetime, char sep = 'T')
f3f2e255 1131 {
a0bcd61b 1132 wxString::const_iterator end;
f3f2e255 1133 const wxString fmt = wxS("%Y-%m-%d") + wxString(sep) + wxS("%H:%M:%S");
c398434d 1134 return ParseFormat(datetime, fmt, &end) && end == datetime.end();
f3f2e255
VZ
1135 }
1136
0979c962
VZ
1137 // parse a string containing the date/time in "free" format, this
1138 // function will try to make an educated guess at the string contents
c398434d
VZ
1139 bool ParseDateTime(const wxString& datetime,
1140 wxString::const_iterator *end);
71ebd60b 1141
cd0b1709
VZ
1142 // parse a string containing the date only in "free" format (less
1143 // flexible than ParseDateTime)
c398434d
VZ
1144 bool ParseDate(const wxString& date,
1145 wxString::const_iterator *end);
71ebd60b 1146
cd0b1709 1147 // parse a string containing the time only in "free" format
c398434d
VZ
1148 bool ParseTime(const wxString& time,
1149 wxString::const_iterator *end);
71ebd60b 1150
0979c962
VZ
1151
1152 // this function accepts strftime()-like format string (default
1153 // argument corresponds to the preferred date and time representation
1154 // for the current locale) and returns the string containing the
1155 // resulting text representation
12e82477 1156 wxString Format(const wxString& format = wxDefaultDateTimeFormat,
299fcbfe 1157 const TimeZone& tz = Local) const;
0979c962 1158 // preferred date representation for the current locale
f3f2e255 1159 wxString FormatDate() const { return Format(wxS("%x")); }
0979c962 1160 // preferred time representation for the current locale
f3f2e255 1161 wxString FormatTime() const { return Format(wxS("%X")); }
4f6aed9c 1162 // returns the string representing the date in ISO 8601 format
9d9b7755 1163 // (YYYY-MM-DD)
f3f2e255 1164 wxString FormatISODate() const { return Format(wxS("%Y-%m-%d")); }
4f6aed9c
VZ
1165 // returns the string representing the time in ISO 8601 format
1166 // (HH:MM:SS)
f3f2e255
VZ
1167 wxString FormatISOTime() const { return Format(wxS("%H:%M:%S")); }
1168 // return the combined date time representation in ISO 8601 format; the
1169 // separator character should be 'T' according to the standard but it
1170 // can also be useful to set it to ' '
1171 wxString FormatISOCombined(char sep = 'T') const
1172 { return FormatISODate() + sep + FormatISOTime(); }
0979c962 1173
c398434d
VZ
1174
1175 // backwards compatible versions of the parsing functions: they return an
1176 // object representing the next character following the date specification
1177 // (i.e. the one where the scan had to stop) or a special NULL-like object
1178 // on failure
1179 //
1180 // they're not deprecated because a lot of existing code uses them and
1181 // there is no particular harm in keeping them but you should still prefer
1182 // the versions above in the new code
1183 wxAnyStrPtr ParseRfc822Date(const wxString& date)
1184 {
1185 wxString::const_iterator end;
1186 return ParseRfc822Date(date, &end) ? wxAnyStrPtr(date, end)
1187 : wxAnyStrPtr();
1188 }
1189
1190 wxAnyStrPtr ParseFormat(const wxString& date,
1191 const wxString& format = wxDefaultDateTimeFormat,
1192 const wxDateTime& dateDef = wxDefaultDateTime)
1193 {
1194 wxString::const_iterator end;
1195 return ParseFormat(date, format, dateDef, &end) ? wxAnyStrPtr(date, end)
1196 : wxAnyStrPtr();
1197 }
1198
1199 wxAnyStrPtr ParseDateTime(const wxString& datetime)
1200 {
1201 wxString::const_iterator end;
1202 return ParseDateTime(datetime, &end) ? wxAnyStrPtr(datetime, end)
1203 : wxAnyStrPtr();
1204 }
1205
1206 wxAnyStrPtr ParseDate(const wxString& date)
1207 {
1208 wxString::const_iterator end;
1209 return ParseDate(date, &end) ? wxAnyStrPtr(date, end)
1210 : wxAnyStrPtr();
1211 }
1212
1213 wxAnyStrPtr ParseTime(const wxString& time)
1214 {
1215 wxString::const_iterator end;
1216 return ParseTime(time, &end) ? wxAnyStrPtr(time, end)
1217 : wxAnyStrPtr();
1218 }
1219
0979c962
VZ
1220 // implementation
1221 // ------------------------------------------------------------------------
1222
cd0b1709
VZ
1223 // construct from internal representation
1224 wxDateTime(const wxLongLong& time) { m_time = time; }
1225
0979c962
VZ
1226 // get the internal representation
1227 inline wxLongLong GetValue() const;
1228
0979c962 1229 // a helper function to get the current time_t
d3b9f782 1230 static time_t GetTimeNow() { return time(NULL); }
0979c962 1231
2f02cb89
VZ
1232 // another one to get the current time broken down
1233 static struct tm *GetTmNow()
1234 {
135d1ad0
JS
1235 static struct tm l_CurrentTime;
1236 return GetTmNow(&l_CurrentTime);
2f02cb89
VZ
1237 }
1238
a452689b
SN
1239 // get current time using thread-safe function
1240 static struct tm *GetTmNow(struct tm *tmstruct);
1241
2f02cb89 1242private:
0979c962 1243 // the current country - as it's the same for all program objects (unless
b76b015e
VZ
1244 // it runs on a _really_ big cluster system :-), this is a static member:
1245 // see SetCountry() and GetCountry()
0979c962
VZ
1246 static Country ms_country;
1247
0979c962
VZ
1248 // this constant is used to transform a time_t value to the internal
1249 // representation, as time_t is in seconds and we use milliseconds it's
1250 // fixed to 1000
cd0b1709 1251 static const long TIME_T_FACTOR;
0979c962 1252
68379eaf 1253 // returns true if we fall in range in which we can use standard ANSI C
b76b015e 1254 // functions
fcc3d7cb 1255 inline bool IsInStdRange() const;
b76b015e
VZ
1256
1257 // the internal representation of the time is the amount of milliseconds
1258 // elapsed since the origin which is set by convention to the UNIX/C epoch
1259 // value: the midnight of January 1, 1970 (UTC)
1260 wxLongLong m_time;
0979c962
VZ
1261};
1262
1263// ----------------------------------------------------------------------------
1264// This class contains a difference between 2 wxDateTime values, so it makes
f6bcfd97 1265// sense to add it to wxDateTime and it is the result of subtraction of 2
0979c962
VZ
1266// objects of that class. See also wxDateSpan.
1267// ----------------------------------------------------------------------------
b76b015e 1268
bddd7a8d 1269class WXDLLIMPEXP_BASE wxTimeSpan
0979c962
VZ
1270{
1271public:
1272 // constructors
1273 // ------------------------------------------------------------------------
1274
bd35ed32
VZ
1275 // return the timespan for the given number of milliseconds
1276 static wxTimeSpan Milliseconds(wxLongLong ms) { return wxTimeSpan(0, 0, 0, ms); }
1277 static wxTimeSpan Millisecond() { return Milliseconds(1); }
1278
fcc3d7cb 1279 // return the timespan for the given number of seconds
9c21e80b 1280 static wxTimeSpan Seconds(wxLongLong sec) { return wxTimeSpan(0, 0, sec); }
68ee7c47 1281 static wxTimeSpan Second() { return Seconds(1); }
fcc3d7cb
VZ
1282
1283 // return the timespan for the given number of minutes
6f2a55e3 1284 static wxTimeSpan Minutes(long min) { return wxTimeSpan(0, min, 0 ); }
68ee7c47 1285 static wxTimeSpan Minute() { return Minutes(1); }
fcc3d7cb
VZ
1286
1287 // return the timespan for the given number of hours
6f2a55e3 1288 static wxTimeSpan Hours(long hours) { return wxTimeSpan(hours, 0, 0); }
68ee7c47 1289 static wxTimeSpan Hour() { return Hours(1); }
fcc3d7cb 1290
cd0b1709 1291 // return the timespan for the given number of days
6f2a55e3 1292 static wxTimeSpan Days(long days) { return Hours(24 * days); }
68ee7c47 1293 static wxTimeSpan Day() { return Days(1); }
cd0b1709
VZ
1294
1295 // return the timespan for the given number of weeks
6f2a55e3 1296 static wxTimeSpan Weeks(long days) { return Days(7 * days); }
68ee7c47 1297 static wxTimeSpan Week() { return Weeks(1); }
cd0b1709 1298
0979c962
VZ
1299 // default ctor constructs the 0 time span
1300 wxTimeSpan() { }
1301
1302 // from separate values for each component, date set to 0 (hours are
1303 // not restricted to 0..24 range, neither are minutes, seconds or
1304 // milliseconds)
6f2a55e3
VZ
1305 inline wxTimeSpan(long hours,
1306 long minutes = 0,
9c21e80b
VZ
1307 wxLongLong seconds = 0,
1308 wxLongLong milliseconds = 0);
0979c962 1309
0979c962
VZ
1310 // default copy ctor is ok
1311
1312 // no dtor
1313
cd0b1709 1314 // arithmetics with time spans (see also below for more operators)
0979c962
VZ
1315 // ------------------------------------------------------------------------
1316
cd0b1709
VZ
1317 // return the sum of two timespans
1318 inline wxTimeSpan Add(const wxTimeSpan& diff) const;
0979c962
VZ
1319 // add two timespans together
1320 inline wxTimeSpan& Add(const wxTimeSpan& diff);
1321 // add two timespans together
1322 wxTimeSpan& operator+=(const wxTimeSpan& diff) { return Add(diff); }
26364344
WS
1323 inline wxTimeSpan operator+(const wxTimeSpan& ts) const
1324 {
1325 return wxTimeSpan(GetValue() + ts.GetValue());
1326 }
0979c962 1327
cd0b1709 1328 // return the difference of two timespans
f6bcfd97
BP
1329 inline wxTimeSpan Subtract(const wxTimeSpan& diff) const;
1330 // subtract another timespan
1331 inline wxTimeSpan& Subtract(const wxTimeSpan& diff);
1332 // subtract another timespan
1333 wxTimeSpan& operator-=(const wxTimeSpan& diff) { return Subtract(diff); }
26364344
WS
1334 inline wxTimeSpan operator-(const wxTimeSpan& ts)
1335 {
1336 return wxTimeSpan(GetValue() - ts.GetValue());
1337 }
0979c962 1338
cd0b1709
VZ
1339 // multiply timespan by a scalar
1340 inline wxTimeSpan Multiply(int n) const;
0979c962
VZ
1341 // multiply timespan by a scalar
1342 inline wxTimeSpan& Multiply(int n);
1343 // multiply timespan by a scalar
1344 wxTimeSpan& operator*=(int n) { return Multiply(n); }
26364344
WS
1345 inline wxTimeSpan operator*(int n) const
1346 {
1347 return wxTimeSpan(*this).Multiply(n);
1348 }
0979c962 1349
3103e8a9 1350 // return this timespan with opposite sign
b76b015e 1351 wxTimeSpan Negate() const { return wxTimeSpan(-GetValue()); }
0979c962
VZ
1352 // negate the value of the timespan
1353 wxTimeSpan& Neg() { m_diff = -GetValue(); return *this; }
1354 // negate the value of the timespan
1355 wxTimeSpan& operator-() { return Neg(); }
1356
1357 // return the absolute value of the timespan: does _not_ modify the
1358 // object
1359 inline wxTimeSpan Abs() const;
1360
1361 // there is intentionally no division because we don't want to
1362 // introduce rounding errors in time calculations
1363
1364 // comparaison (see also operator versions below)
1365 // ------------------------------------------------------------------------
1366
1367 // is the timespan null?
b76b015e 1368 bool IsNull() const { return m_diff == 0l; }
0979c962
VZ
1369 // returns true if the timespan is null
1370 bool operator!() const { return !IsNull(); }
1371
1372 // is the timespan positive?
b76b015e 1373 bool IsPositive() const { return m_diff > 0l; }
0979c962
VZ
1374
1375 // is the timespan negative?
b76b015e 1376 bool IsNegative() const { return m_diff < 0l; }
0979c962
VZ
1377
1378 // are two timespans equal?
1379 inline bool IsEqualTo(const wxTimeSpan& ts) const;
1380 // compare two timestamps: works with the absolute values, i.e. -2
68379eaf 1381 // hours is longer than 1 hour. Also, it will return false if the
0979c962
VZ
1382 // timespans are equal in absolute value.
1383 inline bool IsLongerThan(const wxTimeSpan& ts) const;
1384 // compare two timestamps: works with the absolute values, i.e. 1
68379eaf 1385 // hour is shorter than -2 hours. Also, it will return false if the
0979c962 1386 // timespans are equal in absolute value.
f7541d48 1387 bool IsShorterThan(const wxTimeSpan& t) const;
0979c962 1388
26364344
WS
1389 inline bool operator<(const wxTimeSpan &ts) const
1390 {
1391 return GetValue() < ts.GetValue();
1392 }
1393
1394 inline bool operator<=(const wxTimeSpan &ts) const
1395 {
1396 return GetValue() <= ts.GetValue();
1397 }
1398
1399 inline bool operator>(const wxTimeSpan &ts) const
1400 {
1401 return GetValue() > ts.GetValue();
1402 }
1403
1404 inline bool operator>=(const wxTimeSpan &ts) const
1405 {
1406 return GetValue() >= ts.GetValue();
1407 }
1408
1409 inline bool operator==(const wxTimeSpan &ts) const
1410 {
1411 return GetValue() == ts.GetValue();
1412 }
1413
1414 inline bool operator!=(const wxTimeSpan &ts) const
1415 {
1416 return GetValue() != ts.GetValue();
1417 }
1418
e6ec579c 1419 // breaking into days, hours, minutes and seconds
0979c962
VZ
1420 // ------------------------------------------------------------------------
1421
0979c962
VZ
1422 // get the max number of weeks in this timespan
1423 inline int GetWeeks() const;
1424 // get the max number of days in this timespan
1425 inline int GetDays() const;
1426 // get the max number of hours in this timespan
1427 inline int GetHours() const;
1428 // get the max number of minutes in this timespan
1429 inline int GetMinutes() const;
1430 // get the max number of seconds in this timespan
e6ec579c 1431 inline wxLongLong GetSeconds() const;
0979c962 1432 // get the number of milliseconds in this timespan
b76b015e 1433 wxLongLong GetMilliseconds() const { return m_diff; }
0979c962
VZ
1434
1435 // conversion to text
1436 // ------------------------------------------------------------------------
1437
1438 // this function accepts strftime()-like format string (default
1439 // argument corresponds to the preferred date and time representation
1440 // for the current locale) and returns the string containing the
1441 // resulting text representation. Notice that only some of format
1442 // specifiers valid for wxDateTime are valid for wxTimeSpan: hours,
1443 // minutes and seconds make sense, but not "PM/AM" string for example.
12e82477 1444 wxString Format(const wxString& format = wxDefaultTimeSpanFormat) const;
0979c962
VZ
1445
1446 // implementation
1447 // ------------------------------------------------------------------------
1448
cd0b1709
VZ
1449 // construct from internal representation
1450 wxTimeSpan(const wxLongLong& diff) { m_diff = diff; }
1451
0979c962
VZ
1452 // get the internal representation
1453 wxLongLong GetValue() const { return m_diff; }
1454
1455private:
1456 // the (signed) time span in milliseconds
1457 wxLongLong m_diff;
1458};
1459
1460// ----------------------------------------------------------------------------
1461// This class is a "logical time span" and is useful for implementing program
1462// logic for such things as "add one month to the date" which, in general,
1463// doesn't mean to add 60*60*24*31 seconds to it, but to take the same date
1464// the next month (to understand that this is indeed different consider adding
1465// one month to Feb, 15 - we want to get Mar, 15, of course).
1466//
1467// When adding a month to the date, all lesser components (days, hours, ...)
4f6aed9c
VZ
1468// won't be changed unless the resulting date would be invalid: for example,
1469// Jan 31 + 1 month will be Feb 28, not (non existing) Feb 31.
1470//
f6bcfd97 1471// Because of this feature, adding and subtracting back again the same
4f6aed9c
VZ
1472// wxDateSpan will *not*, in general give back the original date: Feb 28 - 1
1473// month will be Jan 28, not Jan 31!
0979c962
VZ
1474//
1475// wxDateSpan can be either positive or negative. They may be
1476// multiplied by scalars which multiply all deltas by the scalar: i.e. 2*(1
1477// month and 1 day) is 2 months and 2 days. They can be added together and
1478// with wxDateTime or wxTimeSpan, but the type of result is different for each
1479// case.
1480//
1481// Beware about weeks: if you specify both weeks and days, the total number of
1482// days added will be 7*weeks + days! See also GetTotalDays() function.
1483//
93401be9
VZ
1484// Equality operators are defined for wxDateSpans. Two datespans are equal if
1485// they both give the same target date when added to *every* source date.
1486// Thus wxDateSpan::Months(1) is not equal to wxDateSpan::Days(30), because
1487// they not give the same date when added to 1 Feb. But wxDateSpan::Days(14) is
1488// equal to wxDateSpan::Weeks(2)
1489//
0979c962
VZ
1490// Finally, notice that for adding hours, minutes &c you don't need this
1491// class: wxTimeSpan will do the job because there are no subtleties
1492// associated with those.
1493// ----------------------------------------------------------------------------
b76b015e 1494
bddd7a8d 1495class WXDLLIMPEXP_BASE wxDateSpan
0979c962
VZ
1496{
1497public:
1498 // constructors
1499 // ------------------------------------------------------------------------
1500
1501 // this many years/months/weeks/days
2f02cb89
VZ
1502 wxDateSpan(int years = 0, int months = 0, int weeks = 0, int days = 0)
1503 {
1504 m_years = years;
1505 m_months = months;
1506 m_weeks = weeks;
1507 m_days = days;
1508 }
1509
1510 // get an object for the given number of days
1511 static wxDateSpan Days(int days) { return wxDateSpan(0, 0, 0, days); }
68ee7c47 1512 static wxDateSpan Day() { return Days(1); }
2f02cb89
VZ
1513
1514 // get an object for the given number of weeks
1515 static wxDateSpan Weeks(int weeks) { return wxDateSpan(0, 0, weeks, 0); }
68ee7c47 1516 static wxDateSpan Week() { return Weeks(1); }
2f02cb89
VZ
1517
1518 // get an object for the given number of months
1519 static wxDateSpan Months(int mon) { return wxDateSpan(0, mon, 0, 0); }
68ee7c47 1520 static wxDateSpan Month() { return Months(1); }
2f02cb89
VZ
1521
1522 // get an object for the given number of years
1523 static wxDateSpan Years(int years) { return wxDateSpan(years, 0, 0, 0); }
68ee7c47 1524 static wxDateSpan Year() { return Years(1); }
0979c962
VZ
1525
1526 // default copy ctor is ok
1527
1528 // no dtor
1529
1530 // accessors (all SetXXX() return the (modified) wxDateSpan object)
1531 // ------------------------------------------------------------------------
1532
1533 // set number of years
b76b015e 1534 wxDateSpan& SetYears(int n) { m_years = n; return *this; }
0979c962 1535 // set number of months
b76b015e 1536 wxDateSpan& SetMonths(int n) { m_months = n; return *this; }
0979c962 1537 // set number of weeks
b76b015e 1538 wxDateSpan& SetWeeks(int n) { m_weeks = n; return *this; }
0979c962 1539 // set number of days
b76b015e 1540 wxDateSpan& SetDays(int n) { m_days = n; return *this; }
0979c962
VZ
1541
1542 // get number of years
1543 int GetYears() const { return m_years; }
1544 // get number of months
1545 int GetMonths() const { return m_months; }
1546 // get number of weeks
1547 int GetWeeks() const { return m_weeks; }
1548 // get number of days
1549 int GetDays() const { return m_days; }
1550 // returns 7*GetWeeks() + GetDays()
1551 int GetTotalDays() const { return 7*m_weeks + m_days; }
1552
cd0b1709 1553 // arithmetics with date spans (see also below for more operators)
0979c962
VZ
1554 // ------------------------------------------------------------------------
1555
cd0b1709
VZ
1556 // return sum of two date spans
1557 inline wxDateSpan Add(const wxDateSpan& other) const;
0979c962
VZ
1558 // add another wxDateSpan to us
1559 inline wxDateSpan& Add(const wxDateSpan& other);
1560 // add another wxDateSpan to us
1561 inline wxDateSpan& operator+=(const wxDateSpan& other);
26364344
WS
1562 inline wxDateSpan operator+(const wxDateSpan& ds) const
1563 {
1564 return wxDateSpan(GetYears() + ds.GetYears(),
1565 GetMonths() + ds.GetMonths(),
1566 GetWeeks() + ds.GetWeeks(),
1567 GetDays() + ds.GetDays());
1568 }
0979c962 1569
cd0b1709 1570 // return difference of two date spans
f6bcfd97
BP
1571 inline wxDateSpan Subtract(const wxDateSpan& other) const;
1572 // subtract another wxDateSpan from us
1573 inline wxDateSpan& Subtract(const wxDateSpan& other);
1574 // subtract another wxDateSpan from us
0979c962 1575 inline wxDateSpan& operator-=(const wxDateSpan& other);
26364344
WS
1576 inline wxDateSpan operator-(const wxDateSpan& ds) const
1577 {
1578 return wxDateSpan(GetYears() - ds.GetYears(),
1579 GetMonths() - ds.GetMonths(),
1580 GetWeeks() - ds.GetWeeks(),
1581 GetDays() - ds.GetDays());
1582 }
0979c962
VZ
1583
1584 // return a copy of this time span with changed sign
1585 inline wxDateSpan Negate() const;
1586 // inverse the sign of this timespan
1587 inline wxDateSpan& Neg();
1588 // inverse the sign of this timespan
1589 wxDateSpan& operator-() { return Neg(); }
1590
cd0b1709
VZ
1591 // return the date span proportional to this one with given factor
1592 inline wxDateSpan Multiply(int factor) const;
0979c962 1593 // multiply all components by a (signed) number
cd0b1709
VZ
1594 inline wxDateSpan& Multiply(int factor);
1595 // multiply all components by a (signed) number
1596 inline wxDateSpan& operator*=(int factor) { return Multiply(factor); }
26364344
WS
1597 inline wxDateSpan operator*(int n) const
1598 {
1599 return wxDateSpan(*this).Multiply(n);
1600 }
1601
1602 // ds1 == d2 if and only if for every wxDateTime t t + ds1 == t + ds2
1603 inline bool operator==(const wxDateSpan& ds) const
1604 {
1605 return GetYears() == ds.GetYears() &&
1606 GetMonths() == ds.GetMonths() &&
1607 GetTotalDays() == ds.GetTotalDays();
1608 }
1609
1610 inline bool operator!=(const wxDateSpan& ds) const
1611 {
1612 return !(*this == ds);
1613 }
0979c962
VZ
1614
1615private:
1616 int m_years,
1617 m_months,
1618 m_weeks,
1619 m_days;
1620};
1621
4f6aed9c
VZ
1622// ----------------------------------------------------------------------------
1623// wxDateTimeArray: array of dates.
1624// ----------------------------------------------------------------------------
1625
bb24c68f 1626WX_DECLARE_USER_EXPORTED_OBJARRAY(wxDateTime, wxDateTimeArray, WXDLLIMPEXP_BASE);
4f6aed9c
VZ
1627
1628// ----------------------------------------------------------------------------
1629// wxDateTimeHolidayAuthority: an object of this class will decide whether a
1630// given date is a holiday and is used by all functions working with "work
1631// days".
1632//
1633// NB: the base class is an ABC, derived classes must implement the pure
1634// virtual methods to work with the holidays they correspond to.
1635// ----------------------------------------------------------------------------
1636
b5dbe15d 1637class WXDLLIMPEXP_FWD_BASE wxDateTimeHolidayAuthority;
d5d29b8a 1638WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxDateTimeHolidayAuthority *,
bb24c68f 1639 wxHolidayAuthoritiesArray,
fd497ede 1640 class WXDLLIMPEXP_BASE);
4f6aed9c 1641
f6081a04 1642class wxDateTimeHolidaysModule;
bddd7a8d 1643class WXDLLIMPEXP_BASE wxDateTimeHolidayAuthority
4f6aed9c 1644{
f6bcfd97 1645friend class wxDateTimeHolidaysModule;
4f6aed9c 1646public:
68379eaf 1647 // returns true if the given date is a holiday
4f6aed9c
VZ
1648 static bool IsHoliday(const wxDateTime& dt);
1649
1650 // fills the provided array with all holidays in the given range, returns
1651 // the number of them
1652 static size_t GetHolidaysInRange(const wxDateTime& dtStart,
1653 const wxDateTime& dtEnd,
1654 wxDateTimeArray& holidays);
1655
1656 // clear the list of holiday authorities
1657 static void ClearAllAuthorities();
1658
1659 // add a new holiday authority (the pointer will be deleted by
1660 // wxDateTimeHolidayAuthority)
1661 static void AddAuthority(wxDateTimeHolidayAuthority *auth);
1662
30e671a5 1663 // the base class must have a virtual dtor
5e233068 1664 virtual ~wxDateTimeHolidayAuthority();
30e671a5 1665
4f6aed9c
VZ
1666protected:
1667 // this function is called to determine whether a given day is a holiday
1668 virtual bool DoIsHoliday(const wxDateTime& dt) const = 0;
1669
1670 // this function should fill the array with all holidays between the two
1671 // given dates - it is implemented in the base class, but in a very
1672 // inefficient way (it just iterates over all days and uses IsHoliday() for
1673 // each of them), so it must be overridden in the derived class where the
1674 // base class version may be explicitly used if needed
1675 //
1676 // returns the number of holidays in the given range and fills holidays
1677 // array
1678 virtual size_t DoGetHolidaysInRange(const wxDateTime& dtStart,
1679 const wxDateTime& dtEnd,
1680 wxDateTimeArray& holidays) const = 0;
1681
1682private:
1683 // all holiday authorities
1684 static wxHolidayAuthoritiesArray ms_authorities;
1685};
1686
1687// the holidays for this class are all Saturdays and Sundays
bddd7a8d 1688class WXDLLIMPEXP_BASE wxDateTimeWorkDays : public wxDateTimeHolidayAuthority
4f6aed9c
VZ
1689{
1690protected:
1691 virtual bool DoIsHoliday(const wxDateTime& dt) const;
1692 virtual size_t DoGetHolidaysInRange(const wxDateTime& dtStart,
1693 const wxDateTime& dtEnd,
1694 wxDateTimeArray& holidays) const;
1695};
0979c962 1696
2f02cb89
VZ
1697// ============================================================================
1698// inline functions implementation
1699// ============================================================================
1700
df5168c4
MB
1701// ----------------------------------------------------------------------------
1702// private macros
1703// ----------------------------------------------------------------------------
1704
1705#define MILLISECONDS_PER_DAY 86400000l
1706
1707// some broken compilers (HP-UX CC) refuse to compile the "normal" version, but
1708// using a temp variable always might prevent other compilers from optimising
1709// it away - hence use of this ugly macro
1710#ifndef __HPUX__
1711 #define MODIFY_AND_RETURN(op) return wxDateTime(*this).op
1712#else
1713 #define MODIFY_AND_RETURN(op) wxDateTime dt(*this); dt.op; return dt
1714#endif
1715
1716// ----------------------------------------------------------------------------
1717// wxDateTime construction
1718// ----------------------------------------------------------------------------
1719
1720inline bool wxDateTime::IsInStdRange() const
1721{
1722 return m_time >= 0l && (m_time / TIME_T_FACTOR) < LONG_MAX;
1723}
2f02cb89 1724
df5168c4
MB
1725/* static */
1726inline wxDateTime wxDateTime::Now()
1727{
a452689b
SN
1728 struct tm tmstruct;
1729 return wxDateTime(*GetTmNow(&tmstruct));
df5168c4
MB
1730}
1731
1732/* static */
1733inline wxDateTime wxDateTime::Today()
1734{
cb1ef833
VZ
1735 wxDateTime dt(Now());
1736 dt.ResetTime();
df5168c4 1737
cb1ef833 1738 return dt;
df5168c4
MB
1739}
1740
1741#if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400))
1742inline wxDateTime& wxDateTime::Set(time_t timet)
1743{
1744 // assign first to avoid long multiplication overflow!
1745 m_time = timet - WX_TIME_BASE_OFFSET ;
1746 m_time *= TIME_T_FACTOR;
1747
1748 return *this;
1749}
2f02cb89
VZ
1750#endif
1751
df5168c4
MB
1752inline wxDateTime& wxDateTime::SetToCurrent()
1753{
1754 *this = Now();
1755 return *this;
1756}
1757
1758#if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400))
1759inline wxDateTime::wxDateTime(time_t timet)
1760{
1761 Set(timet);
1762}
dc84437e 1763#endif
2f02cb89 1764
df5168c4
MB
1765inline wxDateTime::wxDateTime(const struct tm& tm)
1766{
1767 Set(tm);
1768}
1769
1770inline wxDateTime::wxDateTime(const Tm& tm)
1771{
1772 Set(tm);
1773}
1774
1775inline wxDateTime::wxDateTime(double jdn)
1776{
1777 Set(jdn);
1778}
1779
1780inline wxDateTime& wxDateTime::Set(const Tm& tm)
1781{
1782 wxASSERT_MSG( tm.IsValid(), _T("invalid broken down date/time") );
1783
271f6072
VZ
1784 return Set(tm.mday, (Month)tm.mon, tm.year,
1785 tm.hour, tm.min, tm.sec, tm.msec);
df5168c4
MB
1786}
1787
1788inline wxDateTime::wxDateTime(wxDateTime_t hour,
1789 wxDateTime_t minute,
1790 wxDateTime_t second,
1791 wxDateTime_t millisec)
1792{
1793 Set(hour, minute, second, millisec);
1794}
1795
1796inline wxDateTime::wxDateTime(wxDateTime_t day,
1797 Month month,
1798 int year,
1799 wxDateTime_t hour,
1800 wxDateTime_t minute,
1801 wxDateTime_t second,
1802 wxDateTime_t millisec)
1803{
1804 Set(day, month, year, hour, minute, second, millisec);
1805}
1806
1807// ----------------------------------------------------------------------------
1808// wxDateTime accessors
1809// ----------------------------------------------------------------------------
1810
1811inline wxLongLong wxDateTime::GetValue() const
1812{
1813 wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
1814
1815 return m_time;
1816}
1817
1818inline time_t wxDateTime::GetTicks() const
1819{
1820 wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
1821 if ( !IsInStdRange() )
1822 {
1823 return (time_t)-1;
1824 }
1825
d3c58c7e 1826 return (time_t)((m_time / (long)TIME_T_FACTOR).ToLong()) + WX_TIME_BASE_OFFSET;
df5168c4
MB
1827}
1828
1829inline bool wxDateTime::SetToLastWeekDay(WeekDay weekday,
1830 Month month,
1831 int year)
1832{
1833 return SetToWeekDay(weekday, -1, month, year);
1834}
1835
fc7a2a60
VZ
1836inline wxDateTime
1837wxDateTime::GetWeekDayInSameWeek(WeekDay weekday,
1838 WeekFlags WXUNUSED(flags)) const
df5168c4
MB
1839{
1840 MODIFY_AND_RETURN( SetToWeekDayInSameWeek(weekday) );
1841}
1842
1843inline wxDateTime wxDateTime::GetNextWeekDay(WeekDay weekday) const
1844{
1845 MODIFY_AND_RETURN( SetToNextWeekDay(weekday) );
1846}
1847
1848inline wxDateTime wxDateTime::GetPrevWeekDay(WeekDay weekday) const
1849{
1850 MODIFY_AND_RETURN( SetToPrevWeekDay(weekday) );
1851}
1852
1853inline wxDateTime wxDateTime::GetWeekDay(WeekDay weekday,
1854 int n,
1855 Month month,
1856 int year) const
1857{
1858 wxDateTime dt(*this);
1859
1860 return dt.SetToWeekDay(weekday, n, month, year) ? dt : wxInvalidDateTime;
1861}
1862
1863inline wxDateTime wxDateTime::GetLastWeekDay(WeekDay weekday,
1864 Month month,
1865 int year)
1866{
1867 wxDateTime dt(*this);
1868
1869 return dt.SetToLastWeekDay(weekday, month, year) ? dt : wxInvalidDateTime;
1870}
1871
df5168c4
MB
1872inline wxDateTime wxDateTime::GetLastMonthDay(Month month, int year) const
1873{
1874 MODIFY_AND_RETURN( SetToLastMonthDay(month, year) );
1875}
1876
1877inline wxDateTime wxDateTime::GetYearDay(wxDateTime_t yday) const
1878{
1879 MODIFY_AND_RETURN( SetToYearDay(yday) );
1880}
1881
1882// ----------------------------------------------------------------------------
1883// wxDateTime comparison
1884// ----------------------------------------------------------------------------
1885
1886inline bool wxDateTime::IsEqualTo(const wxDateTime& datetime) const
1887{
1888 wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
1889
1890 return m_time == datetime.m_time;
1891}
1892
1893inline bool wxDateTime::IsEarlierThan(const wxDateTime& datetime) const
1894{
1895 wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
1896
1897 return m_time < datetime.m_time;
1898}
1899
1900inline bool wxDateTime::IsLaterThan(const wxDateTime& datetime) const
1901{
1902 wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
1903
1904 return m_time > datetime.m_time;
1905}
1906
1907inline bool wxDateTime::IsStrictlyBetween(const wxDateTime& t1,
1908 const wxDateTime& t2) const
1909{
1910 // no need for assert, will be checked by the functions we call
1911 return IsLaterThan(t1) && IsEarlierThan(t2);
1912}
1913
1914inline bool wxDateTime::IsBetween(const wxDateTime& t1,
1915 const wxDateTime& t2) const
1916{
1917 // no need for assert, will be checked by the functions we call
1918 return IsEqualTo(t1) || IsEqualTo(t2) || IsStrictlyBetween(t1, t2);
1919}
1920
1921inline bool wxDateTime::IsSameDate(const wxDateTime& dt) const
1922{
1923 Tm tm1 = GetTm(),
1924 tm2 = dt.GetTm();
1925
1926 return tm1.year == tm2.year &&
1927 tm1.mon == tm2.mon &&
1928 tm1.mday == tm2.mday;
1929}
1930
1931inline bool wxDateTime::IsSameTime(const wxDateTime& dt) const
1932{
1933 // notice that we can't do something like this:
1934 //
1935 // m_time % MILLISECONDS_PER_DAY == dt.m_time % MILLISECONDS_PER_DAY
1936 //
1937 // because we have also to deal with (possibly) different DST settings!
1938 Tm tm1 = GetTm(),
1939 tm2 = dt.GetTm();
1940
1941 return tm1.hour == tm2.hour &&
1942 tm1.min == tm2.min &&
1943 tm1.sec == tm2.sec &&
1944 tm1.msec == tm2.msec;
1945}
1946
1947inline bool wxDateTime::IsEqualUpTo(const wxDateTime& dt,
1948 const wxTimeSpan& ts) const
1949{
1950 return IsBetween(dt.Subtract(ts), dt.Add(ts));
1951}
1952
1953// ----------------------------------------------------------------------------
1954// wxDateTime arithmetics
1955// ----------------------------------------------------------------------------
1956
1957inline wxDateTime wxDateTime::Add(const wxTimeSpan& diff) const
1958{
1959 wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
1960
1961 return wxDateTime(m_time + diff.GetValue());
1962}
1963
1964inline wxDateTime& wxDateTime::Add(const wxTimeSpan& diff)
1965{
1966 wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
1967
1968 m_time += diff.GetValue();
1969
1970 return *this;
1971}
1972
1973inline wxDateTime& wxDateTime::operator+=(const wxTimeSpan& diff)
1974{
1975 return Add(diff);
1976}
1977
1978inline wxDateTime wxDateTime::Subtract(const wxTimeSpan& diff) const
1979{
1980 wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
1981
1982 return wxDateTime(m_time - diff.GetValue());
1983}
1984
1985inline wxDateTime& wxDateTime::Subtract(const wxTimeSpan& diff)
1986{
1987 wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
1988
1989 m_time -= diff.GetValue();
1990
1991 return *this;
1992}
1993
1994inline wxDateTime& wxDateTime::operator-=(const wxTimeSpan& diff)
1995{
1996 return Subtract(diff);
1997}
1998
1999inline wxTimeSpan wxDateTime::Subtract(const wxDateTime& datetime) const
2000{
2001 wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
2002
2003 return wxTimeSpan(GetValue() - datetime.GetValue());
2004}
2005
26364344
WS
2006inline wxTimeSpan wxDateTime::operator-(const wxDateTime& dt2) const
2007{
2008 return this->Subtract(dt2);
2009}
2010
df5168c4
MB
2011inline wxDateTime wxDateTime::Add(const wxDateSpan& diff) const
2012{
2013 return wxDateTime(*this).Add(diff);
2014}
2015
2016inline wxDateTime& wxDateTime::Subtract(const wxDateSpan& diff)
2017{
2018 return Add(diff.Negate());
2019}
2020
2021inline wxDateTime wxDateTime::Subtract(const wxDateSpan& diff) const
2022{
2023 return wxDateTime(*this).Subtract(diff);
2024}
2025
2026inline wxDateTime& wxDateTime::operator-=(const wxDateSpan& diff)
2027{
2028 return Subtract(diff);
2029}
2030
2031inline wxDateTime& wxDateTime::operator+=(const wxDateSpan& diff)
2032{
2033 return Add(diff);
2034}
2035
2036// ----------------------------------------------------------------------------
2037// wxDateTime and timezones
2038// ----------------------------------------------------------------------------
2039
d26adb9d
VZ
2040inline wxDateTime
2041wxDateTime::ToTimezone(const wxDateTime::TimeZone& tz, bool noDST) const
df5168c4
MB
2042{
2043 MODIFY_AND_RETURN( MakeTimezone(tz, noDST) );
2044}
2045
d26adb9d
VZ
2046inline wxDateTime
2047wxDateTime::FromTimezone(const wxDateTime::TimeZone& tz, bool noDST) const
2048{
2049 MODIFY_AND_RETURN( MakeFromTimezone(tz, noDST) );
2050}
2051
df5168c4
MB
2052// ----------------------------------------------------------------------------
2053// wxTimeSpan construction
2054// ----------------------------------------------------------------------------
2055
2056inline wxTimeSpan::wxTimeSpan(long hours,
2057 long minutes,
9c21e80b
VZ
2058 wxLongLong seconds,
2059 wxLongLong milliseconds)
df5168c4
MB
2060{
2061 // assign first to avoid precision loss
2062 m_diff = hours;
2063 m_diff *= 60l;
2064 m_diff += minutes;
2065 m_diff *= 60l;
2066 m_diff += seconds;
2067 m_diff *= 1000l;
2068 m_diff += milliseconds;
2069}
2070
2071// ----------------------------------------------------------------------------
2072// wxTimeSpan accessors
2073// ----------------------------------------------------------------------------
2074
2075inline wxLongLong wxTimeSpan::GetSeconds() const
2076{
2077 return m_diff / 1000l;
2078}
2079
2080inline int wxTimeSpan::GetMinutes() const
2081{
18c7af7e
VZ
2082 // explicit cast to int suppresses a warning with CodeWarrior and possibly
2083 // others (changing the return type to long from int is impossible in 2.8)
2084 return (int)((GetSeconds() / 60l).GetLo());
df5168c4
MB
2085}
2086
2087inline int wxTimeSpan::GetHours() const
2088{
2089 return GetMinutes() / 60;
2090}
2091
2092inline int wxTimeSpan::GetDays() const
2093{
2094 return GetHours() / 24;
2095}
2096
2097inline int wxTimeSpan::GetWeeks() const
2098{
2099 return GetDays() / 7;
2100}
2101
2102// ----------------------------------------------------------------------------
2103// wxTimeSpan arithmetics
2104// ----------------------------------------------------------------------------
2105
2106inline wxTimeSpan wxTimeSpan::Add(const wxTimeSpan& diff) const
2107{
2108 return wxTimeSpan(m_diff + diff.GetValue());
2109}
2110
2111inline wxTimeSpan& wxTimeSpan::Add(const wxTimeSpan& diff)
2112{
2113 m_diff += diff.GetValue();
2114
2115 return *this;
2116}
2117
2118inline wxTimeSpan wxTimeSpan::Subtract(const wxTimeSpan& diff) const
2119{
2120 return wxTimeSpan(m_diff - diff.GetValue());
2121}
2122
2123inline wxTimeSpan& wxTimeSpan::Subtract(const wxTimeSpan& diff)
2124{
2125 m_diff -= diff.GetValue();
2126
2127 return *this;
2128}
2129
2130inline wxTimeSpan& wxTimeSpan::Multiply(int n)
2131{
2132 m_diff *= (long)n;
2133
2134 return *this;
2135}
2136
2137inline wxTimeSpan wxTimeSpan::Multiply(int n) const
2138{
2139 return wxTimeSpan(m_diff * (long)n);
2140}
2141
2142inline wxTimeSpan wxTimeSpan::Abs() const
2143{
2144 return wxTimeSpan(GetValue().Abs());
2145}
2146
2147inline bool wxTimeSpan::IsEqualTo(const wxTimeSpan& ts) const
2148{
2149 return GetValue() == ts.GetValue();
2150}
2151
2152inline bool wxTimeSpan::IsLongerThan(const wxTimeSpan& ts) const
2153{
2154 return GetValue().Abs() > ts.GetValue().Abs();
f7541d48
VZ
2155}
2156
2157inline bool wxTimeSpan::IsShorterThan(const wxTimeSpan& ts) const
2158{
2159 return GetValue().Abs() < ts.GetValue().Abs();
df5168c4
MB
2160}
2161
2162// ----------------------------------------------------------------------------
2163// wxDateSpan
2164// ----------------------------------------------------------------------------
2165
2166inline wxDateSpan& wxDateSpan::operator+=(const wxDateSpan& other)
2167{
2168 m_years += other.m_years;
2169 m_months += other.m_months;
2170 m_weeks += other.m_weeks;
2171 m_days += other.m_days;
2172
2173 return *this;
2174}
2175
2176inline wxDateSpan& wxDateSpan::Add(const wxDateSpan& other)
2177{
2178 return *this += other;
2179}
2180
2181inline wxDateSpan wxDateSpan::Add(const wxDateSpan& other) const
2182{
2183 wxDateSpan ds(*this);
2184 ds.Add(other);
2185 return ds;
2186}
2187
2188inline wxDateSpan& wxDateSpan::Multiply(int factor)
2189{
2190 m_years *= factor;
2191 m_months *= factor;
2192 m_weeks *= factor;
2193 m_days *= factor;
2194
2195 return *this;
2196}
2197
2198inline wxDateSpan wxDateSpan::Multiply(int factor) const
2199{
2200 wxDateSpan ds(*this);
2201 ds.Multiply(factor);
2202 return ds;
2203}
2204
2205inline wxDateSpan wxDateSpan::Negate() const
2206{
2207 return wxDateSpan(-m_years, -m_months, -m_weeks, -m_days);
2208}
2209
2210inline wxDateSpan& wxDateSpan::Neg()
2211{
2212 m_years = -m_years;
2213 m_months = -m_months;
2214 m_weeks = -m_weeks;
2215 m_days = -m_days;
2216
2217 return *this;
2218}
2219
2220inline wxDateSpan& wxDateSpan::operator-=(const wxDateSpan& other)
2221{
2222 return *this += other.Negate();
2223}
2224
2225inline wxDateSpan& wxDateSpan::Subtract(const wxDateSpan& other)
2226{
2227 return *this -= other;
2228}
2229
2230inline wxDateSpan wxDateSpan::Subtract(const wxDateSpan& other) const
2231{
2232 wxDateSpan ds(*this);
2233 ds.Subtract(other);
2234 return ds;
2235}
2236
2237#undef MILLISECONDS_PER_DAY
2238
2239#undef MODIFY_AND_RETURN
2240
0979c962
VZ
2241// ============================================================================
2242// binary operators
2243// ============================================================================
2244
0979c962
VZ
2245// ----------------------------------------------------------------------------
2246// wxTimeSpan operators
2247// ----------------------------------------------------------------------------
2248
26364344 2249wxTimeSpan WXDLLIMPEXP_BASE operator*(int n, const wxTimeSpan& ts);
0979c962
VZ
2250
2251// ----------------------------------------------------------------------------
2252// wxDateSpan
2253// ----------------------------------------------------------------------------
2254
26364344 2255wxDateSpan WXDLLIMPEXP_BASE operator*(int n, const wxDateSpan& ds);
cd0b1709
VZ
2256
2257// ============================================================================
2258// other helper functions
2259// ============================================================================
2260
2261// ----------------------------------------------------------------------------
2262// iteration helpers: can be used to write a for loop over enum variable like
2263// this:
2264// for ( m = wxDateTime::Jan; m < wxDateTime::Inv_Month; wxNextMonth(m) )
2265// ----------------------------------------------------------------------------
2266
26364344
WS
2267WXDLLIMPEXP_BASE void wxNextMonth(wxDateTime::Month& m);
2268WXDLLIMPEXP_BASE void wxPrevMonth(wxDateTime::Month& m);
2269WXDLLIMPEXP_BASE void wxNextWDay(wxDateTime::WeekDay& wd);
2270WXDLLIMPEXP_BASE void wxPrevWDay(wxDateTime::WeekDay& wd);
0979c962 2271
e421922f
VZ
2272#endif // wxUSE_DATETIME
2273
2f02cb89 2274#endif // _WX_DATETIME_H