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