1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions of various utility classes
7 // Created: 25-nov-1998
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
18 #include <wx/config.h>
19 #include <wx/fileconf.h>
20 #include <wx/datetime.h>
23 //---------------------------------------------------------------------------
26 %include my_typemaps.i
28 %pragma(python) code = "import string"
31 //---------------------------------------------------------------------------
34 static PyObject* __EnumerationHelper(bool flag, wxString& str, long index) {
35 PyObject* ret = PyTuple_New(3);
37 PyTuple_SET_ITEM(ret, 0, PyInt_FromLong(flag));
38 PyTuple_SET_ITEM(ret, 1, PyString_FromString(str));
39 PyTuple_SET_ITEM(ret, 2, PyInt_FromLong(index));
45 //---------------------------------------------------------------------------
49 wxCONFIG_USE_LOCAL_FILE = 1,
50 wxCONFIG_USE_GLOBAL_FILE = 2,
51 wxCONFIG_USE_RELATIVE_PATH = 4
54 //---------------------------------------------------------------------------
58 // wxConfigBase(const wxString& appName = wxPyEmptyStr, **** An ABC
59 // const wxString& vendorName = wxPyEmptyStr,
60 // const wxString& localFilename = wxPyEmptyStr,
61 // const wxString& globalFilename = wxPyEmptyStr,
70 Type_Integer, // use Read(long *)
71 Type_Float // use Read(double *)
75 // sets the config object, returns the previous pointer
76 static wxConfigBase *Set(wxConfigBase *pConfig);
77 // get the config object, creates it on demand unless DontCreateOnDemand
79 static wxConfigBase *Get(bool createOnDemand = TRUE);
80 // create a new config object: this function will create the "best"
81 // implementation of wxConfig available for the current platform, see
82 // comments near definition wxUSE_CONFIG_NATIVE for details. It returns
83 // the created object and also sets it as ms_pConfig.
84 static wxConfigBase *Create();
85 // should Get() try to create a new log object if the current one is NULL?
86 static void DontCreateOnDemand();
90 bool DeleteAll(); // This is supposed to have been fixed...
91 bool DeleteEntry(const wxString& key, bool bDeleteGroupIfEmpty = TRUE);
92 bool DeleteGroup(const wxString& key);
93 bool Exists(wxString& strName);
94 bool Flush(bool bCurrentOnly = FALSE);
95 wxString GetAppName();
98 // Each of these enumeration methods return a 3-tuple consisting of
99 // the continue flag, the value string, and the index for the next call.
101 PyObject* GetFirstGroup() {
106 cont = self->GetFirstGroup(value, index);
107 return __EnumerationHelper(cont, value, index);
110 PyObject* GetFirstEntry() {
115 cont = self->GetFirstEntry(value, index);
116 return __EnumerationHelper(cont, value, index);
119 PyObject* GetNextGroup(long index) {
123 cont = self->GetNextGroup(value, index);
124 return __EnumerationHelper(cont, value, index);
127 PyObject* GetNextEntry(long index) {
131 cont = self->GetNextEntry(value, index);
132 return __EnumerationHelper(cont, value, index);
137 int GetNumberOfEntries(bool bRecursive = FALSE);
138 int GetNumberOfGroups(bool bRecursive = FALSE);
140 wxString GetVendorName();
141 bool HasEntry(wxString& strName);
142 bool HasGroup(const wxString& strName);
143 bool IsExpandingEnvVars();
144 bool IsRecordingDefaults();
146 wxString Read(const wxString& key, const wxString& defaultVal = wxPyEmptyStr);
147 %name(ReadInt)long Read(const wxString& key, long defaultVal = 0);
148 %name(ReadFloat)double Read(const wxString& key, double defaultVal = 0.0);
150 void SetExpandEnvVars (bool bDoIt = TRUE);
151 void SetPath(const wxString& strPath);
152 void SetRecordDefaults(bool bDoIt = TRUE);
153 void SetAppName(const wxString& appName);
154 void SetVendorName(const wxString& vendorName);
156 void SetStyle(long style);
159 bool Write(const wxString& key, const wxString& value);
160 %name(WriteInt)bool Write(const wxString& key, long value);
161 %name(WriteFloat)bool Write(const wxString& key, double value);
163 EntryType GetEntryType(const wxString& name);
164 bool RenameEntry(const wxString& oldName,
165 const wxString& newName);
166 bool RenameGroup(const wxString& oldName,
167 const wxString& newName);
168 wxString ExpandEnvVars(const wxString& str);
173 //---------------------------------------------------------------------------
175 class wxConfig : public wxConfigBase {
177 wxConfig(const wxString& appName = wxPyEmptyStr,
178 const wxString& vendorName = wxPyEmptyStr,
179 const wxString& localFilename = wxPyEmptyStr,
180 const wxString& globalFilename = wxPyEmptyStr,
185 class wxFileConfig : public wxConfigBase {
187 wxFileConfig(const wxString& appName = wxPyEmptyStr,
188 const wxString& vendorName = wxPyEmptyStr,
189 const wxString& localFilename = wxPyEmptyStr,
190 const wxString& globalFilename = wxPyEmptyStr,
196 //---------------------------------------------------------------------------
197 //---------------------------------------------------------------------------
204 %typemap(python,in) wxDateTime::TimeZone& {
205 $target = new wxDateTime::TimeZone((wxDateTime::TZ)PyInt_AsLong($source));
207 %typemap(python,freearg) wxDateTime::TimeZone& {
208 if ($source) delete $source;
212 #define LOCAL *(new wxDateTime::TimeZone(wxDateTime::Local))
216 %typemap(python, out) wxLongLong {
217 PyObject *hi, *lo, *shifter, *shifted;
218 hi = PyLong_FromLong($source->GetHi());
219 lo = PyLong_FromLong($source->GetLo());
220 shifter = PyLong_FromLong(32);
221 shifted = PyNumber_Lshift(hi, shifter);
222 $target = PyNumber_Or(shifted, lo);
234 typedef unsigned short wxDateTime_t;
240 GMT_12, GMT_11, GMT_10, GMT_9, GMT_8, GMT_7,
241 GMT_6, GMT_5, GMT_4, GMT_3, GMT_2, GMT_1,
243 GMT1, GMT2, GMT3, GMT4, GMT5, GMT6,
244 GMT7, GMT8, GMT9, GMT10, GMT11, GMT12,
247 WET = GMT0, // Western Europe Time
248 WEST = GMT1, // Western Europe Summer Time
249 CET = GMT1, // Central Europe Time
250 CEST = GMT2, // Central Europe Summer Time
251 EET = GMT2, // Eastern Europe Time
252 EEST = GMT3, // Eastern Europe Summer Time
253 MSK = GMT3, // Moscow Time
254 MSD = GMT4, // Moscow Summer Time
257 AST = GMT_4, // Atlantic Standard Time
258 ADT = GMT_3, // Atlantic Daylight Time
259 EST = GMT_5, // Eastern Standard Time
260 EDT = GMT_4, // Eastern Daylight Saving Time
261 CST = GMT_6, // Central Standard Time
262 CDT = GMT_5, // Central Daylight Saving Time
263 MST = GMT_7, // Mountain Standard Time
264 MDT = GMT_6, // Mountain Daylight Saving Time
265 PST = GMT_8, // Pacific Standard Time
266 PDT = GMT_7, // Pacific Daylight Saving Time
267 HST = GMT_10, // Hawaiian Standard Time
268 AKST = GMT_9, // Alaska Standard Time
269 AKDT = GMT_8, // Alaska Daylight Saving Time
273 A_WST = GMT8, // Western Standard Time
274 A_CST = GMT12 + 1, // Central Standard Time (+9.5)
275 A_EST = GMT10, // Eastern Standard Time
276 A_ESST = GMT11, // Eastern Summer Time
278 // Universal Coordinated Time = the new and politically correct name
285 Gregorian, // current calendar
286 Julian // calendar in use since -45 until the 1582 (or later)
291 Country_Unknown, // no special information for this country
292 Country_Default, // set the default country with SetCountry() method
293 // or use the default country with any other
295 // Western European countries: we assume that they all follow the same
296 // DST rules (true or false?)
297 Country_WesternEurope_Start,
298 Country_EEC = Country_WesternEurope_Start,
302 Country_WesternEurope_End = UK,
309 // symbolic names for the months
312 Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, Inv_Month
315 // symbolic names for the weekdays
318 Sun, Mon, Tue, Wed, Thu, Fri, Sat, Inv_WeekDay
321 // invalid value for the year
324 Inv_Year = SHRT_MIN // should hold in wxDateTime_t
327 // flags for GetWeekDayName and GetMonthName
330 Name_Full = 0x01, // return full name
331 Name_Abbr = 0x02 // return abbreviated name
334 // flags for GetWeekOfYear and GetWeekOfMonth
337 Default_First, // Sunday_First for US, Monday_First for the rest
338 Monday_First, // week starts with a Monday
339 Sunday_First // week starts with a Sunday
344 // ------------------------------------------------------------------------
346 // set the current country
347 static void SetCountry(Country country);
348 // get the current country
349 static Country GetCountry();
351 // return TRUE if the country is a West European one (in practice,
352 // this means that the same DST rules as for EEC apply)
353 static bool IsWestEuropeanCountry(Country country = Country_Default);
355 // return the current year
356 static int GetCurrentYear(Calendar cal = Gregorian);
358 // convert the year as returned by wxDateTime::GetYear() to a year
359 // suitable for BC/AD notation. The difference is that BC year 1
360 // corresponds to the year 0 (while BC year 0 didn't exist) and AD
361 // year N is just year N.
362 static int ConvertYearToBC(int year);
364 // return the current month
365 static Month GetCurrentMonth(Calendar cal = Gregorian);
367 // returns TRUE if the given year is a leap year in the given calendar
368 static bool IsLeapYear(int year = Inv_Year, Calendar cal = Gregorian);
370 // get the century (19 for 1999, 20 for 2000 and -5 for 492 BC)
371 static int GetCentury(int year = Inv_Year);
373 // returns the number of days in this year (356 or 355 for Gregorian
374 // calendar usually :-)
375 %name(GetNumberOfDaysinYear)
376 static wxDateTime_t GetNumberOfDays(int year, Calendar cal = Gregorian);
378 // get the number of the days in the given month (default value for
379 // the year means the current one)
380 %name(GetNumberOfDaysInMonth)
381 static wxDateTime_t GetNumberOfDays(Month month,
383 Calendar cal = Gregorian);
385 // get the full (default) or abbreviated month name in the current
386 // locale, returns empty string on error
387 static wxString GetMonthName(Month month,
388 NameFlags flags = Name_Full);
390 // get the full (default) or abbreviated weekday name in the current
391 // locale, returns empty string on error
392 static wxString GetWeekDayName(WeekDay weekday,
393 NameFlags flags = Name_Full);
395 // get the AM and PM strings in the current locale (may be empty)
396 static void GetAmPmStrings(wxString *OUTPUT, wxString *OUTPUT);
398 // return TRUE if the given country uses DST for this year
399 static bool IsDSTApplicable(int year = Inv_Year,
400 Country country = Country_Default);
402 // get the beginning of DST for this year, will return invalid object
403 // if no DST applicable in this year. The default value of the
404 // parameter means to take the current year.
405 static wxDateTime GetBeginDST(int year = Inv_Year,
406 Country country = Country_Default);
407 // get the end of DST for this year, will return invalid object
408 // if no DST applicable in this year. The default value of the
409 // parameter means to take the current year.
410 static wxDateTime GetEndDST(int year = Inv_Year,
411 Country country = Country_Default);
413 // return the wxDateTime object for the current time
414 static inline wxDateTime Now();
416 // return the wxDateTime object for today midnight: i.e. as Now() but
417 // with time set to 0
418 static inline wxDateTime Today();
422 // ------------------------------------------------------------------------
426 %name(wxDateTimeFromTimeT)wxDateTime(time_t timet);
427 %name(wxDateTimeFromJDN)wxDateTime(double jdn);
428 %name(wxDateTimeFromHMS)wxDateTime(wxDateTime_t hour,
429 wxDateTime_t minute = 0,
430 wxDateTime_t second = 0,
431 wxDateTime_t millisec = 0);
432 %name(wxDateTimeFromDMY)wxDateTime(wxDateTime_t day,
433 Month month = Inv_Month,
435 wxDateTime_t hour = 0,
436 wxDateTime_t minute = 0,
437 wxDateTime_t second = 0,
438 wxDateTime_t millisec = 0);
442 // ------------------------------------------------------------------------
445 wxDateTime& SetToCurrent();
447 // set to given time_t value
448 %name(SetTimeT)wxDateTime& Set(time_t timet);
450 // set to given JDN (beware of rounding errors)
451 %name(SetJDN)wxDateTime& Set(double jdn);
453 // set to given time, date = today
454 %name(SetHMS)wxDateTime& Set(wxDateTime_t hour,
455 wxDateTime_t minute = 0,
456 wxDateTime_t second = 0,
457 wxDateTime_t millisec = 0);
459 // from separate values for each component with explicit date
460 // (defaults for month and year are the current values)
461 wxDateTime& Set(wxDateTime_t day,
462 Month month = Inv_Month,
463 int year = Inv_Year, // 1999, not 99 please!
464 wxDateTime_t hour = 0,
465 wxDateTime_t minute = 0,
466 wxDateTime_t second = 0,
467 wxDateTime_t millisec = 0);
469 // resets time to 00:00:00, doesn't change the date
470 wxDateTime& ResetTime();
472 // the following functions don't change the values of the other
473 // fields, i.e. SetMinute() won't change either hour or seconds value
476 wxDateTime& SetYear(int year);
478 wxDateTime& SetMonth(Month month);
479 // set the day of the month
480 wxDateTime& SetDay(wxDateTime_t day);
482 wxDateTime& SetHour(wxDateTime_t hour);
484 wxDateTime& SetMinute(wxDateTime_t minute);
486 wxDateTime& SetSecond(wxDateTime_t second);
488 wxDateTime& SetMillisecond(wxDateTime_t millisecond);
491 // ------------------------------------------------------------------------
492 // calendar calculations
494 // set to the given week day in the same week as this one
495 wxDateTime& SetToWeekDayInSameWeek(WeekDay weekday);
496 wxDateTime GetWeekDayInSameWeek(WeekDay weekday);
498 // set to the next week day following this one
499 wxDateTime& SetToNextWeekDay(WeekDay weekday);
500 wxDateTime GetNextWeekDay(WeekDay weekday);
502 // set to the previous week day before this one
503 wxDateTime& SetToPrevWeekDay(WeekDay weekday);
504 wxDateTime GetPrevWeekDay(WeekDay weekday);
506 // set to Nth occurence of given weekday in the given month of the
507 // given year (time is set to 0), return TRUE on success and FALSE on
508 // failure. n may be positive (1..5) or negative to count from the end
509 // of the month (see helper function SetToLastWeekDay())
510 bool SetToWeekDay(WeekDay weekday,
512 Month month = Inv_Month,
513 int year = Inv_Year);
514 wxDateTime GetWeekDay(WeekDay weekday,
516 Month month = Inv_Month,
517 int year = Inv_Year);
519 // sets to the last weekday in the given month, year
520 bool SetToLastWeekDay(WeekDay weekday,
521 Month month = Inv_Month,
522 int year = Inv_Year);
523 wxDateTime GetLastWeekDay(WeekDay weekday,
524 Month month = Inv_Month,
525 int year = Inv_Year);
527 // sets the date to the given day of the given week in the year,
528 // returns TRUE on success and FALSE if given date doesn't exist (e.g.
530 bool SetToTheWeek(wxDateTime_t numWeek, WeekDay weekday = Mon);
531 wxDateTime GetWeek(wxDateTime_t numWeek, WeekDay weekday = Mon);
533 // sets the date to the last day of the given (or current) month or the
534 // given (or current) year
535 wxDateTime& SetToLastMonthDay(Month month = Inv_Month,
536 int year = Inv_Year);
537 wxDateTime GetLastMonthDay(Month month = Inv_Month,
538 int year = Inv_Year);
540 // sets to the given year day (1..365 or 366)
541 wxDateTime& SetToYearDay(wxDateTime_t yday);
542 wxDateTime GetYearDay(wxDateTime_t yday);
544 // The definitions below were taken verbatim from
546 // http://www.capecod.net/~pbaum/date/date0.htm
548 // (Peter Baum's home page)
550 // definition: The Julian Day Number, Julian Day, or JD of a
551 // particular instant of time is the number of days and fractions of a
552 // day since 12 hours Universal Time (Greenwich mean noon) on January
553 // 1 of the year -4712, where the year is given in the Julian
554 // proleptic calendar. The idea of using this reference date was
555 // originally proposed by Joseph Scalizer in 1582 to count years but
556 // it was modified by 19th century astronomers to count days. One
557 // could have equivalently defined the reference time to be noon of
558 // November 24, -4713 if were understood that Gregorian calendar rules
559 // were applied. Julian days are Julian Day Numbers and are not to be
560 // confused with Julian dates.
562 // definition: The Rata Die number is a date specified as the number
563 // of days relative to a base date of December 31 of the year 0. Thus
564 // January 1 of the year 1 is Rata Die day 1.
566 // get the Julian Day number (the fractional part specifies the time of
567 // the day, related to noon - beware of rounding errors!)
568 double GetJulianDayNumber();
571 // get the Modified Julian Day number: it is equal to JDN - 2400000.5
572 // and so integral MJDs correspond to the midnights (and not noons).
573 // MJD 0 is Nov 17, 1858
574 double GetModifiedJulianDayNumber() const { return GetJDN() - 2400000.5; }
577 // get the Rata Die number
581 // ------------------------------------------------------------------------
584 // transform to any given timezone
585 wxDateTime ToTimezone(const wxDateTime::TimeZone& tz, bool noDST = FALSE);
586 wxDateTime& MakeTimezone(const wxDateTime::TimeZone& tz, bool noDST = FALSE);
588 // transform to GMT/UTC
589 wxDateTime ToGMT(bool noDST = FALSE);
590 wxDateTime& MakeGMT(bool noDST = FALSE);
592 // is daylight savings time in effect at this moment according to the
593 // rules of the specified country?
595 // Return value is > 0 if DST is in effect, 0 if it is not and -1 if
596 // the information is not available (this is compatible with ANSI C)
597 int IsDST(Country country = Country_Default);
601 // ------------------------------------------------------------------------
604 // is the date valid (TRUE even for non initialized objects)?
605 inline bool IsValid() const;
607 // get the number of seconds since the Unix epoch - returns (time_t)-1
608 // if the value is out of range
609 inline time_t GetTicks() const;
611 // get the year (returns Inv_Year if date is invalid)
612 int GetYear(const wxDateTime::TimeZone& tz = LOCAL) const;
614 // get the month (Inv_Month if date is invalid)
615 Month GetMonth(const wxDateTime::TimeZone& tz = LOCAL) const;
617 // get the month day (in 1..31 range, 0 if date is invalid)
618 wxDateTime_t GetDay(const wxDateTime::TimeZone& tz = LOCAL) const;
620 // get the day of the week (Inv_WeekDay if date is invalid)
621 WeekDay GetWeekDay(const wxDateTime::TimeZone& tz = LOCAL) const;
623 // get the hour of the day
624 wxDateTime_t GetHour(const wxDateTime::TimeZone& tz = LOCAL) const;
627 wxDateTime_t GetMinute(const wxDateTime::TimeZone& tz = LOCAL) const;
630 wxDateTime_t GetSecond(const wxDateTime::TimeZone& tz = LOCAL) const;
633 wxDateTime_t GetMillisecond(const wxDateTime::TimeZone& tz = LOCAL) const;
636 // get the day since the year start (1..366, 0 if date is invalid)
637 wxDateTime_t GetDayOfYear(const wxDateTime::TimeZone& tz = LOCAL) const;
638 // get the week number since the year start (1..52 or 53, 0 if date is
640 wxDateTime_t GetWeekOfYear(WeekFlags flags = Monday_First,
641 const wxDateTime::TimeZone& tz = LOCAL) const;
642 // get the week number since the month start (1..5, 0 if date is
644 wxDateTime_t GetWeekOfMonth(WeekFlags flags = Monday_First,
645 const wxDateTime::TimeZone& tz = LOCAL) const;
647 // is this date a work day? This depends on a country, of course,
648 // because the holidays are different in different countries
649 bool IsWorkDay(Country country = Country_Default) const;
651 // is this date later than Gregorian calendar introduction for the
652 // given country (see enum GregorianAdoption)?
654 // NB: this function shouldn't be considered as absolute authority in
655 // the matter. Besides, for some countries the exact date of
656 // adoption of the Gregorian calendar is simply unknown.
657 //bool IsGregorianDate(GregorianAdoption country = Gr_Standard) const;
660 // ------------------------------------------------------------------------
661 // comparison (see also functions below for operator versions)
663 // returns TRUE if the two moments are strictly identical
664 inline bool IsEqualTo(const wxDateTime& datetime) const;
666 // returns TRUE if the date is strictly earlier than the given one
667 inline bool IsEarlierThan(const wxDateTime& datetime) const;
669 // returns TRUE if the date is strictly later than the given one
670 inline bool IsLaterThan(const wxDateTime& datetime) const;
672 // returns TRUE if the date is strictly in the given range
673 inline bool IsStrictlyBetween(const wxDateTime& t1,
674 const wxDateTime& t2) const;
676 // returns TRUE if the date is in the given range
677 inline bool IsBetween(const wxDateTime& t1, const wxDateTime& t2) const;
679 // do these two objects refer to the same date?
680 inline bool IsSameDate(const wxDateTime& dt) const;
682 // do these two objects have the same time?
683 inline bool IsSameTime(const wxDateTime& dt) const;
685 // are these two objects equal up to given timespan?
686 inline bool IsEqualUpTo(const wxDateTime& dt, const wxTimeSpan& ts) const;
689 // ------------------------------------------------------------------------
690 // arithmetics with dates (see also below for more operators)
692 // add a time span (positive or negative)
693 %name(AddTS) wxDateTime& Add(const wxTimeSpan& diff);
694 // add a date span (positive or negative)
695 %name(AddDS) wxDateTime& Add(const wxDateSpan& diff);
697 // subtract a time span (positive or negative)
698 %name(SubtractTS) wxDateTime& Subtract(const wxTimeSpan& diff);
700 // subtract a date span (positive or negative)
701 %name(SubtractDS) wxDateTime& Subtract(const wxDateSpan& diff);
703 // return the difference between two dates
704 wxTimeSpan Subtract(const wxDateTime& dt) const;
708 wxDateTime __add__TS(const wxTimeSpan& other) { return *self + other; }
709 wxDateTime __add__DS(const wxDateSpan& other) { return *self + other; }
711 wxTimeSpan __sub__DT(const wxDateTime& other) { return *self - other; }
712 wxDateTime __sub__TS(const wxTimeSpan& other) { return *self - other; }
713 wxDateTime __sub__DS(const wxDateSpan& other) { return *self - other; }
715 int __cmp__(const wxDateTime& other) {
716 if (*self < other) return -1;
717 if (*self == other) return 0;
722 %pragma(python) addtoclass = "
723 def __add__(self, other):
724 if string.find(other.this, 'wxTimeSpan') != -1:
725 return self.__add__TS(other)
726 if string.find(other.this, 'wxDateSpan') != -1:
727 return self.__add__DS(other)
728 raise TypeError, 'Invalid r.h.s. type for __add__'
729 def __sub__(self, other):
730 if string.find(other.this, 'wxDateTime') != -1:
731 return self.__sub__DT(other)
732 if string.find(other.this, 'wxTimeSpan') != -1:
733 return self.__sub__TS(other)
734 if string.find(other.this, 'wxDateSpan') != -1:
735 return self.__sub__DS(other)
736 raise TypeError, 'Invalid r.h.s. type for __sub__'
739 // ------------------------------------------------------------------------
740 // conversion to/from text: all conversions from text return the pointer to
741 // the next character following the date specification (i.e. the one where
742 // the scan had to stop) or NULL on failure.
744 // parse a string in RFC 822 format (found e.g. in mail headers and
745 // having the form "Wed, 10 Feb 1999 19:07:07 +0100")
746 const char *ParseRfc822Date(const char* date);
748 // parse a date/time in the given format (see strptime(3)), fill in
749 // the missing (in the string) fields with the values of dateDef (by
750 // default, they will not change if they had valid values or will
751 // default to Today() otherwise)
752 const char *ParseFormat(const char *date,
753 const char *format = "%c",
754 const wxDateTime& dateDef = wxDefaultDateTime);
756 // parse a string containing the date/time in "free" format, this
757 // function will try to make an educated guess at the string contents
758 const char *ParseDateTime(const char *datetime);
760 // parse a string containing the date only in "free" format (less
761 // flexible than ParseDateTime)
762 const char *ParseDate(const char *date);
764 // parse a string containing the time only in "free" format
765 const char *ParseTime(const char *time);
767 // this function accepts strftime()-like format string (default
768 // argument corresponds to the preferred date and time representation
769 // for the current locale) and returns the string containing the
770 // resulting text representation
771 wxString Format(const char *format = "%c",
772 const wxDateTime::TimeZone& tz = LOCAL) const;
774 // preferred date representation for the current locale
775 wxString FormatDate() const;
777 // preferred time representation for the current locale
778 wxString FormatTime() const;
780 // returns the string representing the date in ISO 8601 format
782 wxString FormatISODate() const;
784 // returns the string representing the time in ISO 8601 format
786 wxString FormatISOTime() const;
788 %pragma(python) addtoclass = "
790 return '<wxDateTime: \"%s\" at %s>' % ( self.Format(), self.this)
797 //---------------------------------------------------------------------------
798 //---------------------------------------------------------------------------
804 // return the timespan for the given number of seconds
805 static wxTimeSpan Seconds(long sec);
806 static wxTimeSpan Second();
808 // return the timespan for the given number of minutes
809 static wxTimeSpan Minutes(long min);
810 static wxTimeSpan Minute();
812 // return the timespan for the given number of hours
813 static wxTimeSpan Hours(long hours);
814 static wxTimeSpan Hour();
816 // return the timespan for the given number of days
817 static wxTimeSpan Days(long days);
818 static wxTimeSpan Day();
820 // return the timespan for the given number of weeks
821 static wxTimeSpan Weeks(long days);
822 static wxTimeSpan Week();
824 // ------------------------------------------------------------------------
827 // from separate values for each component, date set to 0 (hours are
828 // not restricted to 0..24 range, neither are minutes, seconds or
830 wxTimeSpan(long hours = 0,
833 long milliseconds = 0);
837 // ------------------------------------------------------------------------
838 // arithmetics with time spans
840 // add two timespans together
841 inline wxTimeSpan& Add(const wxTimeSpan& diff);
843 // subtract another timespan
844 inline wxTimeSpan& Subtract(const wxTimeSpan& diff);
846 // multiply timespan by a scalar
847 inline wxTimeSpan& Multiply(int n);
849 // negate the value of the timespan
852 // return the absolute value of the timespan: does _not_ modify the
854 inline wxTimeSpan Abs() const;
857 wxTimeSpan __add__(const wxTimeSpan& other) { return *self + other; }
858 wxTimeSpan __sub__(const wxTimeSpan& other) { return *self - other; }
859 wxTimeSpan __mul__(int n) { return *self * n; }
860 wxTimeSpan __rmul__(int n) { return n * *self; }
861 wxTimeSpan __neg__() { return self->Negate(); }
862 int __cmp__(const wxTimeSpan& other) {
863 if (*self < other) return -1;
864 if (*self == other) return 0;
869 // comparaison (see also operator versions below)
870 // ------------------------------------------------------------------------
872 // is the timespan null?
875 // is the timespan positive?
876 bool IsPositive() const;
878 // is the timespan negative?
879 bool IsNegative() const;
881 // are two timespans equal?
882 inline bool IsEqualTo(const wxTimeSpan& ts) const;
884 // compare two timestamps: works with the absolute values, i.e. -2
885 // hours is longer than 1 hour. Also, it will return FALSE if the
886 // timespans are equal in absolute value.
887 inline bool IsLongerThan(const wxTimeSpan& ts) const;
889 // compare two timestamps: works with the absolute values, i.e. 1
890 // hour is shorter than -2 hours. Also, it will return FALSE if the
891 // timespans are equal in absolute value.
892 bool IsShorterThan(const wxTimeSpan& t) const;
894 // ------------------------------------------------------------------------
895 // breaking into days, hours, minutes and seconds
897 // get the max number of weeks in this timespan
898 inline int GetWeeks() const;
899 // get the max number of days in this timespan
900 inline int GetDays() const;
901 // get the max number of hours in this timespan
902 inline int GetHours() const;
903 // get the max number of minutes in this timespan
904 inline int GetMinutes() const;
907 // get the max number of seconds in this timespan
908 inline wxLongLong GetSeconds() const;
909 // get the number of milliseconds in this timespan
910 wxLongLong GetMilliseconds() const;
912 // ------------------------------------------------------------------------
913 // conversion to text
915 // this function accepts strftime()-like format string (default
916 // argument corresponds to the preferred date and time representation
917 // for the current locale) and returns the string containing the
918 // resulting text representation. Notice that only some of format
919 // specifiers valid for wxDateTime are valid for wxTimeSpan: hours,
920 // minutes and seconds make sense, but not "PM/AM" string for example.
921 wxString Format(const char *format = "%c") const;
923 // // preferred date representation for the current locale
924 // wxString FormatDate() const;
926 // // preferred time representation for the current locale
927 // wxString FormatTime() const;
929 // %pragma(python) addtoclass = "
930 // def __repr__(self):
931 // return '<wxTimeSpan: \"%s\" at %s>' % ( self.Format(), self.this)
932 // def __str__(self):
933 // return self.Format()
938 //---------------------------------------------------------------------------
939 //---------------------------------------------------------------------------
944 // this many years/months/weeks/days
945 wxDateSpan(int years = 0, int months = 0, int weeks = 0, int days = 0)
955 // get an object for the given number of days
956 static wxDateSpan Days(int days);
957 static wxDateSpan Day();
959 // get an object for the given number of weeks
960 static wxDateSpan Weeks(int weeks);
961 static wxDateSpan Week();
963 // get an object for the given number of months
964 static wxDateSpan Months(int mon);
965 static wxDateSpan Month();
967 // get an object for the given number of years
968 static wxDateSpan Years(int years);
969 static wxDateSpan Year();
972 // ------------------------------------------------------------------------
974 // set number of years
975 wxDateSpan& SetYears(int n);
976 // set number of months
977 wxDateSpan& SetMonths(int n);
978 // set number of weeks
979 wxDateSpan& SetWeeks(int n);
980 // set number of days
981 wxDateSpan& SetDays(int n);
983 // get number of years
984 int GetYears() const;
985 // get number of months
986 int GetMonths() const;
987 // get number of weeks
988 int GetWeeks() const;
989 // get number of days
991 // returns 7*GetWeeks() + GetDays()
992 int GetTotalDays() const;
995 // ------------------------------------------------------------------------
997 // add another wxDateSpan to us
998 inline wxDateSpan& Add(const wxDateSpan& other);
1000 // subtract another wxDateSpan from us
1001 inline wxDateSpan& Subtract(const wxDateSpan& other);
1003 // inverse the sign of this timespan
1004 inline wxDateSpan& Neg();
1006 // multiply all components by a (signed) number
1007 inline wxDateSpan& Multiply(int factor);
1010 wxDateSpan __add__(const wxDateSpan& other) { return *self + other; }
1011 wxDateSpan __sub__(const wxDateSpan& other) { return *self - other; }
1012 wxDateSpan __mul__(int n) { return *self * n; }
1013 wxDateSpan __rmul__(int n) { return n * *self; }
1014 wxDateSpan __neg__() { return self->Negate(); }
1019 //---------------------------------------------------------------------------
1021 long wxGetLocalTime();
1022 long wxGetUTCTime();
1023 long wxGetCurrentTime();
1024 wxLongLong wxGetLocalTimeMillis();
1026 //---------------------------------------------------------------------------
1027 //---------------------------------------------------------------------------
1031 // wxClassInfo::CleanUpClasses();
1032 // wxClassInfo::InitializeClasses();
1036 //---------------------------------------------------------------------------