]>
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$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxDateTime | |
11 | @wxheader{datetime.h} | |
7c913512 | 12 | |
23324ae1 | 13 | wxDateTime class represents an absolute moment in the time. |
7c913512 | 14 | |
23324ae1 FM |
15 | @library{wxbase} |
16 | @category{data} | |
7c913512 | 17 | |
65874118 FM |
18 | @stdobjects |
19 | ::wxDefaultDateTime | |
20 | ||
e54c96f1 | 21 | @see @ref overview_wxdatetimeoverview "Date classes overview", wxTimeSpan, |
23324ae1 FM |
22 | wxDateSpan, wxCalendarCtrl |
23 | */ | |
7c913512 | 24 | class wxDateTime |
23324ae1 FM |
25 | { |
26 | public: | |
27 | /** | |
28 | Same as @ref setdate() Set | |
29 | */ | |
30 | wxDateTime(wxDateTime_t day, Month month = Inv_Month, | |
1d497b99 | 31 | int year = Inv_Year, wxDateTime_t hour = 0, |
23324ae1 FM |
32 | wxDateTime_t minute = 0, |
33 | wxDateTime_t second = 0, | |
34 | wxDateTime_t millisec = 0); | |
35 | ||
36 | /** | |
37 | Here are the trivial accessors. Other functions, which might have to perform | |
38 | some more complicated calculations to find the answer are under the | |
39 | @ref overview_datetimecalculations "Calendar calculations" section. | |
23324ae1 | 40 | IsValid() |
3c4f71cc | 41 | |
23324ae1 | 42 | GetTicks() |
3c4f71cc | 43 | |
23324ae1 | 44 | GetCentury() |
3c4f71cc | 45 | |
23324ae1 | 46 | GetYear() |
3c4f71cc | 47 | |
23324ae1 | 48 | GetMonth() |
3c4f71cc | 49 | |
23324ae1 | 50 | GetDay() |
3c4f71cc | 51 | |
23324ae1 | 52 | GetWeekDay() |
3c4f71cc | 53 | |
23324ae1 | 54 | GetHour() |
3c4f71cc | 55 | |
23324ae1 | 56 | GetMinute() |
3c4f71cc | 57 | |
23324ae1 | 58 | GetSecond() |
3c4f71cc | 59 | |
23324ae1 | 60 | GetMillisecond() |
3c4f71cc | 61 | |
23324ae1 | 62 | GetDayOfYear() |
3c4f71cc | 63 | |
23324ae1 | 64 | GetWeekOfYear() |
3c4f71cc | 65 | |
23324ae1 | 66 | GetWeekOfMonth() |
3c4f71cc | 67 | |
23324ae1 | 68 | GetYearDay() |
3c4f71cc | 69 | |
23324ae1 | 70 | IsWorkDay() |
3c4f71cc | 71 | |
23324ae1 | 72 | IsGregorianDate() |
3c4f71cc | 73 | |
23324ae1 FM |
74 | GetAsDOS() |
75 | */ | |
76 | ||
77 | ||
78 | //@{ | |
79 | /** | |
80 | Adds the given date span to this object. | |
81 | */ | |
82 | wxDateTime Add(const wxDateSpan& diff); | |
328f5751 | 83 | const wxDateTime& Add(const wxDateSpan& diff); |
7c913512 | 84 | wxDateTime operator+=(const wxDateSpan& diff); |
23324ae1 FM |
85 | //@} |
86 | ||
87 | /** | |
88 | Some degree of support for the date units used in astronomy and/or history is | |
89 | provided. You can construct a wxDateTime object from a | |
90 | @ref setjdn() JDN and you may also get its JDN, | |
91 | @ref getmodifiedjuliandaynumber() MJD or | |
92 | @ref getratadie() "Rata Die number" from it. | |
23324ae1 | 93 | @ref wxdatetimejdn() "wxDateTime(double jdn)" |
3c4f71cc | 94 | |
23324ae1 | 95 | @ref setjdn() "Set(double jdn)" |
3c4f71cc | 96 | |
23324ae1 | 97 | GetJulianDayNumber() |
3c4f71cc | 98 | |
23324ae1 | 99 | GetJDN() |
3c4f71cc | 100 | |
23324ae1 | 101 | GetModifiedJulianDayNumber() |
3c4f71cc | 102 | |
23324ae1 | 103 | GetMJD() |
3c4f71cc | 104 | |
23324ae1 FM |
105 | GetRataDie() |
106 | */ | |
107 | ||
108 | ||
109 | /** | |
110 | The functions in this section perform the basic calendar calculations, mostly | |
111 | related to the week days. They allow to find the given week day in the | |
112 | week with given number (either in the month or in the year) and so on. | |
23324ae1 FM |
113 | All (non-const) functions in this section don't modify the time part of the |
114 | wxDateTime -- they only work with the date part of it. | |
23324ae1 | 115 | SetToWeekDayInSameWeek() |
3c4f71cc | 116 | |
23324ae1 | 117 | GetWeekDayInSameWeek() |
3c4f71cc | 118 | |
23324ae1 | 119 | SetToNextWeekDay() |
3c4f71cc | 120 | |
23324ae1 | 121 | GetNextWeekDay() |
3c4f71cc | 122 | |
23324ae1 | 123 | SetToPrevWeekDay() |
3c4f71cc | 124 | |
23324ae1 | 125 | GetPrevWeekDay() |
3c4f71cc | 126 | |
23324ae1 | 127 | SetToWeekDay() |
3c4f71cc | 128 | |
23324ae1 | 129 | @ref wxDateTime::getweekday2 GetWeekDay |
3c4f71cc | 130 | |
23324ae1 | 131 | SetToLastWeekDay() |
3c4f71cc | 132 | |
23324ae1 | 133 | GetLastWeekDay() |
3c4f71cc | 134 | |
23324ae1 | 135 | SetToWeekOfYear() |
3c4f71cc | 136 | |
23324ae1 | 137 | SetToLastMonthDay() |
3c4f71cc | 138 | |
23324ae1 | 139 | GetLastMonthDay() |
3c4f71cc | 140 | |
23324ae1 | 141 | SetToYearDay() |
3c4f71cc | 142 | |
23324ae1 FM |
143 | GetYearDay() |
144 | */ | |
145 | ||
146 | ||
147 | /** | |
148 | Constructors and various @c Set() methods are collected here. If you | |
149 | construct a date object from separate values for day, month and year, you | |
150 | should use IsValid() method to check that the | |
151 | values were correct as constructors can not return an error code. | |
23324ae1 | 152 | @ref wxdatetimedef() wxDateTime |
3c4f71cc | 153 | |
23324ae1 | 154 | @ref wxdatetimetimet() wxDateTime(time_t) |
3c4f71cc | 155 | |
23324ae1 | 156 | @ref wxdatetimetm() "wxDateTime(struct tm)" |
3c4f71cc | 157 | |
23324ae1 | 158 | @ref wxdatetimejdn() "wxDateTime(double jdn)" |
3c4f71cc | 159 | |
23324ae1 | 160 | @ref wxdatetimetime() "wxDateTime(h, m, s, ms)" |
3c4f71cc | 161 | |
23324ae1 | 162 | @ref wxdatetimedate() "wxDateTime(day, mon, year, h, m, s, ms)" |
3c4f71cc | 163 | |
23324ae1 | 164 | SetToCurrent() |
3c4f71cc | 165 | |
23324ae1 | 166 | @ref settimet() Set(time_t) |
3c4f71cc | 167 | |
23324ae1 | 168 | @ref settm() "Set(struct tm)" |
3c4f71cc | 169 | |
23324ae1 | 170 | @ref setjdn() "Set(double jdn)" |
3c4f71cc | 171 | |
23324ae1 | 172 | @ref settime() "Set(h, m, s, ms)" |
3c4f71cc | 173 | |
23324ae1 | 174 | @ref setdate() "Set(day, mon, year, h, m, s, ms)" |
3c4f71cc | 175 | |
23324ae1 | 176 | @ref setfromdos() "SetFromDOS(unsigned long ddt)" |
3c4f71cc | 177 | |
23324ae1 | 178 | ResetTime() |
3c4f71cc | 179 | |
23324ae1 | 180 | SetYear() |
3c4f71cc | 181 | |
23324ae1 | 182 | SetMonth() |
3c4f71cc | 183 | |
23324ae1 | 184 | @ref setdate() SetDay |
3c4f71cc | 185 | |
23324ae1 | 186 | SetHour() |
3c4f71cc | 187 | |
23324ae1 | 188 | SetMinute() |
3c4f71cc | 189 | |
23324ae1 | 190 | SetSecond() |
3c4f71cc | 191 | |
23324ae1 | 192 | SetMillisecond() |
3c4f71cc | 193 | |
23324ae1 | 194 | @ref operatoreqtimet() operator=(time_t) |
3c4f71cc | 195 | |
23324ae1 FM |
196 | @ref operatoreqtm() "operator=(struct tm)" |
197 | */ | |
198 | ||
199 | ||
200 | /** | |
201 | Converts the year in absolute notation (i.e. a number which can be negative, | |
202 | positive or zero) to the year in BC/AD notation. For the positive years, | |
203 | nothing is done, but the year 0 is year 1 BC and so for other years there is a | |
204 | difference of 1. | |
23324ae1 FM |
205 | This function should be used like this: |
206 | */ | |
207 | static int ConvertYearToBC(int year); | |
208 | ||
209 | /** | |
e54c96f1 | 210 | These functions carry out arithmetics() on the wxDateTime |
23324ae1 FM |
211 | objects. As explained in the overview, either wxTimeSpan or wxDateSpan may be |
212 | added to wxDateTime, hence all functions are overloaded to accept both | |
213 | arguments. | |
23324ae1 FM |
214 | Also, both @c Add() and @c Subtract() have both const and non-const |
215 | version. The first one returns a new object which represents the | |
216 | sum/difference of the original one with the argument while the second form | |
217 | modifies the object to which it is applied. The operators -= and += are | |
218 | defined to be equivalent to the second forms of these functions. | |
23324ae1 | 219 | @ref addts() Add(wxTimeSpan) |
3c4f71cc | 220 | |
23324ae1 | 221 | @ref addds() Add(wxDateSpan) |
3c4f71cc | 222 | |
23324ae1 | 223 | @ref subtractts() Subtract(wxTimeSpan) |
3c4f71cc | 224 | |
23324ae1 | 225 | @ref subtractds() Subtract(wxDateSpan) |
3c4f71cc | 226 | |
23324ae1 | 227 | @ref subtractdt() Subtract(wxDateTime) |
3c4f71cc | 228 | |
23324ae1 | 229 | @ref addts() oparator+=(wxTimeSpan) |
3c4f71cc | 230 | |
23324ae1 | 231 | @ref addds() oparator+=(wxDateSpan) |
3c4f71cc | 232 | |
23324ae1 | 233 | @ref subtractts() oparator-=(wxTimeSpan) |
3c4f71cc | 234 | |
23324ae1 FM |
235 | @ref subtractds() oparator-=(wxDateSpan) |
236 | */ | |
237 | ||
238 | ||
239 | /** | |
240 | There are several function to allow date comparison. To supplement them, a few | |
241 | global operators , etc taking wxDateTime are defined. | |
23324ae1 | 242 | IsEqualTo() |
3c4f71cc | 243 | |
23324ae1 | 244 | IsEarlierThan() |
3c4f71cc | 245 | |
23324ae1 | 246 | IsLaterThan() |
3c4f71cc | 247 | |
23324ae1 | 248 | IsStrictlyBetween() |
3c4f71cc | 249 | |
23324ae1 | 250 | IsBetween() |
3c4f71cc | 251 | |
23324ae1 | 252 | IsSameDate() |
3c4f71cc | 253 | |
23324ae1 | 254 | IsSameTime() |
3c4f71cc | 255 | |
23324ae1 FM |
256 | IsEqualUpTo() |
257 | */ | |
258 | ||
259 | ||
260 | /** | |
261 | This function does the same as the standard ANSI C @c strftime(3) function. | |
4cc4bfaf | 262 | Please see its description for the meaning of @a format parameter. |
23324ae1 FM |
263 | It also accepts a few wxWidgets-specific extensions: you can optionally specify |
264 | the width of the field to follow using @c printf(3)-like syntax and the | |
265 | format specification @c %l can be used to get the number of milliseconds. | |
3c4f71cc | 266 | |
4cc4bfaf | 267 | @see ParseFormat() |
23324ae1 | 268 | */ |
4cc4bfaf | 269 | wxString Format(const wxChar* format = wxDefaultDateTimeFormat, |
328f5751 | 270 | const TimeZone& tz = Local) const; |
23324ae1 FM |
271 | |
272 | /** | |
273 | Identical to calling Format() with @c "%x" | |
274 | argument (which means 'preferred date representation for the current locale'). | |
275 | */ | |
328f5751 | 276 | wxString FormatDate() const; |
23324ae1 FM |
277 | |
278 | /** | |
279 | Returns the combined date-time representation in the ISO 8601 format | |
4cc4bfaf | 280 | (YYYY-MM-DDTHH:MM:SS). The @a sep parameter default value produces the |
23324ae1 FM |
281 | result exactly corresponding to the ISO standard, but it can also be useful to |
282 | use a space as seprator if a more human-readable combined date-time | |
283 | representation is needed. | |
3c4f71cc | 284 | |
4cc4bfaf FM |
285 | @see FormatISODate(), FormatISOTime(), |
286 | ParseISOCombined() | |
23324ae1 | 287 | */ |
328f5751 | 288 | wxString FormatISOCombined(char sep = 'T') const; |
23324ae1 FM |
289 | |
290 | /** | |
291 | This function returns the date representation in the ISO 8601 format | |
292 | (YYYY-MM-DD). | |
293 | */ | |
328f5751 | 294 | wxString FormatISODate() const; |
23324ae1 FM |
295 | |
296 | /** | |
297 | This function returns the time representation in the ISO 8601 format | |
298 | (HH:MM:SS). | |
299 | */ | |
328f5751 | 300 | wxString FormatISOTime() const; |
23324ae1 FM |
301 | |
302 | /** | |
303 | Identical to calling Format() with @c "%X" | |
304 | argument (which means 'preferred time representation for the current locale'). | |
305 | */ | |
328f5751 | 306 | wxString FormatTime() const; |
23324ae1 FM |
307 | |
308 | /** | |
4cc4bfaf | 309 | Transform the date from the given time zone to the local one. If @a noDST is |
23324ae1 | 310 | @true, no DST adjustments will be made. |
23324ae1 FM |
311 | Returns the date in the local time zone. |
312 | */ | |
313 | wxDateTime FromTimezone(const TimeZone& tz, | |
328f5751 | 314 | bool noDST = false) const; |
23324ae1 FM |
315 | |
316 | /** | |
317 | Returns the translations of the strings @c AM and @c PM used for time | |
318 | formatting for the current locale. Either of the pointers may be @NULL if | |
319 | the corresponding value is not needed. | |
320 | */ | |
4cc4bfaf | 321 | static void GetAmPmStrings(wxString* am, wxString* pm); |
23324ae1 FM |
322 | |
323 | /** | |
324 | Returns the date and time in | |
325 | DOS | |
326 | format. | |
327 | */ | |
1d497b99 | 328 | long unsigned int GetAsDOS() const; |
23324ae1 FM |
329 | |
330 | /** | |
331 | Get the beginning of DST for the given country in the given year (current one | |
332 | by default). This function suffers from limitations described in | |
333 | @ref overview_tdatedst "DST overview". | |
3c4f71cc | 334 | |
4cc4bfaf | 335 | @see GetEndDST() |
23324ae1 FM |
336 | */ |
337 | static wxDateTime GetBeginDST(int year = Inv_Year, | |
338 | Country country = Country_Default); | |
339 | ||
340 | /** | |
341 | Returns the century of this date. | |
342 | */ | |
328f5751 | 343 | int GetCentury(const TimeZone& tz = Local) const; |
23324ae1 FM |
344 | |
345 | /** | |
346 | Returns the current default country. The default country is used for DST | |
347 | calculations, for example. | |
3c4f71cc | 348 | |
4cc4bfaf | 349 | @see SetCountry() |
23324ae1 FM |
350 | */ |
351 | static Country GetCountry(); | |
352 | ||
353 | /** | |
354 | Get the current month in given calendar (only Gregorian is currently supported). | |
355 | */ | |
356 | static Month GetCurrentMonth(Calendar cal = Gregorian); | |
357 | ||
358 | /** | |
359 | Get the current year in given calendar (only Gregorian is currently supported). | |
360 | */ | |
361 | static int GetCurrentYear(Calendar cal = Gregorian); | |
362 | ||
363 | /** | |
364 | Returns the object having the same date component as this one but time of | |
365 | 00:00:00. | |
3c4f71cc | 366 | |
e54c96f1 | 367 | @wxsince{2.8.2} |
3c4f71cc | 368 | |
4cc4bfaf | 369 | @see ResetTime() |
23324ae1 | 370 | */ |
328f5751 | 371 | wxDateTime GetDateOnly() const; |
23324ae1 FM |
372 | |
373 | /** | |
374 | Returns the day in the given timezone (local one by default). | |
375 | */ | |
1d497b99 | 376 | short unsigned int GetDay(const TimeZone& tz = Local) const; |
23324ae1 FM |
377 | |
378 | /** | |
379 | Returns the day of the year (in 1...366 range) in the given timezone | |
380 | (local one by default). | |
381 | */ | |
1d497b99 | 382 | short unsigned int GetDayOfYear(const TimeZone& tz = Local) const; |
23324ae1 FM |
383 | |
384 | /** | |
385 | Returns the end of DST for the given country in the given year (current one by | |
386 | default). | |
3c4f71cc | 387 | |
4cc4bfaf | 388 | @see GetBeginDST() |
23324ae1 FM |
389 | */ |
390 | static wxDateTime GetEndDST(int year = Inv_Year, | |
391 | Country country = Country_Default); | |
392 | ||
393 | /** | |
394 | Returns the hour in the given timezone (local one by default). | |
395 | */ | |
1d497b99 | 396 | short unsigned int GetHour(const TimeZone& tz = Local) const; |
23324ae1 FM |
397 | |
398 | /** | |
399 | Synonym for GetJulianDayNumber(). | |
400 | */ | |
328f5751 | 401 | double GetJDN() const; |
23324ae1 FM |
402 | |
403 | /** | |
404 | Returns the @ref setjdn() JDN corresponding to this date. Beware | |
405 | of rounding errors! | |
3c4f71cc | 406 | |
4cc4bfaf | 407 | @see GetModifiedJulianDayNumber() |
23324ae1 | 408 | */ |
328f5751 | 409 | double GetJulianDayNumber() const; |
23324ae1 FM |
410 | |
411 | /** | |
412 | Returns the copy of this object to which | |
413 | SetToLastMonthDay() was applied. | |
414 | */ | |
415 | wxDateTime GetLastMonthDay(Month month = Inv_Month, | |
328f5751 | 416 | int year = Inv_Year) const; |
23324ae1 FM |
417 | |
418 | /** | |
419 | Returns the copy of this object to which | |
420 | SetToLastWeekDay() was applied. | |
421 | */ | |
422 | wxDateTime GetLastWeekDay(WeekDay weekday, | |
423 | Month month = Inv_Month, | |
424 | int year = Inv_Year); | |
425 | ||
426 | /** | |
427 | Synonym for GetModifiedJulianDayNumber(). | |
428 | */ | |
328f5751 | 429 | double GetMJD() const; |
23324ae1 FM |
430 | |
431 | /** | |
432 | Returns the milliseconds in the given timezone (local one by default). | |
433 | */ | |
1d497b99 | 434 | short unsigned int GetMillisecond(const TimeZone& tz = Local) const; |
23324ae1 FM |
435 | |
436 | /** | |
437 | Returns the minute in the given timezone (local one by default). | |
438 | */ | |
1d497b99 | 439 | short unsigned int GetMinute(const TimeZone& tz = Local) const; |
23324ae1 FM |
440 | |
441 | /** | |
442 | Returns the @e Modified Julian Day Number (MJD) which is, by definition, | |
443 | equal to JDN - 2400000.5. The MJDs are simpler to work with as the integral | |
444 | MJDs correspond to midnights of the dates in the Gregorian calendar and not th | |
445 | noons like JDN. The MJD 0 is Nov 17, 1858. | |
446 | */ | |
328f5751 | 447 | double GetModifiedJulianDayNumber() const; |
23324ae1 FM |
448 | |
449 | /** | |
450 | Returns the month in the given timezone (local one by default). | |
451 | */ | |
328f5751 | 452 | Month GetMonth(const TimeZone& tz = Local) const; |
23324ae1 FM |
453 | |
454 | /** | |
455 | Gets the full (default) or abbreviated (specify @c Name_Abbr name of the | |
456 | given month. | |
3c4f71cc | 457 | |
4cc4bfaf | 458 | @see GetWeekDayName() |
23324ae1 FM |
459 | */ |
460 | static wxString GetMonthName(Month month, | |
461 | NameFlags flags = Name_Full); | |
462 | ||
463 | /** | |
464 | Returns the copy of this object to which | |
465 | SetToNextWeekDay() was applied. | |
466 | */ | |
328f5751 | 467 | wxDateTime GetNextWeekDay(WeekDay weekday) const; |
23324ae1 FM |
468 | |
469 | //@{ | |
470 | /** | |
471 | Returns the number of days in the given year or in the given month of the | |
472 | year. | |
4cc4bfaf | 473 | The only supported value for @a cal parameter is currently @c Gregorian. |
23324ae1 FM |
474 | */ |
475 | static wxDateTime_t GetNumberOfDays(int year, | |
476 | Calendar cal = Gregorian); | |
7c913512 FM |
477 | static wxDateTime_t GetNumberOfDays(Month month, |
478 | int year = Inv_Year, | |
479 | Calendar cal = Gregorian); | |
23324ae1 FM |
480 | //@} |
481 | ||
482 | /** | |
483 | Returns the copy of this object to which | |
484 | SetToPrevWeekDay() was applied. | |
485 | */ | |
328f5751 | 486 | wxDateTime GetPrevWeekDay(WeekDay weekday) const; |
23324ae1 FM |
487 | |
488 | /** | |
489 | Return the @e Rata Die number of this date. | |
23324ae1 FM |
490 | By definition, the Rata Die number is a date specified as the number of days |
491 | relative to a base date of December 31 of the year 0. Thus January 1 of the | |
492 | year 1 is Rata Die day 1. | |
493 | */ | |
328f5751 | 494 | double GetRataDie() const; |
23324ae1 FM |
495 | |
496 | /** | |
497 | Returns the seconds in the given timezone (local one by default). | |
498 | */ | |
1d497b99 | 499 | short unsigned int GetSecond(const TimeZone& tz = Local) const; |
23324ae1 FM |
500 | |
501 | /** | |
502 | Returns the number of seconds since Jan 1, 1970. An assert failure will occur | |
503 | if the date is not in the range covered by @c time_t type. | |
504 | */ | |
328f5751 | 505 | time_t GetTicks() const; |
23324ae1 FM |
506 | |
507 | /** | |
508 | Returns the current time. | |
509 | */ | |
510 | static time_t GetTimeNow(); | |
511 | ||
512 | /** | |
513 | Returns broken down representation of the date and time. | |
514 | */ | |
328f5751 | 515 | Tm GetTm(const TimeZone& tz = Local) const; |
23324ae1 FM |
516 | |
517 | /** | |
518 | Returns the current time broken down. Note that this function returns a | |
519 | pointer to a static buffer that's reused by calls to this function and | |
520 | certain C library functions (e.g. localtime). If there is any chance your | |
521 | code might be used in a multi-threaded application, you really should use | |
522 | the flavour of function GetTmNow() | |
523 | taking a parameter. | |
524 | */ | |
4cc4bfaf | 525 | static struct tm* GetTmNow(); |
23324ae1 FM |
526 | |
527 | /** | |
528 | Returns the copy of this object to which | |
529 | SetToWeekDay() was applied. | |
530 | */ | |
531 | wxDateTime GetWeekDay(WeekDay weekday, int n = 1, | |
532 | Month month = Inv_Month, | |
328f5751 | 533 | int year = Inv_Year) const; |
23324ae1 FM |
534 | |
535 | /** | |
536 | Returns the copy of this object to which | |
537 | SetToWeekDayInSameWeek() was | |
538 | applied. | |
539 | */ | |
540 | wxDateTime GetWeekDayInSameWeek(WeekDay weekday, | |
328f5751 | 541 | WeekFlags flags = Monday_First) const; |
23324ae1 FM |
542 | |
543 | /** | |
544 | Gets the full (default) or abbreviated (specify @c Name_Abbr name of the | |
545 | given week day. | |
3c4f71cc | 546 | |
4cc4bfaf | 547 | @see GetMonthName() |
23324ae1 FM |
548 | */ |
549 | static wxString GetWeekDayName(WeekDay weekday, | |
550 | NameFlags flags = Name_Full); | |
551 | ||
552 | /** | |
553 | Returns the ordinal number of the week in the month (in 1...5 range). | |
23324ae1 FM |
554 | As GetWeekOfYear(), this function supports |
555 | both conventions for the week start. See the description of these | |
556 | @ref overview_wxdatetime "week start" conventions. | |
557 | */ | |
558 | wxDateTime_t GetWeekOfMonth(WeekFlags flags = Monday_First, | |
328f5751 | 559 | const TimeZone& tz = Local) const; |
23324ae1 FM |
560 | |
561 | /** | |
562 | Returns the number of the week of the year this date is in. The first week of | |
563 | the year is, according to international standards, the one containing Jan 4 or, | |
564 | equivalently, the first week which has Thursday in this year. Both of these | |
565 | definitions are the same as saying that the first week of the year must contain | |
566 | more than half of its days in this year. Accordingly, the week number will | |
567 | always be in 1...53 range (52 for non-leap years). | |
23324ae1 | 568 | The function depends on the @ref overview_wxdatetime "week start" convention |
4cc4bfaf | 569 | specified by the @a flags argument but its results for |
23324ae1 FM |
570 | @c Sunday_First are not well-defined as the ISO definition quoted above |
571 | applies to the weeks starting on Monday only. | |
572 | */ | |
573 | wxDateTime_t GetWeekOfYear(WeekFlags flags = Monday_First, | |
328f5751 | 574 | const TimeZone& tz = Local) const; |
23324ae1 FM |
575 | |
576 | /** | |
577 | Returns the year in the given timezone (local one by default). | |
578 | */ | |
328f5751 | 579 | int GetYear(const TimeZone& tz = Local) const; |
23324ae1 FM |
580 | |
581 | /** | |
582 | Returns the copy of this object to which | |
583 | SetToYearDay() was applied. | |
584 | */ | |
1d497b99 | 585 | wxDateTime GetYearDay(short unsigned int) const; |
23324ae1 FM |
586 | |
587 | /** | |
588 | Returns @true if IsStrictlyBetween() | |
589 | is @true or if the date is equal to one of the limit values. | |
3c4f71cc | 590 | |
4cc4bfaf | 591 | @see IsStrictlyBetween() |
23324ae1 | 592 | */ |
328f5751 | 593 | bool IsBetween(const wxDateTime& t1, const wxDateTime& t2) const; |
23324ae1 FM |
594 | |
595 | /** | |
596 | Returns @true if the DST is applied for this date in the given country. | |
597 | */ | |
328f5751 | 598 | int IsDST(Country country = Country_Default) const; |
23324ae1 FM |
599 | |
600 | /** | |
601 | Returns @true if DST was used n the given year (the current one by | |
602 | default) in the given country. | |
603 | */ | |
604 | static bool IsDSTApplicable(int year = Inv_Year, | |
605 | Country country = Country_Default); | |
606 | ||
607 | /** | |
608 | Returns @true if this date precedes the given one. | |
609 | */ | |
328f5751 | 610 | bool IsEarlierThan(const wxDateTime& datetime) const; |
23324ae1 FM |
611 | |
612 | /** | |
613 | Returns @true if the two dates are strictly identical. | |
614 | */ | |
328f5751 | 615 | bool IsEqualTo(const wxDateTime& datetime) const; |
23324ae1 FM |
616 | |
617 | /** | |
618 | Returns @true if the date is equal to another one up to the given time | |
619 | interval, i.e. if the absolute difference between the two dates is less than | |
620 | this interval. | |
621 | */ | |
328f5751 | 622 | bool IsEqualUpTo(const wxDateTime& dt, const wxTimeSpan& ts) const; |
23324ae1 FM |
623 | |
624 | /** | |
625 | Returns @true if the given date is later than the date of adoption of the | |
626 | Gregorian calendar in the given country (and hence the Gregorian calendar | |
627 | calculations make sense for it). | |
628 | */ | |
328f5751 | 629 | bool IsGregorianDate(GregorianAdoption country = Gr_Standard) const; |
23324ae1 FM |
630 | |
631 | /** | |
632 | Returns @true if this date is later than the given one. | |
633 | */ | |
328f5751 | 634 | bool IsLaterThan(const wxDateTime& datetime) const; |
23324ae1 FM |
635 | |
636 | /** | |
4cc4bfaf | 637 | Returns @true if the @a year is a leap one in the specified calendar. |
23324ae1 FM |
638 | This functions supports Gregorian and Julian calendars. |
639 | */ | |
640 | static bool IsLeapYear(int year = Inv_Year, | |
641 | Calendar cal = Gregorian); | |
642 | ||
643 | /** | |
644 | Returns @true if the date is the same without comparing the time parts. | |
645 | */ | |
328f5751 | 646 | bool IsSameDate(const wxDateTime& dt) const; |
23324ae1 FM |
647 | |
648 | /** | |
649 | Returns @true if the time is the same (although dates may differ). | |
650 | */ | |
328f5751 | 651 | bool IsSameTime(const wxDateTime& dt) const; |
23324ae1 FM |
652 | |
653 | /** | |
654 | Returns @true if this date lies strictly between the two others, | |
3c4f71cc | 655 | |
4cc4bfaf | 656 | @see IsBetween() |
23324ae1 FM |
657 | */ |
658 | bool IsStrictlyBetween(const wxDateTime& t1, | |
328f5751 | 659 | const wxDateTime& t2) const; |
23324ae1 FM |
660 | |
661 | /** | |
662 | Returns @true if the object represents a valid time moment. | |
663 | */ | |
328f5751 | 664 | bool IsValid() const; |
23324ae1 FM |
665 | |
666 | /** | |
667 | This function returns @true if the specified (or default) country is one | |
668 | of Western European ones. It is used internally by wxDateTime to determine the | |
669 | DST convention and date and time formatting rules. | |
670 | */ | |
671 | static bool IsWestEuropeanCountry(Country country = Country_Default); | |
672 | ||
673 | /** | |
674 | Returns @true is this day is not a holiday in the given country. | |
675 | */ | |
328f5751 | 676 | bool IsWorkDay(Country country = Country_Default) const; |
23324ae1 FM |
677 | |
678 | /** | |
679 | Same as FromTimezone() but modifies the object | |
680 | in place. | |
681 | */ | |
682 | wxDateTime MakeFromTimezone(const TimeZone& tz, | |
4cc4bfaf | 683 | bool noDST = false); |
23324ae1 FM |
684 | |
685 | /** | |
686 | Modifies the object in place to represent the date in another time zone. If | |
4cc4bfaf | 687 | @a noDST is @true, no DST adjustments will be made. |
23324ae1 FM |
688 | */ |
689 | wxDateTime MakeTimezone(const TimeZone& tz, | |
4cc4bfaf | 690 | bool noDST = false); |
23324ae1 FM |
691 | |
692 | /** | |
693 | This is the same as calling MakeTimezone() with | |
694 | the argument @c GMT0. | |
695 | */ | |
1d497b99 | 696 | wxDateTime& MakeUTC(bool noDST = false); |
23324ae1 FM |
697 | |
698 | /** | |
699 | Returns the object corresponding to the current time. | |
23324ae1 | 700 | Example: |
3c4f71cc | 701 | |
23324ae1 FM |
702 | Note that this function is accurate up to second: |
703 | UNow() should be used for better precision | |
704 | (but it is less efficient and might not be available on all platforms). | |
3c4f71cc | 705 | |
4cc4bfaf | 706 | @see Today() |
23324ae1 | 707 | */ |
4cc4bfaf | 708 | static wxDateTime Now(); |
23324ae1 FM |
709 | |
710 | //@{ | |
711 | /** | |
712 | This function is like ParseDateTime(), but it | |
713 | only allows the date to be specified. It is thus less flexible then | |
714 | ParseDateTime(), but also has less chances to | |
715 | misinterpret the user input. | |
23324ae1 FM |
716 | Returns @NULL if the conversion failed, otherwise return the pointer to |
717 | the character which stopped the scan. | |
718 | */ | |
4cc4bfaf FM |
719 | const char* ParseDate(const wxString& date, |
720 | wxString::const_iterator* end = NULL); | |
721 | const char* ParseDate(const char* date); | |
722 | const wchar_t* ParseDate(const wchar_t* date); | |
23324ae1 FM |
723 | //@} |
724 | ||
725 | //@{ | |
726 | /** | |
4cc4bfaf | 727 | Parses the string @a datetime containing the date and time in free format. |
23324ae1 FM |
728 | This function tries as hard as it can to interpret the given string as date |
729 | and time. Unlike wxDateTime::ParseRfc822Date, it | |
730 | will accept anything that may be accepted and will only reject strings which | |
731 | can not be parsed in any way at all. | |
23324ae1 FM |
732 | Returns @NULL if the conversion failed, otherwise return the pointer to |
733 | the character which stopped the scan. | |
734 | */ | |
4cc4bfaf FM |
735 | const char* ParseDateTime(const wxString& datetime, |
736 | wxString::const_iterator* end = NULL); | |
737 | const char* ParseDateTime(const char* datetime); | |
738 | const wchar_t* ParseDateTime(const wchar_t* datetime); | |
23324ae1 FM |
739 | //@} |
740 | ||
741 | //@{ | |
742 | /** | |
4cc4bfaf | 743 | This function parses the string @a date according to the given |
23324ae1 FM |
744 | @e format. The system @c strptime(3) function is used whenever available, |
745 | but even if it is not, this function is still implemented, although support | |
746 | for locale-dependent format specifiers such as @c "%c", @c "%x" or @c "%X" may | |
747 | not be perfect and GNU extensions such as @c "%z" and @c "%Z" are | |
748 | not implemented. This function does handle the month and weekday | |
749 | names in the current locale on all platforms, however. | |
23324ae1 FM |
750 | Please see the description of the ANSI C function @c strftime(3) for the syntax |
751 | of the format string. | |
4cc4bfaf | 752 | The @a dateDef parameter is used to fill in the fields which could not be |
23324ae1 FM |
753 | determined from the format string. For example, if the format is @c "%d" (the |
754 | ay of the month), the month and the year are taken from @e dateDef. If | |
755 | it is not specified, Today() is used as the | |
756 | default date. | |
23324ae1 FM |
757 | Returns @NULL if the conversion failed, otherwise return the pointer to |
758 | the character which stopped the scan. | |
759 | */ | |
4cc4bfaf FM |
760 | const char* ParseFormat(const wxString& date, |
761 | const wxString& format = wxDefaultDateTimeFormat, | |
762 | const wxDateTime& dateDef = wxDefaultDateTime, | |
763 | wxString::const_iterator* end = NULL); | |
764 | const char* ParseFormat(const char* date, | |
765 | const wxString& format = wxDefaultDateTimeFormat, | |
766 | const wxDateTime& dateDef = wxDefaultDateTime); | |
767 | const wchar_t* ParseFormat(const wchar_t* date, | |
768 | const wxString& format = wxDefaultDateTimeFormat, | |
769 | const wxDateTime& dateDef = wxDefaultDateTime); | |
23324ae1 FM |
770 | //@} |
771 | ||
772 | /** | |
773 | This function parses the string containing the date and time in ISO 8601 | |
774 | combined format (YYYY-MM-DDTHH:MM:SS). The separator between the date and time | |
4cc4bfaf | 775 | parts must be equal to @a sep for the function to succeed. |
23324ae1 FM |
776 | Returns @true if the entire string was parsed successfully, @false |
777 | otherwise. | |
778 | */ | |
779 | bool ParseISOCombined(const wxString& date, char sep = 'T'); | |
780 | ||
781 | /** | |
782 | This function parses the date in ISO 8601 format (YYYY-MM-DD). | |
23324ae1 FM |
783 | Returns @true if the entire string was parsed successfully, @false |
784 | otherwise. | |
785 | */ | |
786 | bool ParseISODate(const wxString& date); | |
787 | ||
788 | /** | |
789 | This function parses the time in ISO 8601 format (HH:MM:SS). | |
23324ae1 FM |
790 | Returns @true if the entire string was parsed successfully, @false |
791 | otherwise. | |
792 | */ | |
793 | bool ParseISOTime(const wxString& date); | |
794 | ||
795 | //@{ | |
796 | /** | |
4cc4bfaf | 797 | Parses the string @a date looking for a date formatted according to the RFC |
23324ae1 FM |
798 | 822 in it. The exact description of this format may, of course, be found in |
799 | the RFC (section 5), but, briefly, this is the format used in the headers of | |
800 | Internet email messages and one of the most common strings expressing date in | |
801 | this format may be something like @c "Sat, 18 Dec 1999 00:48:30 +0100". | |
23324ae1 FM |
802 | Returns @NULL if the conversion failed, otherwise return the pointer to |
803 | the character immediately following the part of the string which could be | |
804 | parsed. If the entire string contains only the date in RFC 822 format, | |
805 | the returned pointer will be pointing to a @c NUL character. | |
23324ae1 FM |
806 | This function is intentionally strict, it will return an error for any string |
807 | which is not RFC 822 compliant. If you need to parse date formatted in more | |
808 | free ways, you should use ParseDateTime() or | |
809 | ParseDate() instead. | |
810 | */ | |
4cc4bfaf FM |
811 | const char* ParseRfc822Date(const wxString& date, |
812 | wxString::const_iterator* end = NULL); | |
813 | const char* ParseRfc822Date(const char* date); | |
814 | const wchar_t* ParseRfc822Date(const wchar_t* date); | |
23324ae1 FM |
815 | //@} |
816 | ||
817 | //@{ | |
818 | /** | |
819 | This functions is like ParseDateTime(), but | |
820 | only allows the time to be specified in the input string. | |
23324ae1 FM |
821 | Returns @NULL if the conversion failed, otherwise return the pointer to |
822 | the character which stopped the scan. | |
823 | */ | |
4cc4bfaf FM |
824 | const char* ParseTime(const wxString& time, |
825 | wxString::const_iterator* end = NULL); | |
826 | const char* ParseTime(const char* time); | |
827 | const wchar_t* ParseTime(const wchar_t* time); | |
23324ae1 FM |
828 | //@} |
829 | ||
830 | /** | |
831 | These functions convert wxDateTime objects to and from text. The | |
832 | conversions to text are mostly trivial: you can either do it using the default | |
833 | date and time representations for the current locale ( | |
834 | FormatDate() and | |
835 | wxDateTime::FormatTime), using the international standard | |
836 | representation defined by ISO 8601 ( | |
837 | FormatISODate(), | |
838 | FormatISOTime() and | |
839 | wxDateTime::FormatISOCombined) or by specifying any | |
840 | format at all and using Format() directly. | |
23324ae1 FM |
841 | The conversions from text are more interesting, as there are much more |
842 | possibilities to care about. The simplest cases can be taken care of with | |
843 | ParseFormat() which can parse any date in the | |
844 | given (rigid) format. wxDateTime::ParseRfc822Date is | |
845 | another function for parsing dates in predefined format -- the one of RFC 822 | |
846 | which (still...) defines the format of email messages on the Internet. This | |
847 | format can not be described with @c strptime(3)-like format strings used by | |
848 | Format(), hence the need for a separate function. | |
23324ae1 FM |
849 | But the most interesting functions are |
850 | ParseTime(), | |
851 | ParseDate() and | |
852 | ParseDateTime(). They try to parse the date | |
853 | ans time (or only one of them) in 'free' format, i.e. allow them to be | |
854 | specified in any of possible ways. These functions will usually be used to | |
855 | parse the (interactive) user input which is not bound to be in any predefined | |
856 | format. As an example, ParseDateTime() can | |
857 | parse the strings such as @c "tomorrow", @c "March first" and even | |
858 | @c "next Sunday". | |
23324ae1 FM |
859 | Finally notice that each of the parsing functions is available in several |
860 | overloads: if the input string is a narrow (@c char *) string, then a | |
861 | narrow pointer is returned. If the input string is a wide string, a wide char | |
862 | pointer is returned. Finally, if the input parameter is a wxString, a narrow | |
863 | char pointer is also returned for backwards compatibility but there is also an | |
864 | additional argument of wxString::const_iterator type in which, if it is not | |
865 | @NULL, an iterator pointing to the end of the scanned string part is returned. | |
23324ae1 | 866 | ParseFormat() |
3c4f71cc | 867 | |
23324ae1 | 868 | ParseDateTime() |
3c4f71cc | 869 | |
23324ae1 | 870 | ParseDate() |
3c4f71cc | 871 | |
23324ae1 | 872 | ParseTime() |
3c4f71cc | 873 | |
23324ae1 | 874 | ParseISODate() |
3c4f71cc | 875 | |
23324ae1 | 876 | ParseISOTime() |
3c4f71cc | 877 | |
23324ae1 | 878 | ParseISOCombined() |
3c4f71cc | 879 | |
23324ae1 | 880 | wxDateTime::ParseRfc822Date |
3c4f71cc | 881 | |
23324ae1 | 882 | Format() |
3c4f71cc | 883 | |
23324ae1 | 884 | FormatDate() |
3c4f71cc | 885 | |
23324ae1 | 886 | FormatTime() |
3c4f71cc | 887 | |
23324ae1 | 888 | FormatISOCombined() |
3c4f71cc | 889 | |
23324ae1 | 890 | FormatISODate() |
3c4f71cc | 891 | |
23324ae1 FM |
892 | FormatISOTime() |
893 | */ | |
894 | ||
895 | ||
896 | /** | |
897 | Reset time to midnight (00:00:00) without changing the date. | |
898 | */ | |
1d497b99 | 899 | wxDateTime& ResetTime(); |
23324ae1 FM |
900 | |
901 | /** | |
902 | Sets the date and time from the parameters. | |
903 | */ | |
4cc4bfaf FM |
904 | wxDateTime Set(wxDateTime_t day, Month month = Inv_Month, |
905 | int year = Inv_Year, | |
906 | wxDateTime_t hour = 0, | |
907 | wxDateTime_t minute = 0, | |
908 | wxDateTime_t second = 0, | |
909 | wxDateTime_t millisec = 0); | |
23324ae1 FM |
910 | |
911 | /** | |
912 | Sets the country to use by default. This setting influences the DST | |
913 | calculations, date formatting and other things. | |
4cc4bfaf | 914 | The possible values for @a country parameter are enumerated in |
23324ae1 | 915 | @ref overview_wxdatetime "wxDateTime constants section". |
3c4f71cc | 916 | |
4cc4bfaf | 917 | @see GetCountry() |
23324ae1 FM |
918 | */ |
919 | static void SetCountry(Country country); | |
920 | ||
921 | /** | |
922 | Sets the day without changing other date components. | |
923 | */ | |
1d497b99 | 924 | wxDateTime& SetDay(short unsigned int); |
23324ae1 FM |
925 | |
926 | /** | |
927 | Sets the date from the date and time in | |
928 | DOS | |
929 | format. | |
930 | */ | |
931 | wxDateTime Set(unsigned long ddt); | |
932 | ||
933 | /** | |
934 | Sets the hour without changing other date components. | |
935 | */ | |
1d497b99 | 936 | wxDateTime& SetHour(short unsigned int); |
23324ae1 FM |
937 | |
938 | /** | |
939 | Sets the millisecond without changing other date components. | |
940 | */ | |
1d497b99 | 941 | wxDateTime& SetMillisecond(short unsigned int); |
23324ae1 FM |
942 | |
943 | /** | |
944 | Sets the minute without changing other date components. | |
945 | */ | |
1d497b99 | 946 | wxDateTime& SetMinute(short unsigned int); |
23324ae1 FM |
947 | |
948 | /** | |
949 | Sets the month without changing other date components. | |
950 | */ | |
1d497b99 | 951 | wxDateTime& SetMonth(Month month); |
23324ae1 FM |
952 | |
953 | /** | |
954 | Sets the second without changing other date components. | |
955 | */ | |
1d497b99 | 956 | wxDateTime& SetSecond(short unsigned int); |
23324ae1 FM |
957 | |
958 | /** | |
959 | Sets the date and time of to the current values. Same as assigning the result | |
960 | of Now() to this object. | |
961 | */ | |
1d497b99 | 962 | wxDateTime& SetToCurrent(); |
23324ae1 FM |
963 | |
964 | /** | |
965 | Sets the date to the last day in the specified month (the current one by | |
966 | default). | |
23324ae1 FM |
967 | Returns the reference to the modified object itself. |
968 | */ | |
969 | wxDateTime SetToLastMonthDay(Month month = Inv_Month, | |
970 | int year = Inv_Year); | |
971 | ||
972 | /** | |
973 | The effect of calling this function is the same as of calling | |
974 | @c SetToWeekDay(-1, weekday, month, year). The date will be set to the last | |
4cc4bfaf | 975 | @a weekday in the given month and year (the current ones by default). |
23324ae1 FM |
976 | Always returns @true. |
977 | */ | |
978 | bool SetToLastWeekDay(WeekDay weekday, Month month = Inv_Month, | |
979 | int year = Inv_Year); | |
980 | ||
981 | /** | |
4cc4bfaf | 982 | Sets the date so that it will be the first @a weekday following the current |
23324ae1 | 983 | date. |
23324ae1 FM |
984 | Returns the reference to the modified object itself. |
985 | */ | |
1d497b99 | 986 | wxDateTime& SetToNextWeekDay(WeekDay weekday); |
23324ae1 FM |
987 | |
988 | /** | |
4cc4bfaf | 989 | Sets the date so that it will be the last @a weekday before the current |
23324ae1 | 990 | date. |
23324ae1 FM |
991 | Returns the reference to the modified object itself. |
992 | */ | |
1d497b99 | 993 | wxDateTime& SetToPrevWeekDay(WeekDay weekday); |
23324ae1 FM |
994 | |
995 | /** | |
4cc4bfaf | 996 | Sets the date to the @e n-th @a weekday in the given month of the given |
23324ae1 FM |
997 | year (the current month and year are used by default). The parameter @e n |
998 | may be either positive (counting from the beginning of the month) or negative | |
999 | (counting from the end of it). | |
23324ae1 FM |
1000 | For example, @c SetToWeekDay(2, wxDateTime::Wed) will set the date to the |
1001 | second Wednesday in the current month and | |
1002 | @c SetToWeekDay(-1, wxDateTime::Sun) -- to the last Sunday in it. | |
23324ae1 FM |
1003 | Returns @true if the date was modified successfully, @false |
1004 | otherwise meaning that the specified date doesn't exist. | |
1005 | */ | |
1006 | bool SetToWeekDay(WeekDay weekday, int n = 1, | |
1007 | Month month = Inv_Month, | |
4cc4bfaf | 1008 | int year = Inv_Year); |
23324ae1 FM |
1009 | |
1010 | /** | |
1011 | Adjusts the date so that it will still lie in the same week as before, but its | |
1012 | week day will be the given one. | |
23324ae1 FM |
1013 | Returns the reference to the modified object itself. |
1014 | */ | |
1015 | wxDateTime SetToWeekDayInSameWeek(WeekDay weekday, | |
1016 | WeekFlags flags = Monday_First); | |
1017 | ||
1018 | /** | |
4cc4bfaf FM |
1019 | Set the date to the given @a weekday in the week number @a numWeek of the |
1020 | given @a year . The number should be in range 1...53. | |
23324ae1 FM |
1021 | Note that the returned date may be in a different year than the one passed to |
1022 | this function because both the week 1 and week 52 or 53 (for leap years) | |
1023 | contain days from different years. See | |
1024 | GetWeekOfYear() for the explanation of how the | |
1025 | year weeks are counted. | |
1026 | */ | |
1027 | static wxDateTime SetToWeekOfYear(int year, wxDateTime_t numWeek, | |
1028 | WeekDay weekday = Mon); | |
1029 | ||
1030 | /** | |
4cc4bfaf | 1031 | Sets the date to the day number @a yday in the same year (i.e., unlike the |
23324ae1 FM |
1032 | other functions, this one does not use the current year). The day number |
1033 | should be in the range 1...366 for the leap years and 1...365 for | |
1034 | the other ones. | |
23324ae1 FM |
1035 | Returns the reference to the modified object itself. |
1036 | */ | |
1d497b99 | 1037 | wxDateTime& SetToYearDay(short unsigned int); |
23324ae1 FM |
1038 | |
1039 | /** | |
1040 | Sets the year without changing other date components. | |
1041 | */ | |
1d497b99 | 1042 | wxDateTime& SetYear(int year); |
23324ae1 FM |
1043 | |
1044 | /** | |
1045 | For convenience, all static functions are collected here. These functions | |
1046 | either set or return the static variables of wxDateSpan (the country), return | |
1047 | the current moment, year, month or number of days in it, or do some general | |
1048 | calendar-related actions. | |
23324ae1 FM |
1049 | Please note that although several function accept an extra @e Calendar |
1050 | parameter, it is currently ignored as only the Gregorian calendar is | |
1051 | supported. Future versions will support other calendars. | |
3c4f71cc | 1052 | |
23324ae1 | 1053 | SetCountry() |
3c4f71cc | 1054 | |
23324ae1 | 1055 | GetCountry() |
3c4f71cc | 1056 | |
23324ae1 | 1057 | IsWestEuropeanCountry() |
3c4f71cc | 1058 | |
23324ae1 | 1059 | GetCurrentYear() |
3c4f71cc | 1060 | |
23324ae1 | 1061 | ConvertYearToBC() |
3c4f71cc | 1062 | |
23324ae1 | 1063 | GetCurrentMonth() |
3c4f71cc | 1064 | |
23324ae1 | 1065 | IsLeapYear() |
3c4f71cc | 1066 | |
23324ae1 | 1067 | @ref getcenturystatic() GetCentury |
3c4f71cc | 1068 | |
23324ae1 | 1069 | GetNumberOfDays() |
3c4f71cc | 1070 | |
23324ae1 | 1071 | GetNumberOfDays() |
3c4f71cc | 1072 | |
23324ae1 | 1073 | GetMonthName() |
3c4f71cc | 1074 | |
23324ae1 | 1075 | GetWeekDayName() |
3c4f71cc | 1076 | |
23324ae1 | 1077 | GetAmPmStrings() |
3c4f71cc | 1078 | |
23324ae1 | 1079 | IsDSTApplicable() |
3c4f71cc | 1080 | |
23324ae1 | 1081 | GetBeginDST() |
3c4f71cc | 1082 | |
23324ae1 | 1083 | GetEndDST() |
3c4f71cc | 1084 | |
23324ae1 | 1085 | Now() |
3c4f71cc | 1086 | |
23324ae1 | 1087 | UNow() |
3c4f71cc | 1088 | |
23324ae1 FM |
1089 | Today() |
1090 | */ | |
1091 | ||
1092 | ||
1093 | /** | |
1094 | Subtracts another date from this one and returns the difference between them | |
1095 | as wxTimeSpan. | |
1096 | */ | |
328f5751 | 1097 | wxTimeSpan Subtract(const wxDateTime& dt) const; |
23324ae1 FM |
1098 | |
1099 | /** | |
1100 | Please see the @ref overview_tdatetimezones "time zone overview" for more | |
1101 | information about time zones. Normally, these functions should be rarely used. | |
23324ae1 | 1102 | FromTimezone() |
3c4f71cc | 1103 | |
23324ae1 | 1104 | ToTimezone() |
3c4f71cc | 1105 | |
23324ae1 | 1106 | MakeTimezone() |
3c4f71cc | 1107 | |
23324ae1 | 1108 | MakeFromTimezone() |
3c4f71cc | 1109 | |
23324ae1 | 1110 | ToUTC() |
3c4f71cc | 1111 | |
23324ae1 | 1112 | MakeUTC() |
3c4f71cc | 1113 | |
23324ae1 | 1114 | GetBeginDST() |
3c4f71cc | 1115 | |
23324ae1 | 1116 | GetEndDST() |
3c4f71cc | 1117 | |
23324ae1 FM |
1118 | IsDST() |
1119 | */ | |
1120 | ||
1121 | ||
1122 | /** | |
4cc4bfaf | 1123 | Transform the date to the given time zone. If @a noDST is @true, no |
23324ae1 | 1124 | DST adjustments will be made. |
23324ae1 FM |
1125 | Returns the date in the new time zone. |
1126 | */ | |
328f5751 | 1127 | wxDateTime ToTimezone(const TimeZone& tz, bool noDST = false) const; |
23324ae1 FM |
1128 | |
1129 | /** | |
1130 | This is the same as calling ToTimezone() with | |
1131 | the argument @c GMT0. | |
1132 | */ | |
328f5751 | 1133 | wxDateTime ToUTC(bool noDST = false) const; |
23324ae1 FM |
1134 | |
1135 | /** | |
1136 | Returns the object corresponding to the midnight of the current day (i.e. the | |
1137 | same as Now(), but the time part is set to 0). | |
3c4f71cc | 1138 | |
4cc4bfaf | 1139 | @see Now() |
23324ae1 FM |
1140 | */ |
1141 | static wxDateTime Today(); | |
1142 | ||
1143 | /** | |
1144 | Returns the object corresponding to the current time including the | |
1145 | milliseconds if a function to get time with such precision is available on the | |
1146 | current platform (supported under most Unices and Win32). | |
3c4f71cc | 1147 | |
4cc4bfaf | 1148 | @see Now() |
23324ae1 | 1149 | */ |
4cc4bfaf | 1150 | static wxDateTime UNow(); |
23324ae1 FM |
1151 | |
1152 | /** | |
1153 | Same as @ref settm() Set. | |
1154 | */ | |
1155 | wxDateTime operator(const struct tm& tm); | |
4cc4bfaf | 1156 | }; |
23324ae1 | 1157 | |
65874118 FM |
1158 | /** |
1159 | Global instance of an empty wxDateTime object. | |
1160 | ||
1161 | @todo wouldn't be better to rename it wxNullDateTime as for the rest of wx global objects | |
1162 | which are initialized to an empty value? | |
1163 | */ | |
1164 | wxDateTime wxDefaultDateTime; | |
1165 | ||
23324ae1 | 1166 | |
e54c96f1 | 1167 | |
23324ae1 FM |
1168 | /** |
1169 | @class wxDateTimeWorkDays | |
1170 | @wxheader{datetime.h} | |
7c913512 FM |
1171 | |
1172 | ||
23324ae1 FM |
1173 | @library{wxbase} |
1174 | @category{FIXME} | |
1175 | */ | |
7c913512 | 1176 | class wxDateTimeWorkDays |
23324ae1 FM |
1177 | { |
1178 | public: | |
7c913512 | 1179 | |
23324ae1 FM |
1180 | }; |
1181 | ||
1182 | ||
e54c96f1 | 1183 | |
23324ae1 FM |
1184 | /** |
1185 | @class wxDateSpan | |
1186 | @wxheader{datetime.h} | |
7c913512 | 1187 | |
23324ae1 FM |
1188 | This class is a "logical time span" and is useful for implementing program |
1189 | logic for such things as "add one month to the date" which, in general, | |
1190 | doesn't mean to add 60*60*24*31 seconds to it, but to take the same date | |
1191 | the next month (to understand that this is indeed different consider adding | |
1192 | one month to Feb, 15 -- we want to get Mar, 15, of course). | |
7c913512 | 1193 | |
23324ae1 FM |
1194 | When adding a month to the date, all lesser components (days, hours, ...) |
1195 | won't be changed unless the resulting date would be invalid: for example, | |
1196 | Jan 31 + 1 month will be Feb 28, not (non-existing) Feb 31. | |
7c913512 | 1197 | |
23324ae1 FM |
1198 | Because of this feature, adding and subtracting back again the same |
1199 | wxDateSpan will @b not, in general give back the original date: Feb 28 - 1 | |
1200 | month will be Jan 28, not Jan 31! | |
7c913512 | 1201 | |
23324ae1 FM |
1202 | wxDateSpan objects can be either positive or negative. They may be |
1203 | multiplied by scalars which multiply all deltas by the scalar: i.e. | |
1204 | 2*(1 month and 1 day) is 2 months and 2 days. They can | |
7c913512 | 1205 | be added together and with wxDateTime or |
23324ae1 FM |
1206 | wxTimeSpan, but the type of result is different for each |
1207 | case. | |
7c913512 | 1208 | |
23324ae1 FM |
1209 | Beware about weeks: if you specify both weeks and days, the total number of |
1210 | days added will be 7*weeks + days! See also GetTotalDays() | |
1211 | function. | |
7c913512 | 1212 | |
23324ae1 FM |
1213 | Equality operators are defined for wxDateSpans. Two datespans are equal if |
1214 | and only if they both give the same target date when added to @b every | |
1215 | source date. Thus wxDateSpan::Months(1) is not equal to wxDateSpan::Days(30), | |
1216 | because they don't give the same date when added to 1 Feb. But | |
1217 | wxDateSpan::Days(14) is equal to wxDateSpan::Weeks(2) | |
7c913512 | 1218 | |
23324ae1 FM |
1219 | Finally, notice that for adding hours, minutes and so on you don't need this |
1220 | class at all: wxTimeSpan will do the job because there | |
1221 | are no subtleties associated with those (we don't support leap seconds). | |
7c913512 | 1222 | |
23324ae1 FM |
1223 | @library{wxbase} |
1224 | @category{data} | |
7c913512 | 1225 | |
e54c96f1 | 1226 | @see @ref overview_wxdatetimeoverview "Date classes overview", wxDateTime |
23324ae1 | 1227 | */ |
7c913512 | 1228 | class wxDateSpan |
23324ae1 FM |
1229 | { |
1230 | public: | |
1231 | /** | |
1232 | Constructs the date span object for the given number of years, months, weeks | |
1233 | and days. Note that the weeks and days add together if both are given. | |
1234 | */ | |
1235 | wxDateSpan(int years = 0, int months = 0, int weeks = 0, | |
1236 | int days = 0); | |
1237 | ||
1238 | //@{ | |
1239 | /** | |
1240 | Returns the sum of two date spans. The first version returns a new object, the | |
1241 | second and third ones modify this object in place. | |
1242 | */ | |
1243 | wxDateSpan Add(const wxDateSpan& other); | |
328f5751 | 1244 | const wxDateSpan& Add(const wxDateSpan& other); |
7c913512 | 1245 | wxDateSpan operator+=(const wxDateSpan& other); |
23324ae1 FM |
1246 | //@} |
1247 | ||
1248 | /** | |
1249 | Returns a date span object corresponding to one day. | |
3c4f71cc | 1250 | |
4cc4bfaf | 1251 | @see Days() |
23324ae1 | 1252 | */ |
4cc4bfaf | 1253 | static wxDateSpan Day(); |
23324ae1 FM |
1254 | |
1255 | /** | |
1256 | Returns a date span object corresponding to the given number of days. | |
3c4f71cc | 1257 | |
4cc4bfaf | 1258 | @see Day() |
23324ae1 FM |
1259 | */ |
1260 | static wxDateSpan Days(int days); | |
1261 | ||
1262 | /** | |
1263 | Returns the number of days (only, that it not counting the weeks component!) | |
1264 | in this date span. | |
3c4f71cc | 1265 | |
4cc4bfaf | 1266 | @see GetTotalDays() |
23324ae1 | 1267 | */ |
328f5751 | 1268 | int GetDays() const; |
23324ae1 FM |
1269 | |
1270 | /** | |
1271 | Returns the number of the months (not counting the years) in this date span. | |
1272 | */ | |
328f5751 | 1273 | int GetMonths() const; |
23324ae1 FM |
1274 | |
1275 | /** | |
1276 | Returns the combined number of days in this date span, counting both weeks and | |
1277 | days. It still doesn't take neither months nor years into the account. | |
3c4f71cc | 1278 | |
4cc4bfaf | 1279 | @see GetWeeks(), GetDays() |
23324ae1 | 1280 | */ |
328f5751 | 1281 | int GetTotalDays() const; |
23324ae1 FM |
1282 | |
1283 | /** | |
1284 | Returns the number of weeks in this date span. | |
3c4f71cc | 1285 | |
4cc4bfaf | 1286 | @see GetTotalDays() |
23324ae1 | 1287 | */ |
328f5751 | 1288 | int GetWeeks() const; |
23324ae1 FM |
1289 | |
1290 | /** | |
1291 | Returns the number of years in this date span. | |
1292 | */ | |
328f5751 | 1293 | int GetYears() const; |
23324ae1 FM |
1294 | |
1295 | /** | |
1296 | Returns a date span object corresponding to one month. | |
3c4f71cc | 1297 | |
4cc4bfaf | 1298 | @see Months() |
23324ae1 FM |
1299 | */ |
1300 | static wxDateSpan Month(); | |
1301 | ||
1302 | /** | |
1303 | Returns a date span object corresponding to the given number of months. | |
3c4f71cc | 1304 | |
4cc4bfaf | 1305 | @see Month() |
23324ae1 FM |
1306 | */ |
1307 | static wxDateSpan Months(int mon); | |
1308 | ||
1309 | //@{ | |
1310 | /** | |
1311 | Returns the product of the date span by the specified @e factor. The | |
1312 | product is computed by multiplying each of the components by the factor. | |
23324ae1 FM |
1313 | The first version returns a new object, the second and third ones modify this |
1314 | object in place. | |
1315 | */ | |
1316 | wxDateSpan Multiply(int factor); | |
328f5751 | 1317 | const wxDateSpan& Multiply(int factor); |
7c913512 | 1318 | wxDateSpan operator*=(int factor); |
23324ae1 FM |
1319 | //@} |
1320 | ||
1321 | //@{ | |
1322 | /** | |
1323 | Changes the sign of this date span. | |
3c4f71cc | 1324 | |
4cc4bfaf | 1325 | @see Negate() |
23324ae1 FM |
1326 | */ |
1327 | wxDateSpan Neg(); | |
7c913512 | 1328 | wxDateSpan operator-(); |
23324ae1 FM |
1329 | //@} |
1330 | ||
1331 | /** | |
1332 | Returns the date span with the opposite sign. | |
3c4f71cc | 1333 | |
4cc4bfaf | 1334 | @see Neg() |
23324ae1 | 1335 | */ |
328f5751 | 1336 | wxDateSpan Negate() const; |
23324ae1 FM |
1337 | |
1338 | /** | |
1339 | Sets the number of days (without modifying any other components) in this date | |
1340 | span. | |
1341 | */ | |
1d497b99 | 1342 | wxDateSpan& SetDays(int n); |
23324ae1 FM |
1343 | |
1344 | /** | |
1345 | Sets the number of months (without modifying any other components) in this | |
1346 | date span. | |
1347 | */ | |
1d497b99 | 1348 | wxDateSpan& SetMonths(int n); |
23324ae1 FM |
1349 | |
1350 | /** | |
1351 | Sets the number of weeks (without modifying any other components) in this date | |
1352 | span. | |
1353 | */ | |
1d497b99 | 1354 | wxDateSpan& SetWeeks(int n); |
23324ae1 FM |
1355 | |
1356 | /** | |
1357 | Sets the number of years (without modifying any other components) in this date | |
1358 | span. | |
1359 | */ | |
1d497b99 | 1360 | wxDateSpan& SetYears(int n); |
23324ae1 FM |
1361 | |
1362 | //@{ | |
1363 | /** | |
1364 | Returns the difference of two date spans. The first version returns a new | |
1365 | object, the second and third ones modify this object in place. | |
1366 | */ | |
1367 | wxDateSpan Subtract(const wxDateSpan& other); | |
328f5751 | 1368 | const wxDateSpan& Subtract(const wxDateSpan& other); |
7c913512 | 1369 | wxDateSpan operator+=(const wxDateSpan& other); |
23324ae1 FM |
1370 | //@} |
1371 | ||
1372 | /** | |
1373 | Returns a date span object corresponding to one week. | |
3c4f71cc | 1374 | |
4cc4bfaf | 1375 | @see Weeks() |
23324ae1 FM |
1376 | */ |
1377 | static wxDateSpan Week(); | |
1378 | ||
1379 | /** | |
1380 | Returns a date span object corresponding to the given number of weeks. | |
3c4f71cc | 1381 | |
4cc4bfaf | 1382 | @see Week() |
23324ae1 FM |
1383 | */ |
1384 | static wxDateSpan Weeks(int weeks); | |
1385 | ||
1386 | /** | |
1387 | Returns a date span object corresponding to one year. | |
3c4f71cc | 1388 | |
4cc4bfaf | 1389 | @see Years() |
23324ae1 FM |
1390 | */ |
1391 | static wxDateSpan Year(); | |
1392 | ||
1393 | /** | |
1394 | Returns a date span object corresponding to the given number of years. | |
3c4f71cc | 1395 | |
4cc4bfaf | 1396 | @see Year() |
23324ae1 FM |
1397 | */ |
1398 | static wxDateSpan Years(int years); | |
1399 | ||
1400 | /** | |
1401 | Returns @true if this date span is different from the other one. | |
1402 | */ | |
1d497b99 | 1403 | bool operator!=(const wxDateSpan&) const; |
23324ae1 FM |
1404 | |
1405 | /** | |
1406 | Returns @true if this date span is equal to the other one. Two date spans | |
1407 | are considered equal if and only if they have the same number of years and | |
1408 | months and the same total number of days (counting both days and weeks). | |
1409 | */ | |
1d497b99 | 1410 | bool operator==(const wxDateSpan&) const; |
23324ae1 FM |
1411 | }; |
1412 | ||
1413 | ||
e54c96f1 | 1414 | |
23324ae1 FM |
1415 | /** |
1416 | @class wxTimeSpan | |
1417 | @wxheader{datetime.h} | |
7c913512 | 1418 | |
23324ae1 | 1419 | wxTimeSpan class represents a time interval. |
7c913512 | 1420 | |
23324ae1 FM |
1421 | @library{wxbase} |
1422 | @category{data} | |
7c913512 | 1423 | |
e54c96f1 | 1424 | @see @ref overview_wxdatetimeoverview "Date classes overview", wxDateTime |
23324ae1 | 1425 | */ |
7c913512 | 1426 | class wxTimeSpan |
23324ae1 FM |
1427 | { |
1428 | public: | |
1429 | //@{ | |
1430 | /** | |
1431 | Constructs timespan from separate values for each component, with the date | |
1432 | set to 0. Hours are not restricted to 0..24 range, neither are | |
1433 | minutes, seconds or milliseconds. | |
1434 | */ | |
1435 | wxTimeSpan(); | |
7c913512 | 1436 | wxTimeSpan(long hours, long min, long sec, long msec); |
23324ae1 FM |
1437 | //@} |
1438 | ||
1439 | /** | |
1440 | Returns the absolute value of the timespan: does not modify the | |
1441 | object. | |
1442 | */ | |
328f5751 | 1443 | wxTimeSpan Abs() const; |
23324ae1 FM |
1444 | |
1445 | /** | |
1446 | GetSeconds() | |
3c4f71cc | 1447 | |
23324ae1 | 1448 | GetMinutes() |
3c4f71cc | 1449 | |
23324ae1 | 1450 | GetHours() |
3c4f71cc | 1451 | |
23324ae1 | 1452 | GetDays() |
3c4f71cc | 1453 | |
23324ae1 | 1454 | GetWeeks() |
3c4f71cc | 1455 | |
23324ae1 FM |
1456 | GetValue() |
1457 | */ | |
1458 | ||
1459 | ||
1460 | //@{ | |
1461 | /** | |
1462 | Returns the sum of two timespans. | |
1463 | */ | |
1464 | wxTimeSpan Add(const wxTimeSpan& diff); | |
328f5751 | 1465 | const wxTimeSpan& Add(const wxTimeSpan& diff); |
7c913512 | 1466 | wxTimeSpan operator+=(const wxTimeSpan& diff); |
23324ae1 FM |
1467 | //@} |
1468 | ||
1469 | /** | |
1470 | @ref ctor() wxTimeSpan | |
1471 | */ | |
1472 | ||
1473 | ||
1474 | /** | |
1475 | Returns the timespan for one day. | |
1476 | */ | |
4cc4bfaf | 1477 | static wxTimespan Day(); |
23324ae1 FM |
1478 | |
1479 | /** | |
1480 | Returns the timespan for the given number of days. | |
1481 | */ | |
1482 | static wxTimespan Days(long days); | |
1483 | ||
1484 | /** | |
1485 | Returns the string containing the formatted representation of the time span. | |
1486 | The following format specifiers are allowed after %: | |
3c4f71cc | 1487 | |
23324ae1 | 1488 | H |
3c4f71cc | 1489 | |
23324ae1 | 1490 | number of @b Hours |
3c4f71cc | 1491 | |
23324ae1 | 1492 | M |
3c4f71cc | 1493 | |
23324ae1 | 1494 | number of @b Minutes |
3c4f71cc | 1495 | |
23324ae1 | 1496 | S |
3c4f71cc | 1497 | |
23324ae1 | 1498 | number of @b Seconds |
3c4f71cc | 1499 | |
23324ae1 | 1500 | l |
3c4f71cc | 1501 | |
23324ae1 | 1502 | number of mi@b lliseconds |
3c4f71cc | 1503 | |
23324ae1 | 1504 | D |
3c4f71cc | 1505 | |
23324ae1 | 1506 | number of @b Days |
3c4f71cc | 1507 | |
23324ae1 | 1508 | E |
3c4f71cc | 1509 | |
23324ae1 | 1510 | number of w@b Eeks |
3c4f71cc | 1511 | |
23324ae1 | 1512 | % |
3c4f71cc | 1513 | |
23324ae1 | 1514 | the percent character |
3c4f71cc | 1515 | |
23324ae1 FM |
1516 | Note that, for example, the number of hours in the description above is not |
1517 | well defined: it can be either the total number of hours (for example, for a | |
1518 | time span of 50 hours this would be 50) or just the hour part of the time | |
1519 | span, which would be 2 in this case as 50 hours is equal to 2 days and | |
1520 | 2 hours. | |
23324ae1 FM |
1521 | wxTimeSpan resolves this ambiguity in the following way: if there had been, |
1522 | indeed, the @c %D format specified preceding the @c %H, then it is | |
1523 | interpreted as 2. Otherwise, it is 50. | |
23324ae1 FM |
1524 | The same applies to all other format specifiers: if they follow a specifier of |
1525 | larger unit, only the rest part is taken, otherwise the full value is used. | |
1526 | */ | |
1d497b99 | 1527 | wxString Format(const wxString& = wxDefaultTimeSpanFormat) const; |
23324ae1 FM |
1528 | |
1529 | /** | |
1530 | Format() | |
1531 | */ | |
1532 | ||
1533 | ||
1534 | /** | |
1535 | Returns the difference in number of days. | |
1536 | */ | |
328f5751 | 1537 | int GetDays() const; |
23324ae1 FM |
1538 | |
1539 | /** | |
1540 | Returns the difference in number of hours. | |
1541 | */ | |
328f5751 | 1542 | int GetHours() const; |
23324ae1 FM |
1543 | |
1544 | /** | |
1545 | Returns the difference in number of milliseconds. | |
1546 | */ | |
328f5751 | 1547 | wxLongLong GetMilliseconds() const; |
23324ae1 FM |
1548 | |
1549 | /** | |
1550 | Returns the difference in number of minutes. | |
1551 | */ | |
328f5751 | 1552 | int GetMinutes() const; |
23324ae1 FM |
1553 | |
1554 | /** | |
1555 | Returns the difference in number of seconds. | |
1556 | */ | |
328f5751 | 1557 | wxLongLong GetSeconds() const; |
23324ae1 FM |
1558 | |
1559 | /** | |
1560 | Returns the internal representation of timespan. | |
1561 | */ | |
328f5751 | 1562 | wxLongLong GetValue() const; |
23324ae1 FM |
1563 | |
1564 | /** | |
1565 | Returns the difference in number of weeks. | |
1566 | */ | |
328f5751 | 1567 | int GetWeeks() const; |
23324ae1 FM |
1568 | |
1569 | /** | |
1570 | Returns the timespan for one hour. | |
1571 | */ | |
1572 | static wxTimespan Hour(); | |
1573 | ||
1574 | /** | |
1575 | Returns the timespan for the given number of hours. | |
1576 | */ | |
1577 | static wxTimespan Hours(long hours); | |
1578 | ||
1579 | /** | |
1580 | Returns @true if two timespans are equal. | |
1581 | */ | |
328f5751 | 1582 | bool IsEqualTo(const wxTimeSpan& ts) const; |
23324ae1 FM |
1583 | |
1584 | /** | |
1585 | Compares two timespans: works with the absolute values, i.e. -2 | |
1586 | hours is longer than 1 hour. Also, it will return @false if | |
1587 | the timespans are equal in absolute value. | |
1588 | */ | |
328f5751 | 1589 | bool IsLongerThan(const wxTimeSpan& ts) const; |
23324ae1 FM |
1590 | |
1591 | /** | |
1592 | Returns @true if the timespan is negative. | |
1593 | */ | |
328f5751 | 1594 | bool IsNegative() const; |
23324ae1 FM |
1595 | |
1596 | /** | |
1597 | Returns @true if the timespan is empty. | |
1598 | */ | |
328f5751 | 1599 | bool IsNull() const; |
23324ae1 FM |
1600 | |
1601 | /** | |
1602 | Returns @true if the timespan is positive. | |
1603 | */ | |
328f5751 | 1604 | bool IsPositive() const; |
23324ae1 FM |
1605 | |
1606 | /** | |
1607 | Compares two timespans: works with the absolute values, i.e. 1 | |
1608 | hour is shorter than -2 hours. Also, it will return @false if | |
1609 | the timespans are equal in absolute value. | |
1610 | */ | |
328f5751 | 1611 | bool IsShorterThan(const wxTimeSpan& ts) const; |
23324ae1 FM |
1612 | |
1613 | /** | |
1614 | Returns the timespan for one millisecond. | |
1615 | */ | |
1616 | static wxTimespan Millisecond(); | |
1617 | ||
1618 | /** | |
1619 | Returns the timespan for the given number of milliseconds. | |
1620 | */ | |
1621 | static wxTimespan Milliseconds(long ms); | |
1622 | ||
1623 | /** | |
1624 | Returns the timespan for one minute. | |
1625 | */ | |
1626 | static wxTimespan Minute(); | |
1627 | ||
1628 | /** | |
1629 | Returns the timespan for the given number of minutes. | |
1630 | */ | |
1631 | static wxTimespan Minutes(long min); | |
1632 | ||
1633 | //@{ | |
1634 | /** | |
1635 | Multiplies timespan by a scalar. | |
1636 | */ | |
1637 | wxTimeSpan Multiply(int n); | |
328f5751 | 1638 | const wxTimeSpan& Multiply(int n); |
7c913512 | 1639 | wxTimeSpan operator*=(int n); |
23324ae1 FM |
1640 | //@} |
1641 | ||
1642 | //@{ | |
1643 | /** | |
1644 | Negate the value of the timespan. | |
1645 | */ | |
1646 | wxTimeSpan Neg(); | |
7c913512 | 1647 | wxTimeSpan operator-(); |
23324ae1 FM |
1648 | //@} |
1649 | ||
1650 | /** | |
1651 | Returns timespan with inverted sign. | |
1652 | */ | |
328f5751 | 1653 | wxTimeSpan Negate() const; |
23324ae1 FM |
1654 | |
1655 | /** | |
1656 | Add() | |
3c4f71cc | 1657 | |
23324ae1 | 1658 | Subtract() |
3c4f71cc | 1659 | |
23324ae1 | 1660 | Multiply() |
3c4f71cc | 1661 | |
23324ae1 | 1662 | Negate() |
3c4f71cc | 1663 | |
23324ae1 | 1664 | Neg() |
3c4f71cc | 1665 | |
23324ae1 FM |
1666 | Abs() |
1667 | */ | |
1668 | ||
1669 | ||
1670 | /** | |
1671 | Returns the timespan for one second. | |
1672 | */ | |
1673 | static wxTimespan Second(); | |
1674 | ||
1675 | /** | |
1676 | Returns the timespan for the given number of seconds. | |
1677 | */ | |
1678 | static wxTimespan Seconds(long sec); | |
1679 | ||
1680 | /** | |
1681 | Milliseconds() | |
3c4f71cc | 1682 | |
23324ae1 | 1683 | Millisecond() |
3c4f71cc | 1684 | |
23324ae1 | 1685 | Seconds() |
3c4f71cc | 1686 | |
23324ae1 | 1687 | Second() |
3c4f71cc | 1688 | |
23324ae1 | 1689 | Minutes() |
3c4f71cc | 1690 | |
23324ae1 | 1691 | Minute() |
3c4f71cc | 1692 | |
23324ae1 | 1693 | Hours() |
3c4f71cc | 1694 | |
23324ae1 | 1695 | Hour() |
3c4f71cc | 1696 | |
23324ae1 | 1697 | Days() |
3c4f71cc | 1698 | |
23324ae1 | 1699 | Day() |
3c4f71cc | 1700 | |
23324ae1 | 1701 | Weeks() |
3c4f71cc | 1702 | |
23324ae1 FM |
1703 | Week() |
1704 | */ | |
1705 | ||
1706 | ||
1707 | //@{ | |
1708 | /** | |
1709 | Returns the difference of two timespans. | |
1710 | */ | |
1711 | wxTimeSpan Subtract(const wxTimeSpan& diff); | |
328f5751 | 1712 | const wxTimeSpan& Subtract(const wxTimeSpan& diff); |
7c913512 | 1713 | wxTimeSpan operator-=(const wxTimeSpan& diff); |
23324ae1 FM |
1714 | //@} |
1715 | ||
1716 | /** | |
1717 | IsNull() | |
3c4f71cc | 1718 | |
23324ae1 | 1719 | IsPositive() |
3c4f71cc | 1720 | |
23324ae1 | 1721 | IsNegative() |
3c4f71cc | 1722 | |
23324ae1 | 1723 | IsEqualTo() |
3c4f71cc | 1724 | |
23324ae1 | 1725 | IsLongerThan() |
3c4f71cc | 1726 | |
23324ae1 FM |
1727 | IsShorterThan() |
1728 | */ | |
1729 | ||
1730 | ||
1731 | /** | |
1732 | Returns the timespan for one week. | |
1733 | */ | |
1734 | static wxTimespan Week(); | |
1735 | ||
1736 | /** | |
1737 | Returns the timespan for the given number of weeks. | |
1738 | */ | |
1739 | static wxTimespan Weeks(long weeks); | |
1740 | }; | |
1741 | ||
1742 | ||
e54c96f1 | 1743 | |
23324ae1 FM |
1744 | /** |
1745 | @class wxDateTimeHolidayAuthority | |
1746 | @wxheader{datetime.h} | |
7c913512 FM |
1747 | |
1748 | ||
23324ae1 FM |
1749 | @library{wxbase} |
1750 | @category{FIXME} | |
1751 | */ | |
7c913512 | 1752 | class wxDateTimeHolidayAuthority |
23324ae1 FM |
1753 | { |
1754 | public: | |
7c913512 | 1755 | |
23324ae1 | 1756 | }; |
e54c96f1 | 1757 |