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