]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: datetime.h | |
e54c96f1 | 3 | // Purpose: interface of wxDateTime |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
526954c5 | 6 | // Licence: wxWindows licence |
23324ae1 FM |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
9 | /** | |
10 | @class wxDateTime | |
7c913512 | 11 | |
e73d7e56 | 12 | wxDateTime class represents an absolute moment in time. |
7c913512 | 13 | |
b9da294f BP |
14 | The type @c wxDateTime_t is typedefed as <tt>unsigned short</tt> and is |
15 | used to contain the number of years, hours, minutes, seconds and | |
16 | milliseconds. | |
17 | ||
a3fc1c94 | 18 | Global constant ::wxDefaultDateTime and synonym for it ::wxInvalidDateTime are |
b9da294f BP |
19 | defined. This constant will be different from any valid wxDateTime object. |
20 | ||
b9da294f BP |
21 | |
22 | @section datetime_static Static Functions | |
23 | ||
24 | All static functions either set or return the static variables of | |
25 | wxDateSpan (the country), return the current moment, year, month or number | |
26 | of days in it, or do some general calendar-related actions. | |
27 | ||
28 | Please note that although several function accept an extra Calendar | |
29 | parameter, it is currently ignored as only the Gregorian calendar is | |
30 | supported. Future versions will support other calendars. | |
31 | ||
b9da294f BP |
32 | @section datetime_formatting Date Formatting and Parsing |
33 | ||
34 | The date formatting and parsing functions convert wxDateTime objects to and | |
35 | from text. The conversions to text are mostly trivial: you can either do it | |
36 | using the default date and time representations for the current locale | |
37 | (FormatDate() and FormatTime()), using the international standard | |
38 | representation defined by ISO 8601 (FormatISODate(), FormatISOTime() and | |
39 | FormatISOCombined()) or by specifying any format at all and using Format() | |
40 | directly. | |
41 | ||
42 | The conversions from text are more interesting, as there are much more | |
43 | possibilities to care about. The simplest cases can be taken care of with | |
44 | ParseFormat() which can parse any date in the given (rigid) format. | |
45 | ParseRfc822Date() is another function for parsing dates in predefined | |
46 | format -- the one of RFC 822 which (still...) defines the format of email | |
57ab6f23 | 47 | messages on the Internet. This format cannot be described with |
b9da294f BP |
48 | @c strptime(3)-like format strings used by Format(), hence the need for a |
49 | separate function. | |
50 | ||
51 | But the most interesting functions are ParseTime(), ParseDate() and | |
52 | ParseDateTime(). They try to parse the date and time (or only one of them) | |
53 | in 'free' format, i.e. allow them to be specified in any of possible ways. | |
54 | These functions will usually be used to parse the (interactive) user input | |
55 | which is not bound to be in any predefined format. As an example, | |
7633bfcd | 56 | ParseDate() can parse the strings such as "tomorrow", "March first" and |
b9da294f BP |
57 | even "next Sunday". |
58 | ||
59 | Finally notice that each of the parsing functions is available in several | |
60 | overloads: if the input string is a narrow (@c char *) string, then a | |
61 | narrow pointer is returned. If the input string is a wide string, a wide | |
62 | char pointer is returned. Finally, if the input parameter is a wxString, a | |
63 | narrow char pointer is also returned for backwards compatibility but there | |
64 | is also an additional argument of wxString::const_iterator type in which, | |
65 | if it is not @NULL, an iterator pointing to the end of the scanned string | |
66 | part is returned. | |
67 | ||
68 | ||
23324ae1 FM |
69 | @library{wxbase} |
70 | @category{data} | |
7c913512 | 71 | |
65874118 | 72 | @stdobjects |
b9da294f | 73 | - ::wxDefaultDateTime |
65874118 | 74 | |
b9da294f | 75 | @see @ref overview_datetime, wxTimeSpan, wxDateSpan, wxCalendarCtrl |
23324ae1 | 76 | */ |
7c913512 | 77 | class wxDateTime |
23324ae1 FM |
78 | { |
79 | public: | |
a3fc1c94 FM |
80 | /** |
81 | A small unsigned integer type for storing things like minutes, | |
82 | seconds &c. It should be at least short (i.e. not char) to contain | |
83 | the number of milliseconds - it may also be 'int' because there is | |
84 | no size penalty associated with it in our code, we don't store any | |
85 | data in this format. | |
86 | */ | |
87 | typedef unsigned short wxDateTime_t; | |
88 | ||
89 | ||
90 | /** | |
91 | Time zone symbolic names. | |
92 | */ | |
93 | enum TZ | |
94 | { | |
95 | /// the time in the current time zone | |
96 | Local, | |
97 | ||
98 | //@{ | |
57ab6f23 | 99 | /// zones from GMT (= Greenwich Mean Time): they're guaranteed to be |
a3fc1c94 FM |
100 | /// consequent numbers, so writing something like `GMT0 + offset' is |
101 | /// safe if abs(offset) <= 12 | |
102 | ||
103 | // underscore stands for minus | |
104 | GMT_12, GMT_11, GMT_10, GMT_9, GMT_8, GMT_7, | |
105 | GMT_6, GMT_5, GMT_4, GMT_3, GMT_2, GMT_1, | |
106 | GMT0, | |
107 | GMT1, GMT2, GMT3, GMT4, GMT5, GMT6, | |
108 | GMT7, GMT8, GMT9, GMT10, GMT11, GMT12, GMT13, | |
109 | // Note that GMT12 and GMT_12 are not the same: there is a difference | |
110 | // of exactly one day between them | |
111 | //@} | |
112 | ||
113 | // some symbolic names for TZ | |
114 | ||
115 | // Europe | |
116 | WET = GMT0, //!< Western Europe Time | |
117 | WEST = GMT1, //!< Western Europe Summer Time | |
118 | CET = GMT1, //!< Central Europe Time | |
119 | CEST = GMT2, //!< Central Europe Summer Time | |
120 | EET = GMT2, //!< Eastern Europe Time | |
121 | EEST = GMT3, //!< Eastern Europe Summer Time | |
122 | MSK = GMT3, //!< Moscow Time | |
123 | MSD = GMT4, //!< Moscow Summer Time | |
124 | ||
125 | // US and Canada | |
126 | AST = GMT_4, //!< Atlantic Standard Time | |
127 | ADT = GMT_3, //!< Atlantic Daylight Time | |
128 | EST = GMT_5, //!< Eastern Standard Time | |
129 | EDT = GMT_4, //!< Eastern Daylight Saving Time | |
130 | CST = GMT_6, //!< Central Standard Time | |
131 | CDT = GMT_5, //!< Central Daylight Saving Time | |
132 | MST = GMT_7, //!< Mountain Standard Time | |
133 | MDT = GMT_6, //!< Mountain Daylight Saving Time | |
134 | PST = GMT_8, //!< Pacific Standard Time | |
135 | PDT = GMT_7, //!< Pacific Daylight Saving Time | |
136 | HST = GMT_10, //!< Hawaiian Standard Time | |
137 | AKST = GMT_9, //!< Alaska Standard Time | |
138 | AKDT = GMT_8, //!< Alaska Daylight Saving Time | |
139 | ||
140 | // Australia | |
141 | ||
142 | A_WST = GMT8, //!< Western Standard Time | |
143 | A_CST = GMT13 + 1, //!< Central Standard Time (+9.5) | |
144 | A_EST = GMT10, //!< Eastern Standard Time | |
145 | A_ESST = GMT11, //!< Eastern Summer Time | |
146 | ||
147 | // New Zealand | |
148 | NZST = GMT12, //!< Standard Time | |
149 | NZDT = GMT13, //!< Daylight Saving Time | |
150 | ||
151 | /// Universal Coordinated Time = the new and politically correct name | |
152 | /// for GMT. | |
153 | UTC = GMT0 | |
154 | }; | |
155 | ||
156 | /** | |
157 | Several functions accept an extra parameter specifying the calendar to use | |
158 | (although most of them only support now the Gregorian calendar). This | |
159 | parameters is one of the following values. | |
160 | */ | |
161 | enum Calendar | |
162 | { | |
163 | Gregorian, ///< calendar currently in use in Western countries | |
164 | Julian ///< calendar in use since -45 until the 1582 (or later) | |
165 | }; | |
166 | ||
400930d3 VZ |
167 | /** |
168 | Values corresponding to different dates of adoption of the Gregorian | |
169 | calendar. | |
170 | ||
171 | @see IsGregorianDate | |
172 | */ | |
173 | enum GregorianAdoption | |
174 | { | |
175 | Gr_Unknown, ///< no data for this country or it's too uncertain to use | |
176 | Gr_Standard, ///< on the day 0 of Gregorian calendar: 15 Oct 1582 | |
177 | ||
178 | Gr_Alaska, ///< Oct 1867 when Alaska became part of the USA | |
179 | Gr_Albania, ///< Dec 1912 | |
180 | ||
181 | Gr_Austria = Gr_Unknown, ///< Different regions on different dates | |
182 | Gr_Austria_Brixen, ///< 5 Oct 1583 -> 16 Oct 1583 | |
183 | Gr_Austria_Salzburg = Gr_Austria_Brixen, | |
184 | Gr_Austria_Tyrol = Gr_Austria_Brixen, | |
185 | Gr_Austria_Carinthia, ///< 14 Dec 1583 -> 25 Dec 1583 | |
186 | Gr_Austria_Styria = Gr_Austria_Carinthia, | |
187 | ||
188 | Gr_Belgium, ///< Then part of the Netherlands | |
189 | ||
190 | Gr_Bulgaria = Gr_Unknown, ///< Unknown precisely (from 1915 to 1920) | |
191 | Gr_Bulgaria_1, ///< 18 Mar 1916 -> 1 Apr 1916 | |
192 | Gr_Bulgaria_2, ///< 31 Mar 1916 -> 14 Apr 1916 | |
193 | Gr_Bulgaria_3, ///< 3 Sep 1920 -> 17 Sep 1920 | |
194 | ||
195 | Gr_Canada = Gr_Unknown, ///< Different regions followed the changes in | |
196 | ///< Great Britain or France | |
197 | ||
198 | Gr_China = Gr_Unknown, ///< Different authorities say: | |
199 | Gr_China_1, ///< 18 Dec 1911 -> 1 Jan 1912 | |
200 | Gr_China_2, ///< 18 Dec 1928 -> 1 Jan 1929 | |
201 | ||
202 | Gr_Czechoslovakia, ///< (Bohemia and Moravia) 6 Jan 1584 -> 17 Jan 1584 | |
203 | Gr_Denmark, ///< (including Norway) 18 Feb 1700 -> 1 Mar 1700 | |
204 | Gr_Egypt, ///< 1875 | |
205 | Gr_Estonia, ///< 1918 | |
206 | Gr_Finland, ///< Then part of Sweden | |
207 | ||
208 | Gr_France, ///< 9 Dec 1582 -> 20 Dec 1582 | |
209 | Gr_France_Alsace, ///< 4 Feb 1682 -> 16 Feb 1682 | |
210 | Gr_France_Lorraine, ///< 16 Feb 1760 -> 28 Feb 1760 | |
211 | Gr_France_Strasbourg, ///< February 1682 | |
212 | ||
213 | Gr_Germany = Gr_Unknown, ///< Different states on different dates: | |
214 | Gr_Germany_Catholic, ///< 1583-1585 (we take 1584) | |
215 | Gr_Germany_Prussia, ///< 22 Aug 1610 -> 2 Sep 1610 | |
216 | Gr_Germany_Protestant, ///< 18 Feb 1700 -> 1 Mar 1700 | |
217 | ||
218 | Gr_GreatBritain, ///< 2 Sep 1752 -> 14 Sep 1752 (use 'cal(1)') | |
219 | ||
220 | Gr_Greece, ///< 9 Mar 1924 -> 23 Mar 1924 | |
221 | Gr_Hungary, ///< 21 Oct 1587 -> 1 Nov 1587 | |
222 | Gr_Ireland = Gr_GreatBritain, | |
223 | Gr_Italy = Gr_Standard, | |
224 | ||
225 | Gr_Japan = Gr_Unknown, ///< Different authorities say: | |
226 | Gr_Japan_1, ///< 19 Dec 1872 -> 1 Jan 1873 | |
227 | Gr_Japan_2, ///< 19 Dec 1892 -> 1 Jan 1893 | |
228 | Gr_Japan_3, ///< 18 Dec 1918 -> 1 Jan 1919 | |
229 | ||
230 | Gr_Latvia, ///< 1915-1918 (we take 1915) | |
231 | Gr_Lithuania, ///< 1915 | |
232 | Gr_Luxemburg, ///< 14 Dec 1582 -> 25 Dec 1582 | |
233 | Gr_Netherlands = Gr_Belgium, ///< (including Belgium) 1 Jan 1583 | |
234 | ||
235 | /** | |
236 | Special case of Groningen. | |
237 | ||
238 | The Gregorian calendar was introduced twice in Groningen, first | |
239 | time 28 Feb 1583 was followed by 11 Mar 1583, then it has gone back | |
240 | to Julian in the summer of 1584 and then 13 Dec 1700 was followed | |
241 | by 12 Jan 1701 -- which is the date we take into account here. | |
242 | */ | |
243 | Gr_Netherlands_Groningen, ///< 13 Dec 1700 -> 12 Jan 1701 | |
244 | Gr_Netherlands_Gelderland, ///< 30 Jun 1700 -> 12 Jul 1700 | |
245 | Gr_Netherlands_Utrecht, ///< (and Overijssel) 30 Nov 1700->12 Dec 1700 | |
246 | Gr_Netherlands_Friesland, ///< (and Drenthe) 31 Dec 1700 -> 12 Jan 1701 | |
247 | ||
248 | Gr_Norway = Gr_Denmark, ///< Then part of Denmark | |
249 | Gr_Poland = Gr_Standard, | |
250 | Gr_Portugal = Gr_Standard, | |
251 | Gr_Romania, ///< 31 Mar 1919 -> 14 Apr 1919 | |
252 | Gr_Russia, ///< 31 Jan 1918 -> 14 Feb 1918 | |
253 | Gr_Scotland = Gr_GreatBritain, | |
254 | Gr_Spain = Gr_Standard, | |
255 | ||
256 | /** | |
257 | Special case of Sweden. | |
258 | ||
259 | Sweden has a curious history. Sweden decided to make a gradual | |
260 | change from the Julian to the Gregorian calendar. By dropping every | |
261 | leap year from 1700 through 1740 the eleven superfluous days would | |
262 | be omitted and from 1 Mar 1740 they would be in sync with the | |
263 | Gregorian calendar. (But in the meantime they would be in sync with | |
264 | nobody!) | |
265 | ||
266 | So 1700 (which should have been a leap year in the Julian calendar) | |
267 | was not a leap year in Sweden. However, by mistake 1704 and 1708 | |
268 | became leap years. This left Sweden out of synchronisation with | |
269 | both the Julian and the Gregorian world, so they decided to go back | |
270 | to the Julian calendar. In order to do this, they inserted an extra | |
271 | day in 1712, making that year a double leap year! So in 1712, | |
272 | February had 30 days in Sweden. | |
273 | ||
274 | Later, in 1753, Sweden changed to the Gregorian calendar by | |
275 | dropping 11 days like everyone else and this is what we use here. | |
276 | */ | |
277 | Gr_Sweden = Gr_Finland, ///< 17 Feb 1753 -> 1 Mar 1753 | |
278 | ||
279 | Gr_Switzerland = Gr_Unknown,///< Different cantons used different dates | |
280 | Gr_Switzerland_Catholic, ///< 1583, 1584 or 1597 (we take 1584) | |
281 | Gr_Switzerland_Protestant, ///< 31 Dec 1700 -> 12 Jan 1701 | |
282 | ||
283 | Gr_Turkey, ///< 1 Jan 1927 | |
284 | Gr_USA = Gr_GreatBritain, | |
285 | Gr_Wales = Gr_GreatBritain, | |
286 | Gr_Yugoslavia ///< 1919 | |
287 | }; | |
288 | ||
a3fc1c94 FM |
289 | /** |
290 | Date calculations often depend on the country and wxDateTime allows to set | |
291 | the country whose conventions should be used using SetCountry(). It takes | |
292 | one of the following values as parameter. | |
293 | */ | |
294 | enum Country | |
295 | { | |
296 | Country_Unknown, ///< no special information for this country | |
297 | Country_Default, ///< set the default country with SetCountry() method | |
298 | ///< or use the default country with any other | |
299 | ||
300 | Country_WesternEurope_Start, | |
301 | Country_EEC = Country_WesternEurope_Start, | |
302 | France, | |
303 | Germany, | |
304 | UK, | |
305 | Country_WesternEurope_End = UK, | |
306 | ||
307 | Russia, | |
308 | ||
309 | USA | |
310 | }; | |
311 | ||
312 | /// symbolic names for the months | |
313 | enum Month | |
314 | { | |
315 | Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, | |
316 | ||
317 | /// Invalid month value. | |
318 | Inv_Month | |
319 | }; | |
320 | ||
321 | /// symbolic names for the weekdays | |
322 | enum WeekDay | |
323 | { | |
324 | Sun, Mon, Tue, Wed, Thu, Fri, Sat, | |
325 | ||
326 | /// Invalid week day value. | |
327 | Inv_WeekDay | |
328 | }; | |
329 | ||
330 | /// invalid value for the year | |
331 | enum Year | |
332 | { | |
333 | Inv_Year = SHRT_MIN // should hold in wxDateTime_t | |
334 | }; | |
335 | ||
336 | /** | |
337 | Flags to be used with GetMonthName() and GetWeekDayName() functions. | |
338 | */ | |
339 | enum NameFlags | |
340 | { | |
341 | Name_Full = 0x01, ///< return full name | |
342 | Name_Abbr = 0x02 ///< return abbreviated name | |
343 | }; | |
344 | ||
345 | /** | |
346 | Different parts of the world use different conventions for the week start. | |
347 | In some countries, the week starts on Sunday, while in others -- on Monday. | |
348 | The ISO standard doesn't address this issue, so we support both conventions | |
349 | in the functions whose result depends on it (GetWeekOfYear() and | |
350 | GetWeekOfMonth()). | |
351 | ||
57ab6f23 | 352 | The desired behaviour may be specified by giving one of the following |
a3fc1c94 FM |
353 | constants as argument to these functions. |
354 | */ | |
355 | enum WeekFlags | |
356 | { | |
357 | Default_First, ///< Sunday_First for US, Monday_First for the rest | |
358 | Monday_First, ///< week starts with a Monday | |
359 | Sunday_First ///< week starts with a Sunday | |
360 | }; | |
361 | ||
362 | ||
400930d3 VZ |
363 | /** |
364 | Class representing a time zone. | |
365 | ||
366 | The representation is simply the offset, in seconds, from UTC. | |
367 | */ | |
368 | class WXDLLIMPEXP_BASE TimeZone | |
369 | { | |
370 | public: | |
371 | /// Constructor for a named time zone. | |
372 | TimeZone(TZ tz); | |
373 | ||
374 | /// Constructor for the given offset in seconds. | |
375 | TimeZone(long offset = 0); | |
376 | ||
377 | /// Create a time zone with the given offset in seconds. | |
378 | static TimeZone Make(long offset); | |
379 | ||
380 | /// Return the offset of this time zone from UTC, in seconds. | |
381 | long GetOffset() const; | |
382 | }; | |
383 | ||
5ed8879e VZ |
384 | /** |
385 | Contains broken down date-time representation. | |
386 | ||
387 | This struct is analogous to standard C <code>struct tm</code> and uses | |
388 | the same, not always immediately obvious, conventions for its members: | |
389 | notably its mon and mday fields count from 0 while yday counts from 1. | |
390 | */ | |
391 | struct Tm | |
392 | { | |
393 | wxDateTime_t msec, ///< Number of milliseconds. | |
394 | sec, ///< Seconds in 0..59 (60 with leap seconds) range. | |
395 | min, ///< Minutes in 0..59 range. | |
396 | hour, ///< Hours since midnight in 0..23 range. | |
397 | mday, ///< Day of the month in 1..31 range. | |
398 | yday; ///< Day of the year in 0..365 range. | |
399 | Month mon; ///< Month, as an enumerated constant. | |
400 | int year; ///< Year. | |
401 | ||
402 | /** | |
403 | Check if the given date/time is valid (in Gregorian calendar). | |
404 | ||
405 | Return @false if the components don't correspond to a correct date. | |
406 | */ | |
407 | bool IsValid() const; | |
408 | ||
409 | /** | |
410 | Return the week day corresponding to this date. | |
411 | ||
412 | Unlike the other fields, the week day is not always available and | |
413 | so must be accessed using this method as it is computed on demand | |
414 | when it is called. | |
415 | */ | |
416 | WeekDay GetWeekDay(); | |
417 | }; | |
418 | ||
419 | ||
23324ae1 | 420 | /** |
b9da294f BP |
421 | @name Constructors, Assignment Operators and Setters |
422 | ||
423 | Constructors and various Set() methods are collected here. If you | |
424 | construct a date object from separate values for day, month and year, | |
425 | you should use IsValid() method to check that the values were correct | |
57ab6f23 | 426 | as constructors cannot return an error code. |
23324ae1 | 427 | */ |
b9da294f | 428 | //@{ |
23324ae1 FM |
429 | |
430 | /** | |
b9da294f BP |
431 | Default constructor. Use one of the Set() functions to initialize the |
432 | object later. | |
433 | */ | |
434 | wxDateTime(); | |
e73d7e56 RD |
435 | |
436 | /** | |
437 | Copy constructor. | |
438 | */ | |
439 | wxDateTime(const wxDateTime& date); | |
440 | ||
b9da294f BP |
441 | /** |
442 | Same as Set(). | |
b9da294f | 443 | */ |
882678eb | 444 | wxDateTime(time_t timet); |
b9da294f BP |
445 | /** |
446 | Same as Set(). | |
b9da294f | 447 | */ |
882678eb | 448 | wxDateTime(const struct tm& tm); |
b9da294f BP |
449 | /** |
450 | Same as Set(). | |
b9da294f | 451 | */ |
882678eb | 452 | wxDateTime(double jdn); |
b9da294f BP |
453 | /** |
454 | Same as Set(). | |
b9da294f | 455 | */ |
882678eb FM |
456 | wxDateTime(wxDateTime_t hour, wxDateTime_t minute = 0, |
457 | wxDateTime_t second = 0, wxDateTime_t millisec = 0); | |
b9da294f BP |
458 | /** |
459 | Same as Set(). | |
b9da294f | 460 | */ |
e73d7e56 | 461 | wxDateTime(wxDateTime_t day, Month month, |
b9da294f BP |
462 | int year = Inv_Year, wxDateTime_t hour = 0, |
463 | wxDateTime_t minute = 0, wxDateTime_t second = 0, | |
464 | wxDateTime_t millisec = 0); | |
3c4f71cc | 465 | |
154014d6 VZ |
466 | /** |
467 | Same as SetFromMSWSysTime. | |
468 | ||
469 | @param st | |
470 | Input, Windows SYSTEMTIME reference | |
471 | @since 2.9.0 | |
472 | @remarks MSW only | |
cb8ae613 | 473 | @onlyfor{wxmsw} |
154014d6 VZ |
474 | */ |
475 | wxDateTime(const struct _SYSTEMTIME& st); | |
476 | ||
477 | ||
b9da294f BP |
478 | /** |
479 | Reset time to midnight (00:00:00) without changing the date. | |
480 | */ | |
481 | wxDateTime& ResetTime(); | |
3c4f71cc | 482 | |
b9da294f BP |
483 | /** |
484 | Constructs the object from @a timet value holding the number of seconds | |
416d505e | 485 | since Jan 1, 1970 UTC. |
d2a02746 VZ |
486 | |
487 | If @a timet is invalid, i.e. @code (time_t)-1 @endcode, wxDateTime | |
488 | becomes invalid too, i.e. its IsValid() will return @false. | |
b9da294f BP |
489 | */ |
490 | wxDateTime& Set(time_t timet); | |
491 | /** | |
492 | Sets the date and time from the broken down representation in the | |
493 | standard @a tm structure. | |
b9da294f BP |
494 | */ |
495 | wxDateTime& Set(const struct tm& tm); | |
e73d7e56 RD |
496 | |
497 | /** | |
498 | Sets the date and time from the broken down representation in the | |
499 | @a wxDateTime::Tm structure. | |
500 | */ | |
501 | wxDateTime& Set(const Tm& tm); | |
502 | ||
b9da294f BP |
503 | /** |
504 | Sets the date from the so-called Julian Day Number. | |
3c4f71cc | 505 | |
b9da294f BP |
506 | By definition, the Julian Day Number, usually abbreviated as JDN, of a |
507 | particular instant is the fractional number of days since 12 hours | |
508 | Universal Coordinated Time (Greenwich mean noon) on January 1 of the | |
509 | year -4712 in the Julian proleptic calendar. | |
23324ae1 | 510 | */ |
b9da294f BP |
511 | wxDateTime& Set(double jdn); |
512 | /** | |
513 | Sets the date to be equal to Today() and the time from supplied | |
514 | parameters. | |
b9da294f BP |
515 | */ |
516 | wxDateTime& Set(wxDateTime_t hour, wxDateTime_t minute = 0, | |
517 | wxDateTime_t second = 0, wxDateTime_t millisec = 0); | |
23324ae1 | 518 | /** |
b9da294f | 519 | Sets the date and time from the parameters. |
23324ae1 | 520 | */ |
e73d7e56 | 521 | wxDateTime& Set(wxDateTime_t day, Month month, |
b9da294f BP |
522 | int year = Inv_Year, wxDateTime_t hour = 0, |
523 | wxDateTime_t minute = 0, wxDateTime_t second = 0, | |
524 | wxDateTime_t millisec = 0); | |
23324ae1 FM |
525 | |
526 | /** | |
b9da294f BP |
527 | Sets the day without changing other date components. |
528 | */ | |
382f12e4 | 529 | wxDateTime& SetDay(unsigned short day); |
3c4f71cc | 530 | |
b9da294f BP |
531 | /** |
532 | Sets the date from the date and time in DOS format. | |
533 | */ | |
534 | wxDateTime& SetFromDOS(unsigned long ddt); | |
3c4f71cc | 535 | |
b9da294f BP |
536 | /** |
537 | Sets the hour without changing other date components. | |
23324ae1 | 538 | */ |
382f12e4 | 539 | wxDateTime& SetHour(unsigned short hour); |
23324ae1 | 540 | |
b9da294f BP |
541 | /** |
542 | Sets the millisecond without changing other date components. | |
543 | */ | |
382f12e4 | 544 | wxDateTime& SetMillisecond(unsigned short millisecond); |
23324ae1 FM |
545 | |
546 | /** | |
b9da294f BP |
547 | Sets the minute without changing other date components. |
548 | */ | |
382f12e4 | 549 | wxDateTime& SetMinute(unsigned short minute); |
3c4f71cc | 550 | |
b9da294f BP |
551 | /** |
552 | Sets the month without changing other date components. | |
553 | */ | |
554 | wxDateTime& SetMonth(Month month); | |
3c4f71cc | 555 | |
b9da294f BP |
556 | /** |
557 | Sets the second without changing other date components. | |
558 | */ | |
382f12e4 | 559 | wxDateTime& SetSecond(unsigned short second); |
3c4f71cc | 560 | |
b9da294f BP |
561 | /** |
562 | Sets the date and time of to the current values. Same as assigning the | |
563 | result of Now() to this object. | |
564 | */ | |
565 | wxDateTime& SetToCurrent(); | |
3c4f71cc | 566 | |
b9da294f BP |
567 | /** |
568 | Sets the year without changing other date components. | |
569 | */ | |
570 | wxDateTime& SetYear(int year); | |
3c4f71cc | 571 | |
b9da294f BP |
572 | /** |
573 | Same as Set(). | |
574 | */ | |
575 | wxDateTime& operator=(time_t timet); | |
576 | /** | |
577 | Same as Set(). | |
578 | */ | |
579 | wxDateTime& operator=(const struct tm& tm); | |
3c4f71cc | 580 | |
b9da294f | 581 | //@} |
3c4f71cc | 582 | |
3c4f71cc | 583 | |
3c4f71cc | 584 | |
b9da294f BP |
585 | /** |
586 | @name Accessors | |
3c4f71cc | 587 | |
b9da294f BP |
588 | Here are the trivial accessors. Other functions, which might have to |
589 | perform some more complicated calculations to find the answer are under | |
590 | the "Date Arithmetics" section. | |
591 | */ | |
592 | //@{ | |
3c4f71cc | 593 | |
b9da294f BP |
594 | /** |
595 | Returns the date and time in DOS format. | |
596 | */ | |
e73d7e56 | 597 | unsigned long GetAsDOS() const; |
3c4f71cc | 598 | |
154014d6 VZ |
599 | /** |
600 | Initialize using the Windows SYSTEMTIME structure. | |
601 | @param st | |
602 | Input, Windows SYSTEMTIME reference | |
603 | @since 2.9.0 | |
604 | @remarks MSW only | |
cb8ae613 | 605 | @onlyfor{wxmsw} |
154014d6 VZ |
606 | */ |
607 | wxDateTime& SetFromMSWSysTime(const struct _SYSTEMTIME& st); | |
608 | ||
609 | /** | |
610 | Returns the date and time in the Windows SYSTEMTIME format. | |
611 | @param st | |
612 | Output, pointer to Windows SYSTEMTIME | |
613 | @since 2.9.0 | |
614 | @remarks MSW only | |
cb8ae613 | 615 | @onlyfor{wxmsw} |
154014d6 VZ |
616 | */ |
617 | void GetAsMSWSysTime(struct _SYSTEMTIME* st) const; | |
618 | ||
b9da294f BP |
619 | /** |
620 | Returns the century of this date. | |
621 | */ | |
622 | int GetCentury(const TimeZone& tz = Local) const; | |
3c4f71cc | 623 | |
1a21919b BP |
624 | /** |
625 | Returns the object having the same date component as this one but time | |
626 | of 00:00:00. | |
627 | ||
1e24c2af | 628 | @since 2.8.2 |
1a21919b BP |
629 | |
630 | @see ResetTime() | |
631 | */ | |
632 | wxDateTime GetDateOnly() const; | |
633 | ||
b9da294f BP |
634 | /** |
635 | Returns the day in the given timezone (local one by default). | |
636 | */ | |
e73d7e56 | 637 | unsigned short GetDay(const TimeZone& tz = Local) const; |
3c4f71cc | 638 | |
b9da294f | 639 | /** |
1a21919b | 640 | Returns the day of the year (in 1-366 range) in the given timezone |
b9da294f | 641 | (local one by default). |
23324ae1 | 642 | */ |
e73d7e56 | 643 | unsigned short GetDayOfYear(const TimeZone& tz = Local) const; |
23324ae1 | 644 | |
1a21919b BP |
645 | /** |
646 | Returns the hour in the given timezone (local one by default). | |
647 | */ | |
e73d7e56 | 648 | unsigned short GetHour(const TimeZone& tz = Local) const; |
1a21919b | 649 | |
b9da294f BP |
650 | /** |
651 | Returns the milliseconds in the given timezone (local one by default). | |
652 | */ | |
e73d7e56 | 653 | unsigned short GetMillisecond(const TimeZone& tz = Local) const; |
23324ae1 FM |
654 | |
655 | /** | |
b9da294f BP |
656 | Returns the minute in the given timezone (local one by default). |
657 | */ | |
e73d7e56 | 658 | unsigned short GetMinute(const TimeZone& tz = Local) const; |
3c4f71cc | 659 | |
b9da294f BP |
660 | /** |
661 | Returns the month in the given timezone (local one by default). | |
662 | */ | |
663 | Month GetMonth(const TimeZone& tz = Local) const; | |
3c4f71cc | 664 | |
b9da294f BP |
665 | /** |
666 | Returns the seconds in the given timezone (local one by default). | |
667 | */ | |
e73d7e56 | 668 | unsigned short GetSecond(const TimeZone& tz = Local) const; |
3c4f71cc | 669 | |
b9da294f | 670 | /** |
416d505e VZ |
671 | Returns the number of seconds since Jan 1, 1970 UTC. |
672 | ||
673 | An assert failure will occur if the date is not in the range covered by | |
674 | @c time_t type, use GetValue() if you work with dates outside of it. | |
b9da294f BP |
675 | */ |
676 | time_t GetTicks() const; | |
3c4f71cc | 677 | |
b9da294f | 678 | /** |
1a21919b | 679 | Returns broken down representation of the date and time. |
b9da294f | 680 | */ |
1a21919b | 681 | Tm GetTm(const TimeZone& tz = Local) const; |
3c4f71cc | 682 | |
b9da294f | 683 | /** |
1a21919b | 684 | Returns the week day in the given timezone (local one by default). |
b9da294f | 685 | */ |
1a21919b | 686 | WeekDay GetWeekDay(const TimeZone& tz = Local) const; |
3c4f71cc | 687 | |
b9da294f | 688 | /** |
1a21919b BP |
689 | Returns the ordinal number of the week in the month (in 1-5 range). |
690 | ||
691 | As GetWeekOfYear(), this function supports both conventions for the | |
d7612120 | 692 | week start. |
b9da294f BP |
693 | */ |
694 | wxDateTime_t GetWeekOfMonth(WeekFlags flags = Monday_First, | |
695 | const TimeZone& tz = Local) const; | |
3c4f71cc | 696 | |
b9da294f | 697 | /** |
1a21919b BP |
698 | Returns the number of the week of the year this date is in. The first |
699 | week of the year is, according to international standards, the one | |
700 | containing Jan 4 or, equivalently, the first week which has Thursday in | |
701 | this year. Both of these definitions are the same as saying that the | |
702 | first week of the year must contain more than half of its days in this | |
703 | year. Accordingly, the week number will always be in 1-53 range (52 for | |
704 | non-leap years). | |
705 | ||
d7612120 FM |
706 | The function depends on the week start convention specified by the @a flags |
707 | argument but its results for @c Sunday_First are not well-defined as the | |
708 | ISO definition quoted above applies to the weeks starting on Monday only. | |
b9da294f BP |
709 | */ |
710 | wxDateTime_t GetWeekOfYear(WeekFlags flags = Monday_First, | |
711 | const TimeZone& tz = Local) const; | |
3c4f71cc | 712 | |
b9da294f BP |
713 | /** |
714 | Returns the year in the given timezone (local one by default). | |
715 | */ | |
716 | int GetYear(const TimeZone& tz = Local) const; | |
3c4f71cc | 717 | |
b9da294f | 718 | /** |
1a21919b BP |
719 | Returns @true if the given date is later than the date of adoption of |
720 | the Gregorian calendar in the given country (and hence the Gregorian | |
721 | calendar calculations make sense for it). | |
b9da294f BP |
722 | */ |
723 | bool IsGregorianDate(GregorianAdoption country = Gr_Standard) const; | |
3c4f71cc | 724 | |
b9da294f BP |
725 | /** |
726 | Returns @true if the object represents a valid time moment. | |
727 | */ | |
728 | bool IsValid() const; | |
3c4f71cc | 729 | |
b9da294f BP |
730 | /** |
731 | Returns @true is this day is not a holiday in the given country. | |
732 | */ | |
733 | bool IsWorkDay(Country country = Country_Default) const; | |
3c4f71cc | 734 | |
b9da294f | 735 | //@} |
3c4f71cc | 736 | |
3c4f71cc | 737 | |
3c4f71cc | 738 | |
b9da294f BP |
739 | /** |
740 | @name Date Comparison | |
3c4f71cc | 741 | |
b9da294f BP |
742 | There are several functions to allow date comparison. To supplement |
743 | them, a few global operators, etc taking wxDateTime are defined. | |
744 | */ | |
745 | //@{ | |
3c4f71cc | 746 | |
b9da294f BP |
747 | /** |
748 | Returns @true if this date precedes the given one. | |
749 | */ | |
750 | bool IsEarlierThan(const wxDateTime& datetime) const; | |
3c4f71cc | 751 | |
b9da294f BP |
752 | /** |
753 | Returns @true if the two dates are strictly identical. | |
754 | */ | |
755 | bool IsEqualTo(const wxDateTime& datetime) const; | |
3c4f71cc | 756 | |
b9da294f BP |
757 | /** |
758 | Returns @true if the date is equal to another one up to the given time | |
0824e369 | 759 | interval, i.e.\ if the absolute difference between the two dates is less |
1a21919b | 760 | than this interval. |
b9da294f BP |
761 | */ |
762 | bool IsEqualUpTo(const wxDateTime& dt, const wxTimeSpan& ts) const; | |
3c4f71cc | 763 | |
b9da294f BP |
764 | /** |
765 | Returns @true if this date is later than the given one. | |
766 | */ | |
767 | bool IsLaterThan(const wxDateTime& datetime) const; | |
3c4f71cc | 768 | |
b9da294f BP |
769 | /** |
770 | Returns @true if the date is the same without comparing the time parts. | |
23324ae1 | 771 | */ |
b9da294f | 772 | bool IsSameDate(const wxDateTime& dt) const; |
23324ae1 | 773 | |
b9da294f BP |
774 | /** |
775 | Returns @true if the time is the same (although dates may differ). | |
776 | */ | |
777 | bool IsSameTime(const wxDateTime& dt) const; | |
23324ae1 FM |
778 | |
779 | /** | |
1a21919b | 780 | Returns @true if this date lies strictly between the two given dates. |
b9da294f BP |
781 | |
782 | @see IsBetween() | |
23324ae1 | 783 | */ |
b9da294f BP |
784 | bool IsStrictlyBetween(const wxDateTime& t1, |
785 | const wxDateTime& t2) const; | |
23324ae1 FM |
786 | |
787 | /** | |
1a21919b BP |
788 | Returns @true if IsStrictlyBetween() is @true or if the date is equal |
789 | to one of the limit values. | |
3c4f71cc | 790 | |
b9da294f BP |
791 | @see IsStrictlyBetween() |
792 | */ | |
793 | bool IsBetween(const wxDateTime& t1, const wxDateTime& t2) const; | |
3c4f71cc | 794 | |
b9da294f | 795 | //@} |
3c4f71cc | 796 | |
3c4f71cc | 797 | |
3c4f71cc | 798 | |
b9da294f BP |
799 | /** |
800 | @name Date Arithmetics | |
3c4f71cc | 801 | |
b9da294f BP |
802 | These functions carry out |
803 | @ref overview_datetime_arithmetics "arithmetics" on the wxDateTime | |
804 | objects. As explained in the overview, either wxTimeSpan or wxDateSpan | |
805 | may be added to wxDateTime, hence all functions are overloaded to | |
806 | accept both arguments. | |
3c4f71cc | 807 | |
b9da294f BP |
808 | Also, both Add() and Subtract() have both const and non-const version. |
809 | The first one returns a new object which represents the sum/difference | |
810 | of the original one with the argument while the second form modifies | |
811 | the object to which it is applied. The operators "-=" and "+=" are | |
812 | defined to be equivalent to the second forms of these functions. | |
23324ae1 | 813 | */ |
b9da294f | 814 | //@{ |
23324ae1 | 815 | |
b9da294f BP |
816 | /** |
817 | Adds the given date span to this object. | |
1a21919b BP |
818 | */ |
819 | wxDateTime Add(const wxDateSpan& diff) const; | |
820 | /** | |
821 | Adds the given date span to this object. | |
b9da294f | 822 | */ |
19058c76 | 823 | wxDateTime& Add(const wxDateSpan& diff); |
1a21919b BP |
824 | /** |
825 | Adds the given time span to this object. | |
1a21919b BP |
826 | */ |
827 | wxDateTime Add(const wxTimeSpan& diff) const; | |
23324ae1 | 828 | /** |
1a21919b | 829 | Adds the given time span to this object. |
b9da294f | 830 | */ |
1a21919b | 831 | wxDateTime& Add(const wxTimeSpan& diff); |
3c4f71cc | 832 | |
b9da294f | 833 | /** |
1a21919b | 834 | Subtracts the given time span from this object. |
b9da294f | 835 | */ |
1a21919b BP |
836 | wxDateTime Subtract(const wxTimeSpan& diff) const; |
837 | /** | |
838 | Subtracts the given time span from this object. | |
1a21919b BP |
839 | */ |
840 | wxDateTime& Subtract(const wxTimeSpan& diff); | |
841 | /** | |
842 | Subtracts the given date span from this object. | |
1a21919b BP |
843 | */ |
844 | wxDateTime Subtract(const wxDateSpan& diff) const; | |
845 | /** | |
846 | Subtracts the given date span from this object. | |
1a21919b BP |
847 | */ |
848 | wxDateTime& Subtract(const wxDateSpan& diff); | |
b9da294f | 849 | /** |
1a21919b BP |
850 | Subtracts another date from this one and returns the difference between |
851 | them as a wxTimeSpan. | |
b9da294f BP |
852 | */ |
853 | wxTimeSpan Subtract(const wxDateTime& dt) const; | |
77dd7daa VZ |
854 | /** |
855 | Returns the difference between this object and @a dt as a wxDateSpan. | |
856 | ||
857 | This method allows to find the number of entire years, months, weeks and | |
858 | days between @a dt and this date. | |
859 | ||
860 | @since 2.9.5 | |
861 | */ | |
862 | wxDateSpan DiffAsDateSpan(const wxDateTime& dt) const; | |
3c4f71cc | 863 | |
1a21919b BP |
864 | /** |
865 | Adds the given date span to this object. | |
866 | */ | |
cb8ae613 | 867 | wxDateTime& operator+=(const wxDateSpan& diff); |
19058c76 VZ |
868 | /** |
869 | Adds the given date span to this object. | |
870 | */ | |
871 | wxDateTime operator+(const wxDateSpan& ds) const; | |
1a21919b BP |
872 | /** |
873 | Subtracts the given date span from this object. | |
874 | */ | |
875 | wxDateTime& operator-=(const wxDateSpan& diff); | |
19058c76 VZ |
876 | /** |
877 | Subtracts the given date span from this object. | |
878 | */ | |
879 | wxDateTime operator-(const wxDateSpan& ds) const; | |
1a21919b BP |
880 | /** |
881 | Adds the given time span to this object. | |
882 | */ | |
883 | wxDateTime& operator+=(const wxTimeSpan& diff); | |
19058c76 VZ |
884 | /** |
885 | Adds the given time span to this object. | |
886 | */ | |
887 | wxDateTime operator+(const wxTimeSpan& ts) const; | |
1a21919b BP |
888 | /** |
889 | Subtracts the given time span from this object. | |
890 | */ | |
891 | wxDateTime& operator-=(const wxTimeSpan& diff); | |
19058c76 VZ |
892 | /** |
893 | Subtracts the given time span from this object. | |
894 | */ | |
895 | wxDateTime operator-(const wxTimeSpan& ts) const; | |
896 | /** | |
897 | Subtracts another date from this one and returns the difference between | |
898 | them as a wxTimeSpan. | |
899 | */ | |
900 | wxTimeSpan operator-(const wxDateTime& dt2) const; | |
1a21919b | 901 | |
b9da294f | 902 | //@} |
3c4f71cc | 903 | |
3c4f71cc | 904 | |
3c4f71cc | 905 | |
b9da294f BP |
906 | /** |
907 | @name Date Formatting and Parsing | |
3c4f71cc | 908 | |
b9da294f | 909 | See @ref datetime_formatting |
23324ae1 | 910 | */ |
b9da294f | 911 | //@{ |
23324ae1 FM |
912 | |
913 | /** | |
1a21919b | 914 | This function does the same as the standard ANSI C @c strftime(3) |
747199de FM |
915 | function (http://www.cplusplus.com/reference/clibrary/ctime/strftime.html). |
916 | Please see its description for the meaning of @a format parameter. | |
1a21919b BP |
917 | |
918 | It also accepts a few wxWidgets-specific extensions: you can optionally | |
919 | specify the width of the field to follow using @c printf(3)-like syntax | |
920 | and the format specification @c "%l" can be used to get the number of | |
921 | milliseconds. | |
3c4f71cc | 922 | |
4cc4bfaf | 923 | @see ParseFormat() |
23324ae1 | 924 | */ |
382f12e4 | 925 | wxString Format(const wxString& format = wxDefaultDateTimeFormat, |
328f5751 | 926 | const TimeZone& tz = Local) const; |
23324ae1 FM |
927 | |
928 | /** | |
1a21919b BP |
929 | Identical to calling Format() with @c "%x" argument (which means |
930 | "preferred date representation for the current locale"). | |
23324ae1 | 931 | */ |
328f5751 | 932 | wxString FormatDate() const; |
23324ae1 FM |
933 | |
934 | /** | |
935 | Returns the combined date-time representation in the ISO 8601 format | |
1a21919b BP |
936 | @c "YYYY-MM-DDTHH:MM:SS". The @a sep parameter default value produces |
937 | the result exactly corresponding to the ISO standard, but it can also | |
57ab6f23 | 938 | be useful to use a space as separator if a more human-readable combined |
1a21919b | 939 | date-time representation is needed. |
3c4f71cc | 940 | |
1a21919b | 941 | @see FormatISODate(), FormatISOTime(), ParseISOCombined() |
23324ae1 | 942 | */ |
328f5751 | 943 | wxString FormatISOCombined(char sep = 'T') const; |
23324ae1 FM |
944 | |
945 | /** | |
946 | This function returns the date representation in the ISO 8601 format | |
1a21919b | 947 | @c "YYYY-MM-DD". |
23324ae1 | 948 | */ |
328f5751 | 949 | wxString FormatISODate() const; |
23324ae1 FM |
950 | |
951 | /** | |
952 | This function returns the time representation in the ISO 8601 format | |
1a21919b | 953 | @c "HH:MM:SS". |
23324ae1 | 954 | */ |
328f5751 | 955 | wxString FormatISOTime() const; |
23324ae1 FM |
956 | |
957 | /** | |
1a21919b BP |
958 | Identical to calling Format() with @c "%X" argument (which means |
959 | "preferred time representation for the current locale"). | |
23324ae1 | 960 | */ |
328f5751 | 961 | wxString FormatTime() const; |
23324ae1 FM |
962 | |
963 | /** | |
1a21919b | 964 | This function is like ParseDateTime(), but it only allows the date to |
254696bb | 965 | be specified. |
1a21919b | 966 | |
254696bb VZ |
967 | It is thus less flexible then ParseDateTime(), but also has less |
968 | chances to misinterpret the user input. | |
969 | ||
970 | See ParseFormat() for the description of function parameters and return | |
971 | value. | |
747199de FM |
972 | |
973 | @see Format() | |
23324ae1 | 974 | */ |
c398434d | 975 | bool ParseDate(const wxString& date, wxString::const_iterator *end); |
23324ae1 | 976 | |
23324ae1 | 977 | /** |
1a21919b | 978 | Parses the string @a datetime containing the date and time in free |
254696bb | 979 | format. |
1a21919b | 980 | |
254696bb VZ |
981 | This function tries as hard as it can to interpret the given string as |
982 | date and time. Unlike ParseRfc822Date(), it will accept anything that | |
57ab6f23 | 983 | may be accepted and will only reject strings which cannot be parsed in |
7633bfcd VZ |
984 | any way at all. Notice that the function will fail if either date or |
985 | time part is present but not both, use ParseDate() or ParseTime() to | |
986 | parse strings containing just the date or time component. | |
254696bb VZ |
987 | |
988 | See ParseFormat() for the description of function parameters and return | |
989 | value. | |
23324ae1 | 990 | */ |
c398434d | 991 | bool ParseDateTime(const wxString& datetime, wxString::const_iterator *end); |
b9da294f | 992 | |
23324ae1 | 993 | /** |
4cc4bfaf | 994 | This function parses the string @a date according to the given |
1a21919b BP |
995 | @e format. The system @c strptime(3) function is used whenever |
996 | available, but even if it is not, this function is still implemented, | |
997 | although support for locale-dependent format specifiers such as | |
998 | @c "%c", @c "%x" or @c "%X" may not be perfect and GNU extensions such | |
999 | as @c "%z" and @c "%Z" are not implemented. This function does handle | |
1000 | the month and weekday names in the current locale on all platforms, | |
1001 | however. | |
1002 | ||
1003 | Please see the description of the ANSI C function @c strftime(3) for | |
1004 | the syntax of the format string. | |
1005 | ||
1006 | The @a dateDef parameter is used to fill in the fields which could not | |
1007 | be determined from the format string. For example, if the format is | |
1008 | @c "%d" (the day of the month), the month and the year are taken from | |
1009 | @a dateDef. If it is not specified, Today() is used as the default | |
1010 | date. | |
1011 | ||
c398434d | 1012 | Example of using this function: |
254696bb VZ |
1013 | @code |
1014 | wxDateTime dt; | |
1015 | wxString str = "..."; | |
1016 | wxString::const_iterator end; | |
1017 | if ( !dt.ParseFormat(str, "%Y-%m-%d", &end) ) | |
1018 | ... parsing failed ... | |
1019 | else if ( end == str.end() ) | |
1020 | ... entire string parsed ... | |
1021 | else | |
1022 | ... wxString(end, str.end()) left over ... | |
1023 | @endcode | |
1024 | ||
1025 | @param date | |
1026 | The string to be parsed. | |
1027 | @param format | |
1028 | strptime()-like format string. | |
1029 | @param dateDef | |
1030 | Used to fill in the date components not specified in the @a date | |
1031 | string. | |
1032 | @param end | |
c398434d VZ |
1033 | Will be filled with the iterator pointing to the location where the |
1034 | parsing stopped if the function returns @true. If the entire string | |
1035 | was consumed, it is set to @c date.end(). Notice that this argument | |
1036 | must be non-@NULL. | |
254696bb | 1037 | @return |
c398434d VZ |
1038 | @true if at least part of the string was parsed successfully, |
1039 | @false otherwise. | |
747199de FM |
1040 | |
1041 | @see Format() | |
23324ae1 | 1042 | */ |
c398434d | 1043 | bool ParseFormat(const wxString& date, |
dc735b40 FM |
1044 | const wxString& format, |
1045 | const wxDateTime& dateDef, | |
c398434d | 1046 | wxString::const_iterator *end); |
1a21919b | 1047 | |
747199de FM |
1048 | /** |
1049 | @overload | |
b9da294f | 1050 | */ |
c398434d | 1051 | bool ParseFormat(const wxString& date, |
dc735b40 | 1052 | const wxString& format, |
c398434d VZ |
1053 | wxString::const_iterator *end); |
1054 | ||
1055 | /** | |
1056 | @overload | |
1057 | */ | |
1058 | bool ParseFormat(const wxString& date, wxString::const_iterator *end); | |
23324ae1 FM |
1059 | |
1060 | /** | |
1a21919b BP |
1061 | This function parses the string containing the date and time in ISO |
1062 | 8601 combined format @c "YYYY-MM-DDTHH:MM:SS". The separator between | |
1063 | the date and time parts must be equal to @a sep for the function to | |
1064 | succeed. | |
1065 | ||
d29a9a8a | 1066 | @return @true if the entire string was parsed successfully, @false |
1a21919b | 1067 | otherwise. |
23324ae1 FM |
1068 | */ |
1069 | bool ParseISOCombined(const wxString& date, char sep = 'T'); | |
1070 | ||
1071 | /** | |
1a21919b BP |
1072 | This function parses the date in ISO 8601 format @c "YYYY-MM-DD". |
1073 | ||
d29a9a8a | 1074 | @return @true if the entire string was parsed successfully, @false |
1a21919b | 1075 | otherwise. |
23324ae1 FM |
1076 | */ |
1077 | bool ParseISODate(const wxString& date); | |
1078 | ||
1079 | /** | |
1a21919b BP |
1080 | This function parses the time in ISO 8601 format @c "HH:MM:SS". |
1081 | ||
d29a9a8a | 1082 | @return @true if the entire string was parsed successfully, @false |
1a21919b | 1083 | otherwise. |
23324ae1 FM |
1084 | */ |
1085 | bool ParseISOTime(const wxString& date); | |
1086 | ||
23324ae1 | 1087 | /** |
1a21919b BP |
1088 | Parses the string @a date looking for a date formatted according to the |
1089 | RFC 822 in it. The exact description of this format may, of course, be | |
1090 | found in the RFC (section 5), but, briefly, this is the format used in | |
1091 | the headers of Internet email messages and one of the most common | |
1092 | strings expressing date in this format may be something like | |
1093 | @c "Sat, 18 Dec 1999 00:48:30 +0100". | |
1094 | ||
23324ae1 | 1095 | Returns @NULL if the conversion failed, otherwise return the pointer to |
1a21919b BP |
1096 | the character immediately following the part of the string which could |
1097 | be parsed. If the entire string contains only the date in RFC 822 | |
1098 | format, the returned pointer will be pointing to a @c NUL character. | |
1099 | ||
1100 | This function is intentionally strict, it will return an error for any | |
1101 | string which is not RFC 822 compliant. If you need to parse date | |
1102 | formatted in more free ways, you should use ParseDateTime() or | |
23324ae1 | 1103 | ParseDate() instead. |
1a21919b | 1104 | |
254696bb VZ |
1105 | See ParseFormat() for the description of function parameters and return |
1106 | value. | |
b9da294f | 1107 | */ |
c398434d | 1108 | bool ParseRfc822Date(const wxString& date, wxString::const_iterator *end); |
23324ae1 | 1109 | |
23324ae1 | 1110 | /** |
1a21919b BP |
1111 | This functions is like ParseDateTime(), but only allows the time to be |
1112 | specified in the input string. | |
1113 | ||
254696bb VZ |
1114 | See ParseFormat() for the description of function parameters and return |
1115 | value. | |
23324ae1 | 1116 | */ |
c398434d | 1117 | bool ParseTime(const wxString& time, wxString::const_iterator *end); |
b9da294f BP |
1118 | |
1119 | //@} | |
23324ae1 | 1120 | |
3c4f71cc | 1121 | |
23324ae1 FM |
1122 | |
1123 | /** | |
b9da294f | 1124 | @name Calendar Calculations |
23324ae1 | 1125 | |
b9da294f BP |
1126 | The functions in this section perform the basic calendar calculations, |
1127 | mostly related to the week days. They allow to find the given week day | |
1128 | in the week with given number (either in the month or in the year) and | |
1129 | so on. | |
23324ae1 | 1130 | |
b9da294f BP |
1131 | None of the functions in this section modify the time part of the |
1132 | wxDateTime, they only work with the date part of it. | |
23324ae1 | 1133 | */ |
b9da294f | 1134 | //@{ |
23324ae1 FM |
1135 | |
1136 | /** | |
1a21919b BP |
1137 | Returns the copy of this object to which SetToLastMonthDay() was |
1138 | applied. | |
23324ae1 | 1139 | */ |
b9da294f BP |
1140 | wxDateTime GetLastMonthDay(Month month = Inv_Month, |
1141 | int year = Inv_Year) const; | |
23324ae1 FM |
1142 | |
1143 | /** | |
b9da294f BP |
1144 | Returns the copy of this object to which SetToLastWeekDay() was |
1145 | applied. | |
23324ae1 | 1146 | */ |
1a21919b | 1147 | wxDateTime GetLastWeekDay(WeekDay weekday, Month month = Inv_Month, |
b9da294f | 1148 | int year = Inv_Year); |
23324ae1 FM |
1149 | |
1150 | /** | |
b9da294f BP |
1151 | Returns the copy of this object to which SetToNextWeekDay() was |
1152 | applied. | |
23324ae1 | 1153 | */ |
b9da294f | 1154 | wxDateTime GetNextWeekDay(WeekDay weekday) const; |
23324ae1 FM |
1155 | |
1156 | /** | |
b9da294f BP |
1157 | Returns the copy of this object to which SetToPrevWeekDay() was |
1158 | applied. | |
23324ae1 | 1159 | */ |
b9da294f | 1160 | wxDateTime GetPrevWeekDay(WeekDay weekday) const; |
23324ae1 | 1161 | |
1a21919b BP |
1162 | /** |
1163 | Returns the copy of this object to which SetToWeekDay() was applied. | |
1164 | */ | |
1165 | wxDateTime GetWeekDay(WeekDay weekday, int n = 1, Month month = Inv_Month, | |
1166 | int year = Inv_Year) const; | |
1167 | ||
23324ae1 | 1168 | /** |
b9da294f BP |
1169 | Returns the copy of this object to which SetToWeekDayInSameWeek() was |
1170 | applied. | |
23324ae1 | 1171 | */ |
b9da294f BP |
1172 | wxDateTime GetWeekDayInSameWeek(WeekDay weekday, |
1173 | WeekFlags flags = Monday_First) const; | |
23324ae1 | 1174 | |
1a21919b BP |
1175 | /** |
1176 | Returns the copy of this object to which SetToYearDay() was applied. | |
1177 | */ | |
1178 | wxDateTime GetYearDay(wxDateTime_t yday) const; | |
1179 | ||
23324ae1 | 1180 | /** |
b9da294f BP |
1181 | Sets the date to the last day in the specified month (the current one |
1182 | by default). | |
1183 | ||
d29a9a8a | 1184 | @return The reference to the modified object itself. |
23324ae1 | 1185 | */ |
382f12e4 | 1186 | wxDateTime& SetToLastMonthDay(Month month = Inv_Month, int year = Inv_Year); |
23324ae1 FM |
1187 | |
1188 | /** | |
1189 | The effect of calling this function is the same as of calling | |
1a21919b BP |
1190 | @c SetToWeekDay(-1, weekday, month, year). The date will be set to the |
1191 | last @a weekday in the given month and year (the current ones by | |
1192 | default). Always returns @true. | |
23324ae1 FM |
1193 | */ |
1194 | bool SetToLastWeekDay(WeekDay weekday, Month month = Inv_Month, | |
1195 | int year = Inv_Year); | |
1196 | ||
1197 | /** | |
1a21919b BP |
1198 | Sets the date so that it will be the first @a weekday following the |
1199 | current date. | |
b9da294f | 1200 | |
d29a9a8a | 1201 | @return The reference to the modified object itself. |
23324ae1 | 1202 | */ |
1d497b99 | 1203 | wxDateTime& SetToNextWeekDay(WeekDay weekday); |
23324ae1 FM |
1204 | |
1205 | /** | |
4cc4bfaf | 1206 | Sets the date so that it will be the last @a weekday before the current |
23324ae1 | 1207 | date. |
b9da294f | 1208 | |
d29a9a8a | 1209 | @return The reference to the modified object itself. |
23324ae1 | 1210 | */ |
1d497b99 | 1211 | wxDateTime& SetToPrevWeekDay(WeekDay weekday); |
23324ae1 FM |
1212 | |
1213 | /** | |
4cc4bfaf | 1214 | Sets the date to the @e n-th @a weekday in the given month of the given |
1a21919b BP |
1215 | year (the current month and year are used by default). The parameter |
1216 | @a n may be either positive (counting from the beginning of the month) | |
1217 | or negative (counting from the end of it). | |
b9da294f BP |
1218 | |
1219 | For example, SetToWeekDay(2, wxDateTime::Wed) will set the date to the | |
23324ae1 | 1220 | second Wednesday in the current month and |
b9da294f BP |
1221 | SetToWeekDay(-1, wxDateTime::Sun) will set the date to the last Sunday |
1222 | in the current month. | |
1223 | ||
d29a9a8a | 1224 | @return @true if the date was modified successfully, @false otherwise |
b9da294f | 1225 | meaning that the specified date doesn't exist. |
23324ae1 FM |
1226 | */ |
1227 | bool SetToWeekDay(WeekDay weekday, int n = 1, | |
b9da294f | 1228 | Month month = Inv_Month, int year = Inv_Year); |
23324ae1 FM |
1229 | |
1230 | /** | |
b9da294f BP |
1231 | Adjusts the date so that it will still lie in the same week as before, |
1232 | but its week day will be the given one. | |
1233 | ||
d29a9a8a | 1234 | @return The reference to the modified object itself. |
23324ae1 | 1235 | */ |
382f12e4 | 1236 | wxDateTime& SetToWeekDayInSameWeek(WeekDay weekday, |
23324ae1 FM |
1237 | WeekFlags flags = Monday_First); |
1238 | ||
23324ae1 | 1239 | /** |
0824e369 | 1240 | Sets the date to the day number @a yday in the same year (i.e.\ unlike |
1a21919b BP |
1241 | the other functions, this one does not use the current year). The day |
1242 | number should be in the range 1-366 for the leap years and 1-365 for | |
23324ae1 | 1243 | the other ones. |
1a21919b | 1244 | |
d29a9a8a | 1245 | @return The reference to the modified object itself. |
23324ae1 | 1246 | */ |
1a21919b | 1247 | wxDateTime& SetToYearDay(wxDateTime_t yday); |
23324ae1 | 1248 | |
b9da294f BP |
1249 | //@} |
1250 | ||
1251 | ||
1252 | ||
23324ae1 | 1253 | /** |
b9da294f BP |
1254 | @name Astronomical/Historical Functions |
1255 | ||
1256 | Some degree of support for the date units used in astronomy and/or | |
1257 | history is provided. You can construct a wxDateTime object from a | |
1258 | JDN and you may also get its JDN, MJD or Rata Die number from it. | |
1259 | ||
1a21919b | 1260 | Related functions in other groups: wxDateTime(double), Set(double) |
23324ae1 | 1261 | */ |
b9da294f BP |
1262 | //@{ |
1263 | ||
1264 | /** | |
1265 | Synonym for GetJulianDayNumber(). | |
1266 | */ | |
1267 | double GetJDN() const; | |
1268 | ||
1269 | /** | |
1a21919b | 1270 | Returns the JDN corresponding to this date. Beware of rounding errors! |
b9da294f BP |
1271 | |
1272 | @see GetModifiedJulianDayNumber() | |
1273 | */ | |
1274 | double GetJulianDayNumber() const; | |
1275 | ||
1276 | /** | |
1277 | Synonym for GetModifiedJulianDayNumber(). | |
1278 | */ | |
1279 | double GetMJD() const; | |
1280 | ||
1281 | /** | |
1a21919b | 1282 | Returns the @e "Modified Julian Day Number" (MJD) which is, by |
fac938f8 VZ |
1283 | definition, is equal to JDN - 2400000.5. |
1284 | The MJDs are simpler to work with as the integral MJDs correspond to | |
1285 | midnights of the dates in the Gregorian calendar and not the noons like | |
1286 | JDN. The MJD 0 represents Nov 17, 1858. | |
b9da294f BP |
1287 | */ |
1288 | double GetModifiedJulianDayNumber() const; | |
1289 | ||
1290 | /** | |
1291 | Return the @e Rata Die number of this date. | |
1a21919b BP |
1292 | |
1293 | By definition, the Rata Die number is a date specified as the number of | |
1294 | days relative to a base date of December 31 of the year 0. Thus January | |
1295 | 1 of the year 1 is Rata Die day 1. | |
b9da294f BP |
1296 | */ |
1297 | double GetRataDie() const; | |
1298 | ||
1299 | //@} | |
1300 | ||
1301 | ||
1302 | ||
1303 | /** | |
1304 | @name Time Zone and DST Support | |
1305 | ||
1306 | Please see the @ref overview_datetime_timezones "time zone overview" | |
1307 | for more information about time zones. Normally, these functions should | |
1308 | be rarely used. | |
1309 | ||
1a21919b | 1310 | Related functions in other groups: GetBeginDST(), GetEndDST() |
b9da294f BP |
1311 | */ |
1312 | //@{ | |
1313 | ||
1314 | /** | |
1315 | Transform the date from the given time zone to the local one. If | |
1316 | @a noDST is @true, no DST adjustments will be made. | |
1317 | ||
d29a9a8a | 1318 | @return The date in the local time zone. |
b9da294f BP |
1319 | */ |
1320 | wxDateTime FromTimezone(const TimeZone& tz, bool noDST = false) const; | |
1321 | ||
1322 | /** | |
1323 | Returns @true if the DST is applied for this date in the given country. | |
1a21919b BP |
1324 | |
1325 | @see GetBeginDST(), GetEndDST() | |
b9da294f BP |
1326 | */ |
1327 | int IsDST(Country country = Country_Default) const; | |
1328 | ||
1329 | /** | |
1330 | Same as FromTimezone() but modifies the object in place. | |
1331 | */ | |
382f12e4 | 1332 | wxDateTime& MakeFromTimezone(const TimeZone& tz, bool noDST = false); |
b9da294f BP |
1333 | |
1334 | /** | |
1335 | Modifies the object in place to represent the date in another time | |
1336 | zone. If @a noDST is @true, no DST adjustments will be made. | |
1337 | */ | |
382f12e4 | 1338 | wxDateTime& MakeTimezone(const TimeZone& tz, bool noDST = false); |
b9da294f BP |
1339 | |
1340 | /** | |
1341 | This is the same as calling MakeTimezone() with the argument @c GMT0. | |
1342 | */ | |
1343 | wxDateTime& MakeUTC(bool noDST = false); | |
23324ae1 FM |
1344 | |
1345 | /** | |
b9da294f BP |
1346 | Transform the date to the given time zone. If @a noDST is @true, no DST |
1347 | adjustments will be made. | |
3c4f71cc | 1348 | |
d29a9a8a | 1349 | @return The date in the new time zone. |
b9da294f BP |
1350 | */ |
1351 | wxDateTime ToTimezone(const TimeZone& tz, bool noDST = false) const; | |
1352 | ||
1353 | /** | |
1354 | This is the same as calling ToTimezone() with the argument @c GMT0. | |
1355 | */ | |
1356 | wxDateTime ToUTC(bool noDST = false) const; | |
3c4f71cc | 1357 | |
b9da294f | 1358 | //@} |
3c4f71cc | 1359 | |
3c4f71cc | 1360 | |
3c4f71cc | 1361 | |
3c4f71cc | 1362 | |
3c4f71cc | 1363 | |
b9da294f | 1364 | /** |
0824e369 | 1365 | Converts the year in absolute notation (i.e.\ a number which can be |
b9da294f BP |
1366 | negative, positive or zero) to the year in BC/AD notation. For the |
1367 | positive years, nothing is done, but the year 0 is year 1 BC and so for | |
1368 | other years there is a difference of 1. | |
3c4f71cc | 1369 | |
b9da294f | 1370 | This function should be used like this: |
3c4f71cc | 1371 | |
b9da294f BP |
1372 | @code |
1373 | wxDateTime dt(...); | |
1374 | int y = dt.GetYear(); | |
1375 | printf("The year is %d%s", wxDateTime::ConvertYearToBC(y), y > 0 ? "AD" : "BC"); | |
1376 | @endcode | |
1377 | */ | |
1378 | static int ConvertYearToBC(int year); | |
3c4f71cc | 1379 | |
b9da294f BP |
1380 | /** |
1381 | Returns the translations of the strings @c AM and @c PM used for time | |
1382 | formatting for the current locale. Either of the pointers may be @NULL | |
1383 | if the corresponding value is not needed. | |
1384 | */ | |
1385 | static void GetAmPmStrings(wxString* am, wxString* pm); | |
3c4f71cc | 1386 | |
b9da294f BP |
1387 | /** |
1388 | Get the beginning of DST for the given country in the given year | |
1389 | (current one by default). This function suffers from limitations | |
1390 | described in the @ref overview_datetime_dst "DST overview". | |
3c4f71cc | 1391 | |
b9da294f BP |
1392 | @see GetEndDST() |
1393 | */ | |
1394 | static wxDateTime GetBeginDST(int year = Inv_Year, | |
1395 | Country country = Country_Default); | |
3c4f71cc | 1396 | |
b9da294f BP |
1397 | /** |
1398 | Returns the end of DST for the given country in the given year (current | |
1399 | one by default). | |
3c4f71cc | 1400 | |
b9da294f BP |
1401 | @see GetBeginDST() |
1402 | */ | |
1403 | static wxDateTime GetEndDST(int year = Inv_Year, | |
1404 | Country country = Country_Default); | |
3c4f71cc | 1405 | |
b9da294f | 1406 | /** |
0824e369 | 1407 | Get the current century, i.e.\ first two digits of the year, in given |
b9da294f BP |
1408 | calendar (only Gregorian is currently supported). |
1409 | */ | |
1410 | static int GetCentury(int year); | |
3c4f71cc | 1411 | |
b9da294f BP |
1412 | /** |
1413 | Returns the current default country. The default country is used for | |
1414 | DST calculations, for example. | |
3c4f71cc | 1415 | |
b9da294f BP |
1416 | @see SetCountry() |
1417 | */ | |
1418 | static Country GetCountry(); | |
3c4f71cc | 1419 | |
b9da294f BP |
1420 | /** |
1421 | Get the current month in given calendar (only Gregorian is currently | |
1422 | supported). | |
1423 | */ | |
1424 | static Month GetCurrentMonth(Calendar cal = Gregorian); | |
3c4f71cc | 1425 | |
b9da294f BP |
1426 | /** |
1427 | Get the current year in given calendar (only Gregorian is currently | |
1428 | supported). | |
23324ae1 | 1429 | */ |
b9da294f BP |
1430 | static int GetCurrentYear(Calendar cal = Gregorian); |
1431 | ||
1432 | /** | |
e538985e VZ |
1433 | Return the standard English name of the given month. |
1434 | ||
1435 | This function always returns "January" or "Jan" for January, use | |
1436 | GetMonthName() to retrieve the name of the month in the users current | |
1437 | locale. | |
1438 | ||
1439 | @param month | |
1440 | One of wxDateTime::Jan, ..., wxDateTime::Dec values. | |
1441 | @param flags | |
1442 | Either Name_Full (default) or Name_Abbr. | |
1443 | ||
1444 | @see GetEnglishWeekDayName() | |
1445 | ||
1446 | @since 2.9.0 | |
1447 | */ | |
1448 | static wxString GetEnglishMonthName(Month month, | |
1449 | NameFlags flags = Name_Full); | |
1450 | ||
1451 | /** | |
1452 | Return the standard English name of the given week day. | |
1453 | ||
1454 | This function always returns "Monday" or "Mon" for Monday, use | |
1455 | GetWeekDayName() to retrieve the name of the month in the users current | |
1456 | locale. | |
1457 | ||
1458 | @param weekday | |
1459 | One of wxDateTime::Sun, ..., wxDateTime::Sat values. | |
1460 | @param flags | |
1461 | Either Name_Full (default) or Name_Abbr. | |
1462 | ||
1463 | @see GetEnglishMonthName() | |
1464 | ||
1465 | @since 2.9.0 | |
1466 | */ | |
1467 | static wxString GetEnglishWeekDayName(WeekDay weekday, | |
1468 | NameFlags flags = Name_Full); | |
1469 | ||
1470 | /** | |
1471 | Gets the full (default) or abbreviated name of the given month. | |
1472 | ||
1473 | This function returns the name in the current locale, use | |
1474 | GetEnglishMonthName() to get the untranslated name if necessary. | |
1475 | ||
1476 | @param month | |
1477 | One of wxDateTime::Jan, ..., wxDateTime::Dec values. | |
1478 | @param flags | |
1479 | Either Name_Full (default) or Name_Abbr. | |
23324ae1 | 1480 | |
b9da294f BP |
1481 | @see GetWeekDayName() |
1482 | */ | |
1483 | static wxString GetMonthName(Month month, NameFlags flags = Name_Full); | |
23324ae1 FM |
1484 | |
1485 | /** | |
b9da294f BP |
1486 | Returns the number of days in the given year. The only supported value |
1487 | for @a cal currently is @c Gregorian. | |
23324ae1 | 1488 | */ |
b9da294f | 1489 | static wxDateTime_t GetNumberOfDays(int year, Calendar cal = Gregorian); |
23324ae1 FM |
1490 | |
1491 | /** | |
b9da294f BP |
1492 | Returns the number of days in the given month of the given year. The |
1493 | only supported value for @a cal currently is @c Gregorian. | |
b9da294f | 1494 | */ |
1a21919b | 1495 | static wxDateTime_t GetNumberOfDays(Month month, int year = Inv_Year, |
b9da294f | 1496 | Calendar cal = Gregorian); |
3c4f71cc | 1497 | |
b9da294f BP |
1498 | /** |
1499 | Returns the current time. | |
1500 | */ | |
1501 | static time_t GetTimeNow(); | |
3c4f71cc | 1502 | |
b9da294f | 1503 | /** |
57ab6f23 | 1504 | Returns the current time broken down using the buffer whose address is |
b9da294f BP |
1505 | passed to the function with @a tm to store the result. |
1506 | */ | |
882678eb | 1507 | static tm* GetTmNow(struct tm *tm); |
3c4f71cc | 1508 | |
b9da294f BP |
1509 | /** |
1510 | Returns the current time broken down. Note that this function returns a | |
1511 | pointer to a static buffer that's reused by calls to this function and | |
1512 | certain C library functions (e.g. localtime). If there is any chance | |
1513 | your code might be used in a multi-threaded application, you really | |
1514 | should use GetTmNow(struct tm *) instead. | |
1515 | */ | |
882678eb | 1516 | static tm* GetTmNow(); |
3c4f71cc | 1517 | |
b9da294f | 1518 | /** |
e538985e VZ |
1519 | Gets the full (default) or abbreviated name of the given week day. |
1520 | ||
1521 | This function returns the name in the current locale, use | |
1522 | GetEnglishWeekDayName() to get the untranslated name if necessary. | |
1523 | ||
1524 | @param weekday | |
1525 | One of wxDateTime::Sun, ..., wxDateTime::Sat values. | |
1526 | @param flags | |
1527 | Either Name_Full (default) or Name_Abbr. | |
3c4f71cc | 1528 | |
b9da294f BP |
1529 | @see GetMonthName() |
1530 | */ | |
1531 | static wxString GetWeekDayName(WeekDay weekday, | |
e538985e | 1532 | NameFlags flags = Name_Full); |
3c4f71cc | 1533 | |
b9da294f | 1534 | /** |
fac938f8 | 1535 | Returns @true if DST was used in the given year (the current one by |
b9da294f BP |
1536 | default) in the given country. |
1537 | */ | |
1538 | static bool IsDSTApplicable(int year = Inv_Year, | |
1539 | Country country = Country_Default); | |
3c4f71cc | 1540 | |
b9da294f BP |
1541 | /** |
1542 | Returns @true if the @a year is a leap one in the specified calendar. | |
1543 | This functions supports Gregorian and Julian calendars. | |
1544 | */ | |
1a21919b | 1545 | static bool IsLeapYear(int year = Inv_Year, Calendar cal = Gregorian); |
3c4f71cc | 1546 | |
b9da294f BP |
1547 | /** |
1548 | This function returns @true if the specified (or default) country is | |
1549 | one of Western European ones. It is used internally by wxDateTime to | |
1550 | determine the DST convention and date and time formatting rules. | |
23324ae1 | 1551 | */ |
b9da294f BP |
1552 | static bool IsWestEuropeanCountry(Country country = Country_Default); |
1553 | ||
1554 | /** | |
1555 | Returns the object corresponding to the current time. | |
1556 | ||
1557 | Example: | |
23324ae1 | 1558 | |
b9da294f BP |
1559 | @code |
1560 | wxDateTime now = wxDateTime::Now(); | |
1561 | printf("Current time in Paris:\t%s\n", now.Format("%c", wxDateTime::CET).c_str()); | |
1562 | @endcode | |
1563 | ||
324ab5e2 VZ |
1564 | @note This function is accurate up to seconds. UNow() can be used if |
1565 | better precision is required. | |
b9da294f BP |
1566 | |
1567 | @see Today() | |
1568 | */ | |
1569 | static wxDateTime Now(); | |
23324ae1 FM |
1570 | |
1571 | /** | |
b9da294f BP |
1572 | Sets the country to use by default. This setting influences the DST |
1573 | calculations, date formatting and other things. | |
1574 | ||
b9da294f | 1575 | @see GetCountry() |
23324ae1 | 1576 | */ |
b9da294f | 1577 | static void SetCountry(Country country); |
23324ae1 FM |
1578 | |
1579 | /** | |
1a21919b BP |
1580 | Set the date to the given @a weekday in the week number @a numWeek of |
1581 | the given @a year . The number should be in range 1-53. | |
1582 | ||
1583 | Note that the returned date may be in a different year than the one | |
1584 | passed to this function because both the week 1 and week 52 or 53 (for | |
1585 | leap years) contain days from different years. See GetWeekOfYear() for | |
1586 | the explanation of how the year weeks are counted. | |
23324ae1 | 1587 | */ |
b9da294f BP |
1588 | static wxDateTime SetToWeekOfYear(int year, wxDateTime_t numWeek, |
1589 | WeekDay weekday = Mon); | |
23324ae1 FM |
1590 | |
1591 | /** | |
b9da294f | 1592 | Returns the object corresponding to the midnight of the current day |
0824e369 | 1593 | (i.e.\ the same as Now(), but the time part is set to 0). |
3c4f71cc | 1594 | |
4cc4bfaf | 1595 | @see Now() |
23324ae1 FM |
1596 | */ |
1597 | static wxDateTime Today(); | |
1598 | ||
1599 | /** | |
324ab5e2 VZ |
1600 | Returns the object corresponding to the current UTC time including the |
1601 | milliseconds. | |
3c4f71cc | 1602 | |
324ab5e2 VZ |
1603 | Notice that unlike Now(), this method creates a wxDateTime object |
1604 | corresponding to UTC, not local, time. | |
1605 | ||
1606 | @see Now(), wxGetUTCTimeMillis() | |
23324ae1 | 1607 | */ |
4cc4bfaf | 1608 | static wxDateTime UNow(); |
4cc4bfaf | 1609 | }; |
23324ae1 | 1610 | |
65874118 FM |
1611 | /** |
1612 | Global instance of an empty wxDateTime object. | |
1613 | ||
1a21919b BP |
1614 | @todo Would it be better to rename this wxNullDateTime so it's consistent |
1615 | with the rest of the "empty/invalid/null" global objects? | |
65874118 | 1616 | */ |
1a21919b | 1617 | const wxDateTime wxDefaultDateTime; |
65874118 | 1618 | |
b2025b31 FM |
1619 | /* |
1620 | wxInvalidDateTime is an alias for wxDefaultDateTime. | |
1621 | */ | |
1622 | #define wxInvalidDateTime wxDefaultDateTime | |
23324ae1 | 1623 | |
e54c96f1 | 1624 | |
23324ae1 FM |
1625 | /** |
1626 | @class wxDateTimeWorkDays | |
7c913512 | 1627 | |
1a21919b | 1628 | @todo Write wxDateTimeWorkDays documentation. |
7c913512 | 1629 | |
23324ae1 | 1630 | @library{wxbase} |
1a21919b | 1631 | @category{data} |
23324ae1 | 1632 | */ |
7c913512 | 1633 | class wxDateTimeWorkDays |
23324ae1 FM |
1634 | { |
1635 | public: | |
7c913512 | 1636 | |
23324ae1 FM |
1637 | }; |
1638 | ||
1639 | ||
e54c96f1 | 1640 | |
23324ae1 FM |
1641 | /** |
1642 | @class wxDateSpan | |
7c913512 | 1643 | |
23324ae1 FM |
1644 | This class is a "logical time span" and is useful for implementing program |
1645 | logic for such things as "add one month to the date" which, in general, | |
1646 | doesn't mean to add 60*60*24*31 seconds to it, but to take the same date | |
1647 | the next month (to understand that this is indeed different consider adding | |
1648 | one month to Feb, 15 -- we want to get Mar, 15, of course). | |
7c913512 | 1649 | |
23324ae1 FM |
1650 | When adding a month to the date, all lesser components (days, hours, ...) |
1651 | won't be changed unless the resulting date would be invalid: for example, | |
1652 | Jan 31 + 1 month will be Feb 28, not (non-existing) Feb 31. | |
7c913512 | 1653 | |
23324ae1 | 1654 | Because of this feature, adding and subtracting back again the same |
1a21919b | 1655 | wxDateSpan will @b not, in general, give back the original date: Feb 28 - 1 |
23324ae1 | 1656 | month will be Jan 28, not Jan 31! |
7c913512 | 1657 | |
23324ae1 FM |
1658 | wxDateSpan objects can be either positive or negative. They may be |
1659 | multiplied by scalars which multiply all deltas by the scalar: i.e. | |
1a21919b BP |
1660 | 2*(1 month and 1 day) is 2 months and 2 days. They can be added together |
1661 | with wxDateTime or wxTimeSpan, but the type of result is different for each | |
23324ae1 | 1662 | case. |
7c913512 | 1663 | |
1a21919b BP |
1664 | @warning If you specify both weeks and days, the total number of days added |
1665 | will be 7*weeks + days! See also GetTotalDays(). | |
7c913512 | 1666 | |
1a21919b BP |
1667 | Equality operators are defined for wxDateSpans. Two wxDateSpans are equal |
1668 | if and only if they both give the same target date when added to @b every | |
1669 | source date. Thus wxDateSpan::Months(1) is not equal to | |
1670 | wxDateSpan::Days(30), because they don't give the same date when added to | |
1671 | Feb 1st. But wxDateSpan::Days(14) is equal to wxDateSpan::Weeks(2). | |
7c913512 | 1672 | |
1a21919b BP |
1673 | Finally, notice that for adding hours, minutes and so on you don't need |
1674 | this class at all: wxTimeSpan will do the job because there are no | |
1675 | subtleties associated with those (we don't support leap seconds). | |
7c913512 | 1676 | |
23324ae1 FM |
1677 | @library{wxbase} |
1678 | @category{data} | |
7c913512 | 1679 | |
b9da294f | 1680 | @see @ref overview_datetime, wxDateTime |
23324ae1 | 1681 | */ |
7c913512 | 1682 | class wxDateSpan |
23324ae1 FM |
1683 | { |
1684 | public: | |
1685 | /** | |
1a21919b BP |
1686 | Constructs the date span object for the given number of years, months, |
1687 | weeks and days. Note that the weeks and days add together if both are | |
1688 | given. | |
23324ae1 | 1689 | */ |
1a21919b | 1690 | wxDateSpan(int years = 0, int months = 0, int weeks = 0, int days = 0); |
23324ae1 | 1691 | |
23324ae1 | 1692 | /** |
1a21919b BP |
1693 | Returns the sum of two date spans. |
1694 | ||
d29a9a8a | 1695 | @return A new wxDateSpan object with the result. |
23324ae1 | 1696 | */ |
1a21919b BP |
1697 | wxDateSpan Add(const wxDateSpan& other) const; |
1698 | /** | |
1699 | Adds the given wxDateSpan to this wxDateSpan and returns a reference | |
1700 | to itself. | |
1701 | */ | |
1702 | wxDateSpan& Add(const wxDateSpan& other); | |
23324ae1 FM |
1703 | |
1704 | /** | |
1705 | Returns a date span object corresponding to one day. | |
3c4f71cc | 1706 | |
4cc4bfaf | 1707 | @see Days() |
23324ae1 | 1708 | */ |
4cc4bfaf | 1709 | static wxDateSpan Day(); |
23324ae1 FM |
1710 | |
1711 | /** | |
1712 | Returns a date span object corresponding to the given number of days. | |
3c4f71cc | 1713 | |
4cc4bfaf | 1714 | @see Day() |
23324ae1 FM |
1715 | */ |
1716 | static wxDateSpan Days(int days); | |
1717 | ||
1718 | /** | |
1a21919b BP |
1719 | Returns the number of days (not counting the weeks component) in this |
1720 | date span. | |
3c4f71cc | 1721 | |
4cc4bfaf | 1722 | @see GetTotalDays() |
23324ae1 | 1723 | */ |
328f5751 | 1724 | int GetDays() const; |
23324ae1 FM |
1725 | |
1726 | /** | |
1a21919b BP |
1727 | Returns the number of the months (not counting the years) in this date |
1728 | span. | |
23324ae1 | 1729 | */ |
328f5751 | 1730 | int GetMonths() const; |
23324ae1 | 1731 | |
16630eb7 VZ |
1732 | /** |
1733 | Returns the combined number of months in this date span, counting both | |
1734 | years and months. | |
1735 | ||
1736 | @see GetYears(), GetMonths() | |
1737 | ||
1738 | @since 2.9.5 | |
1739 | */ | |
1740 | int GetTotalMonths() const; | |
1741 | ||
23324ae1 | 1742 | /** |
1a21919b BP |
1743 | Returns the combined number of days in this date span, counting both |
1744 | weeks and days. This doesn't take months or years into account. | |
3c4f71cc | 1745 | |
4cc4bfaf | 1746 | @see GetWeeks(), GetDays() |
23324ae1 | 1747 | */ |
328f5751 | 1748 | int GetTotalDays() const; |
23324ae1 FM |
1749 | |
1750 | /** | |
1751 | Returns the number of weeks in this date span. | |
3c4f71cc | 1752 | |
4cc4bfaf | 1753 | @see GetTotalDays() |
23324ae1 | 1754 | */ |
328f5751 | 1755 | int GetWeeks() const; |
23324ae1 FM |
1756 | |
1757 | /** | |
1758 | Returns the number of years in this date span. | |
1759 | */ | |
328f5751 | 1760 | int GetYears() const; |
23324ae1 FM |
1761 | |
1762 | /** | |
1763 | Returns a date span object corresponding to one month. | |
3c4f71cc | 1764 | |
4cc4bfaf | 1765 | @see Months() |
23324ae1 FM |
1766 | */ |
1767 | static wxDateSpan Month(); | |
1768 | ||
1769 | /** | |
1770 | Returns a date span object corresponding to the given number of months. | |
3c4f71cc | 1771 | |
4cc4bfaf | 1772 | @see Month() |
23324ae1 FM |
1773 | */ |
1774 | static wxDateSpan Months(int mon); | |
1775 | ||
23324ae1 | 1776 | /** |
1a21919b BP |
1777 | Returns the product of the date span by the specified @a factor. The |
1778 | product is computed by multiplying each of the components by the | |
1779 | @a factor. | |
1780 | ||
d29a9a8a | 1781 | @return A new wxDateSpan object with the result. |
23324ae1 | 1782 | */ |
1a21919b BP |
1783 | wxDateSpan Multiply(int factor) const; |
1784 | /** | |
1785 | Multiplies this date span by the specified @a factor. The product is | |
1786 | computed by multiplying each of the components by the @a factor. | |
1787 | ||
d29a9a8a | 1788 | @return A reference to this wxDateSpan object modified in place. |
1a21919b BP |
1789 | */ |
1790 | wxDateSpan& Multiply(int factor); | |
23324ae1 | 1791 | |
23324ae1 FM |
1792 | /** |
1793 | Changes the sign of this date span. | |
3c4f71cc | 1794 | |
4cc4bfaf | 1795 | @see Negate() |
23324ae1 | 1796 | */ |
1a21919b | 1797 | wxDateSpan& Neg(); |
23324ae1 FM |
1798 | |
1799 | /** | |
1a21919b | 1800 | Returns a date span with the opposite sign. |
3c4f71cc | 1801 | |
4cc4bfaf | 1802 | @see Neg() |
23324ae1 | 1803 | */ |
328f5751 | 1804 | wxDateSpan Negate() const; |
23324ae1 FM |
1805 | |
1806 | /** | |
1a21919b BP |
1807 | Sets the number of days (without modifying any other components) in |
1808 | this date span. | |
23324ae1 | 1809 | */ |
1d497b99 | 1810 | wxDateSpan& SetDays(int n); |
23324ae1 FM |
1811 | |
1812 | /** | |
1a21919b BP |
1813 | Sets the number of months (without modifying any other components) in |
1814 | this date span. | |
23324ae1 | 1815 | */ |
1d497b99 | 1816 | wxDateSpan& SetMonths(int n); |
23324ae1 FM |
1817 | |
1818 | /** | |
1a21919b BP |
1819 | Sets the number of weeks (without modifying any other components) in |
1820 | this date span. | |
23324ae1 | 1821 | */ |
1d497b99 | 1822 | wxDateSpan& SetWeeks(int n); |
23324ae1 FM |
1823 | |
1824 | /** | |
1a21919b BP |
1825 | Sets the number of years (without modifying any other components) in |
1826 | this date span. | |
23324ae1 | 1827 | */ |
1d497b99 | 1828 | wxDateSpan& SetYears(int n); |
23324ae1 | 1829 | |
23324ae1 | 1830 | /** |
1a21919b BP |
1831 | Returns the difference of two date spans. |
1832 | ||
d29a9a8a | 1833 | @return A new wxDateSpan object with the result. |
1a21919b BP |
1834 | */ |
1835 | wxDateSpan Subtract(const wxDateSpan& other) const; | |
1836 | /** | |
1837 | Subtracts the given wxDateSpan to this wxDateSpan and returns a | |
1838 | reference to itself. | |
23324ae1 | 1839 | */ |
1a21919b | 1840 | wxDateSpan& Subtract(const wxDateSpan& other); |
23324ae1 FM |
1841 | |
1842 | /** | |
1843 | Returns a date span object corresponding to one week. | |
3c4f71cc | 1844 | |
4cc4bfaf | 1845 | @see Weeks() |
23324ae1 FM |
1846 | */ |
1847 | static wxDateSpan Week(); | |
1848 | ||
1849 | /** | |
1850 | Returns a date span object corresponding to the given number of weeks. | |
3c4f71cc | 1851 | |
4cc4bfaf | 1852 | @see Week() |
23324ae1 FM |
1853 | */ |
1854 | static wxDateSpan Weeks(int weeks); | |
1855 | ||
1856 | /** | |
1857 | Returns a date span object corresponding to one year. | |
3c4f71cc | 1858 | |
4cc4bfaf | 1859 | @see Years() |
23324ae1 FM |
1860 | */ |
1861 | static wxDateSpan Year(); | |
1862 | ||
1863 | /** | |
1864 | Returns a date span object corresponding to the given number of years. | |
3c4f71cc | 1865 | |
4cc4bfaf | 1866 | @see Year() |
23324ae1 FM |
1867 | */ |
1868 | static wxDateSpan Years(int years); | |
1869 | ||
1a21919b BP |
1870 | /** |
1871 | Adds the given wxDateSpan to this wxDateSpan and returns the result. | |
1872 | */ | |
1873 | wxDateSpan& operator+=(const wxDateSpan& other); | |
1874 | ||
1875 | /** | |
1876 | Subtracts the given wxDateSpan to this wxDateSpan and returns the | |
1877 | result. | |
1878 | */ | |
1879 | wxDateSpan& operator-=(const wxDateSpan& other); | |
1880 | ||
1881 | /** | |
1882 | Changes the sign of this date span. | |
1883 | ||
1884 | @see Negate() | |
1885 | */ | |
1886 | wxDateSpan& operator-(); | |
1887 | ||
1888 | /** | |
1889 | Multiplies this date span by the specified @a factor. The product is | |
1890 | computed by multiplying each of the components by the @a factor. | |
1891 | ||
d29a9a8a | 1892 | @return A reference to this wxDateSpan object modified in place. |
1a21919b BP |
1893 | */ |
1894 | wxDateSpan& operator*=(int factor); | |
1895 | ||
23324ae1 FM |
1896 | /** |
1897 | Returns @true if this date span is different from the other one. | |
1898 | */ | |
e73d7e56 | 1899 | bool operator!=(const wxDateSpan& other) const; |
23324ae1 FM |
1900 | |
1901 | /** | |
1a21919b BP |
1902 | Returns @true if this date span is equal to the other one. Two date |
1903 | spans are considered equal if and only if they have the same number of | |
1904 | years and months and the same total number of days (counting both days | |
1905 | and weeks). | |
23324ae1 | 1906 | */ |
e73d7e56 | 1907 | bool operator==(const wxDateSpan& other) const; |
23324ae1 FM |
1908 | }; |
1909 | ||
1910 | ||
e54c96f1 | 1911 | |
23324ae1 FM |
1912 | /** |
1913 | @class wxTimeSpan | |
7c913512 | 1914 | |
23324ae1 | 1915 | wxTimeSpan class represents a time interval. |
7c913512 | 1916 | |
23324ae1 FM |
1917 | @library{wxbase} |
1918 | @category{data} | |
7c913512 | 1919 | |
b9da294f | 1920 | @see @ref overview_datetime, wxDateTime |
23324ae1 | 1921 | */ |
7c913512 | 1922 | class wxTimeSpan |
23324ae1 FM |
1923 | { |
1924 | public: | |
23324ae1 | 1925 | /** |
1a21919b | 1926 | Default constructor, constructs a zero timespan. |
23324ae1 FM |
1927 | */ |
1928 | wxTimeSpan(); | |
1a21919b BP |
1929 | /** |
1930 | Constructs timespan from separate values for each component, with the | |
1931 | date set to 0. Hours are not restricted to 0-24 range, neither are | |
1932 | minutes, seconds or milliseconds. | |
1933 | */ | |
4ccf0566 | 1934 | wxTimeSpan(long hours, long min = 0, wxLongLong sec = 0, wxLongLong msec = 0); |
23324ae1 FM |
1935 | |
1936 | /** | |
1a21919b | 1937 | Returns the absolute value of the timespan: does not modify the object. |
23324ae1 | 1938 | */ |
328f5751 | 1939 | wxTimeSpan Abs() const; |
23324ae1 FM |
1940 | |
1941 | /** | |
1a21919b | 1942 | Returns the sum of two time spans. |
3c4f71cc | 1943 | |
d29a9a8a | 1944 | @return A new wxDateSpan object with the result. |
23324ae1 | 1945 | */ |
1a21919b | 1946 | wxTimeSpan Add(const wxTimeSpan& diff) const; |
23324ae1 | 1947 | /** |
1a21919b BP |
1948 | Adds the given wxTimeSpan to this wxTimeSpan and returns a reference |
1949 | to itself. | |
23324ae1 | 1950 | */ |
1a21919b | 1951 | wxTimeSpan& Add(const wxTimeSpan& diff); |
23324ae1 FM |
1952 | |
1953 | /** | |
1954 | Returns the timespan for one day. | |
1955 | */ | |
382f12e4 | 1956 | static wxTimeSpan Day(); |
23324ae1 FM |
1957 | |
1958 | /** | |
1959 | Returns the timespan for the given number of days. | |
1960 | */ | |
382f12e4 | 1961 | static wxTimeSpan Days(long days); |
23324ae1 FM |
1962 | |
1963 | /** | |
1a21919b BP |
1964 | Returns the string containing the formatted representation of the time |
1965 | span. The following format specifiers are allowed after %: | |
3c4f71cc | 1966 | |
1a21919b BP |
1967 | - @c H - Number of Hours |
1968 | - @c M - Number of Minutes | |
1969 | - @c S - Number of Seconds | |
1970 | - @c l - Number of Milliseconds | |
1971 | - @c D - Number of Days | |
1972 | - @c E - Number of Weeks | |
1973 | - @c % - The percent character | |
3c4f71cc | 1974 | |
1a21919b BP |
1975 | Note that, for example, the number of hours in the description above is |
1976 | not well defined: it can be either the total number of hours (for | |
1977 | example, for a time span of 50 hours this would be 50) or just the hour | |
1978 | part of the time span, which would be 2 in this case as 50 hours is | |
1979 | equal to 2 days and 2 hours. | |
3c4f71cc | 1980 | |
1a21919b BP |
1981 | wxTimeSpan resolves this ambiguity in the following way: if there had |
1982 | been, indeed, the @c %D format specified preceding the @c %H, then it | |
1983 | is interpreted as 2. Otherwise, it is 50. | |
3c4f71cc | 1984 | |
1a21919b BP |
1985 | The same applies to all other format specifiers: if they follow a |
1986 | specifier of larger unit, only the rest part is taken, otherwise the | |
1987 | full value is used. | |
23324ae1 | 1988 | */ |
e73d7e56 | 1989 | wxString Format(const wxString& format = wxDefaultTimeSpanFormat) const; |
23324ae1 | 1990 | |
23324ae1 FM |
1991 | /** |
1992 | Returns the difference in number of days. | |
1993 | */ | |
328f5751 | 1994 | int GetDays() const; |
23324ae1 FM |
1995 | |
1996 | /** | |
1997 | Returns the difference in number of hours. | |
1998 | */ | |
328f5751 | 1999 | int GetHours() const; |
23324ae1 FM |
2000 | |
2001 | /** | |
2002 | Returns the difference in number of milliseconds. | |
2003 | */ | |
328f5751 | 2004 | wxLongLong GetMilliseconds() const; |
23324ae1 FM |
2005 | |
2006 | /** | |
2007 | Returns the difference in number of minutes. | |
2008 | */ | |
328f5751 | 2009 | int GetMinutes() const; |
23324ae1 FM |
2010 | |
2011 | /** | |
2012 | Returns the difference in number of seconds. | |
2013 | */ | |
328f5751 | 2014 | wxLongLong GetSeconds() const; |
23324ae1 FM |
2015 | |
2016 | /** | |
2017 | Returns the internal representation of timespan. | |
2018 | */ | |
328f5751 | 2019 | wxLongLong GetValue() const; |
23324ae1 FM |
2020 | |
2021 | /** | |
2022 | Returns the difference in number of weeks. | |
2023 | */ | |
328f5751 | 2024 | int GetWeeks() const; |
23324ae1 FM |
2025 | |
2026 | /** | |
2027 | Returns the timespan for one hour. | |
2028 | */ | |
382f12e4 | 2029 | static wxTimeSpan Hour(); |
23324ae1 FM |
2030 | |
2031 | /** | |
2032 | Returns the timespan for the given number of hours. | |
2033 | */ | |
382f12e4 | 2034 | static wxTimeSpan Hours(long hours); |
23324ae1 FM |
2035 | |
2036 | /** | |
2037 | Returns @true if two timespans are equal. | |
2038 | */ | |
328f5751 | 2039 | bool IsEqualTo(const wxTimeSpan& ts) const; |
23324ae1 FM |
2040 | |
2041 | /** | |
0824e369 | 2042 | Compares two timespans: works with the absolute values, i.e.\ -2 hours |
1a21919b BP |
2043 | is longer than 1 hour. Also, it will return @false if the timespans are |
2044 | equal in absolute value. | |
23324ae1 | 2045 | */ |
328f5751 | 2046 | bool IsLongerThan(const wxTimeSpan& ts) const; |
23324ae1 FM |
2047 | |
2048 | /** | |
2049 | Returns @true if the timespan is negative. | |
2050 | */ | |
328f5751 | 2051 | bool IsNegative() const; |
23324ae1 FM |
2052 | |
2053 | /** | |
2054 | Returns @true if the timespan is empty. | |
2055 | */ | |
328f5751 | 2056 | bool IsNull() const; |
23324ae1 FM |
2057 | |
2058 | /** | |
2059 | Returns @true if the timespan is positive. | |
2060 | */ | |
328f5751 | 2061 | bool IsPositive() const; |
23324ae1 FM |
2062 | |
2063 | /** | |
0824e369 | 2064 | Compares two timespans: works with the absolute values, i.e.\ 1 hour is |
1a21919b BP |
2065 | shorter than -2 hours. Also, it will return @false if the timespans are |
2066 | equal in absolute value. | |
23324ae1 | 2067 | */ |
328f5751 | 2068 | bool IsShorterThan(const wxTimeSpan& ts) const; |
23324ae1 FM |
2069 | |
2070 | /** | |
2071 | Returns the timespan for one millisecond. | |
2072 | */ | |
382f12e4 | 2073 | static wxTimeSpan Millisecond(); |
23324ae1 FM |
2074 | |
2075 | /** | |
2076 | Returns the timespan for the given number of milliseconds. | |
2077 | */ | |
382f12e4 | 2078 | static wxTimeSpan Milliseconds(wxLongLong ms); |
23324ae1 FM |
2079 | |
2080 | /** | |
2081 | Returns the timespan for one minute. | |
2082 | */ | |
382f12e4 | 2083 | static wxTimeSpan Minute(); |
23324ae1 FM |
2084 | |
2085 | /** | |
2086 | Returns the timespan for the given number of minutes. | |
2087 | */ | |
382f12e4 | 2088 | static wxTimeSpan Minutes(long min); |
23324ae1 | 2089 | |
23324ae1 | 2090 | /** |
1a21919b | 2091 | Returns the product of this time span by @a n. |
23324ae1 | 2092 | |
d29a9a8a | 2093 | @return A new wxTimeSpan object with the result. |
23324ae1 | 2094 | */ |
1a21919b | 2095 | wxTimeSpan Multiply(int n) const; |
23324ae1 | 2096 | /** |
1a21919b BP |
2097 | Multiplies this time span by @a n. |
2098 | ||
d29a9a8a | 2099 | @return A reference to this wxTimeSpan object modified in place. |
23324ae1 | 2100 | */ |
1a21919b | 2101 | wxTimeSpan& Multiply(int n); |
23324ae1 FM |
2102 | |
2103 | /** | |
1a21919b | 2104 | Negate the value of the timespan. |
3c4f71cc | 2105 | |
1a21919b BP |
2106 | @see Negate() |
2107 | */ | |
2108 | wxTimeSpan& Neg(); | |
3c4f71cc | 2109 | |
1a21919b BP |
2110 | /** |
2111 | Returns timespan with inverted sign. | |
3c4f71cc | 2112 | |
1a21919b | 2113 | @see Neg() |
23324ae1 | 2114 | */ |
1a21919b | 2115 | wxTimeSpan Negate() const; |
23324ae1 FM |
2116 | |
2117 | /** | |
2118 | Returns the timespan for one second. | |
2119 | */ | |
382f12e4 | 2120 | static wxTimeSpan Second(); |
23324ae1 FM |
2121 | |
2122 | /** | |
2123 | Returns the timespan for the given number of seconds. | |
2124 | */ | |
382f12e4 | 2125 | static wxTimeSpan Seconds(wxLongLong sec); |
23324ae1 FM |
2126 | |
2127 | /** | |
1a21919b | 2128 | Returns the difference of two time spans. |
3c4f71cc | 2129 | |
d29a9a8a | 2130 | @return A new wxDateSpan object with the result. |
23324ae1 | 2131 | */ |
1a21919b | 2132 | wxTimeSpan Subtract(const wxTimeSpan& diff) const; |
23324ae1 | 2133 | /** |
1a21919b BP |
2134 | Subtracts the given wxTimeSpan to this wxTimeSpan and returns a |
2135 | reference to itself. | |
23324ae1 | 2136 | */ |
1a21919b | 2137 | wxTimeSpan& Subtract(const wxTimeSpan& diff); |
23324ae1 FM |
2138 | |
2139 | /** | |
1a21919b BP |
2140 | Returns the timespan for one week. |
2141 | */ | |
382f12e4 | 2142 | static wxTimeSpan Week(); |
3c4f71cc | 2143 | |
1a21919b BP |
2144 | /** |
2145 | Returns the timespan for the given number of weeks. | |
2146 | */ | |
382f12e4 | 2147 | static wxTimeSpan Weeks(long weeks); |
3c4f71cc | 2148 | |
1a21919b BP |
2149 | /** |
2150 | Adds the given wxTimeSpan to this wxTimeSpan and returns the result. | |
2151 | */ | |
2152 | wxTimeSpan& operator+=(const wxTimeSpan& diff); | |
3c4f71cc | 2153 | |
1a21919b BP |
2154 | /** |
2155 | Multiplies this time span by @a n. | |
3c4f71cc | 2156 | |
d29a9a8a | 2157 | @return A reference to this wxTimeSpan object modified in place. |
23324ae1 | 2158 | */ |
1a21919b | 2159 | wxTimeSpan& operator*=(int n); |
23324ae1 FM |
2160 | |
2161 | /** | |
1a21919b BP |
2162 | Negate the value of the timespan. |
2163 | ||
2164 | @see Negate() | |
23324ae1 | 2165 | */ |
1a21919b | 2166 | wxTimeSpan& operator-(); |
23324ae1 FM |
2167 | |
2168 | /** | |
1a21919b BP |
2169 | Subtracts the given wxTimeSpan to this wxTimeSpan and returns the |
2170 | result. | |
23324ae1 | 2171 | */ |
1a21919b | 2172 | wxTimeSpan& operator-=(const wxTimeSpan& diff); |
23324ae1 FM |
2173 | }; |
2174 | ||
2175 | ||
e54c96f1 | 2176 | |
23324ae1 FM |
2177 | /** |
2178 | @class wxDateTimeHolidayAuthority | |
7c913512 | 2179 | |
1a21919b | 2180 | @todo Write wxDateTimeHolidayAuthority documentation. |
7c913512 | 2181 | |
23324ae1 | 2182 | @library{wxbase} |
3c99e2fd | 2183 | @category{data} |
23324ae1 | 2184 | */ |
7c913512 | 2185 | class wxDateTimeHolidayAuthority |
23324ae1 FM |
2186 | { |
2187 | public: | |
7c913512 | 2188 | |
23324ae1 | 2189 | }; |
e54c96f1 | 2190 |