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 // Import some definitions of other classes, etc.
31 %pragma(python) code = "import string"
34 //---------------------------------------------------------------------------
37 static PyObject* __EnumerationHelper(bool flag, wxString& str, long index) {
38 PyObject* ret = PyTuple_New(3);
40 PyTuple_SET_ITEM(ret, 0, PyInt_FromLong(flag));
41 PyTuple_SET_ITEM(ret, 1, PyString_FromString(str));
42 PyTuple_SET_ITEM(ret, 2, PyInt_FromLong(index));
48 //---------------------------------------------------------------------------
52 wxCONFIG_USE_LOCAL_FILE = 1,
53 wxCONFIG_USE_GLOBAL_FILE = 2,
54 wxCONFIG_USE_RELATIVE_PATH = 4
57 //---------------------------------------------------------------------------
61 // wxConfigBase(const wxString& appName = wxEmptyString, **** An ABC
62 // const wxString& vendorName = wxEmptyString,
63 // const wxString& localFilename = wxEmptyString,
64 // const wxString& globalFilename = wxEmptyString,
73 Type_Integer, // use Read(long *)
74 Type_Float // use Read(double *)
78 // sets the config object, returns the previous pointer
79 static wxConfigBase *Set(wxConfigBase *pConfig);
80 // get the config object, creates it on demand unless DontCreateOnDemand
82 static wxConfigBase *Get(bool createOnDemand = TRUE);
83 // create a new config object: this function will create the "best"
84 // implementation of wxConfig available for the current platform, see
85 // comments near definition wxUSE_CONFIG_NATIVE for details. It returns
86 // the created object and also sets it as ms_pConfig.
87 static wxConfigBase *Create();
88 // should Get() try to create a new log object if the current one is NULL?
89 static void DontCreateOnDemand();
93 bool DeleteAll(); // This is supposed to have been fixed...
94 bool DeleteEntry(const wxString& key, bool bDeleteGroupIfEmpty = TRUE);
95 bool DeleteGroup(const wxString& key);
96 bool Exists(wxString& strName);
97 bool Flush(bool bCurrentOnly = FALSE);
98 wxString GetAppName();
101 // Each of these enumeration methods return a 3-tuple consisting of
102 // the continue flag, the value string, and the index for the next call.
104 PyObject* GetFirstGroup() {
109 cont = self->GetFirstGroup(value, index);
110 return __EnumerationHelper(cont, value, index);
113 PyObject* GetFirstEntry() {
118 cont = self->GetFirstEntry(value, index);
119 return __EnumerationHelper(cont, value, index);
122 PyObject* GetNextGroup(long index) {
126 cont = self->GetNextGroup(value, index);
127 return __EnumerationHelper(cont, value, index);
130 PyObject* GetNextEntry(long index) {
134 cont = self->GetNextEntry(value, index);
135 return __EnumerationHelper(cont, value, index);
140 int GetNumberOfEntries(bool bRecursive = FALSE);
141 int GetNumberOfGroups(bool bRecursive = FALSE);
143 wxString GetVendorName();
144 bool HasEntry(wxString& strName);
145 bool HasGroup(const wxString& strName);
146 bool IsExpandingEnvVars();
147 bool IsRecordingDefaults();
149 wxString Read(const wxString& key, const wxString& defaultVal = wxEmptyString);
152 long ReadInt(const wxString& key, long defaultVal = 0) {
154 self->Read(key, &rv, defaultVal);
157 double ReadFloat(const wxString& key, double defaultVal = 0.0) {
159 self->Read(key, &rv, defaultVal);
162 bool ReadBool(const wxString& key, bool defaultVal = FALSE) {
164 self->Read(key, &rv, defaultVal);
169 void SetExpandEnvVars (bool bDoIt = TRUE);
170 void SetPath(const wxString& strPath);
171 void SetRecordDefaults(bool bDoIt = TRUE);
172 void SetAppName(const wxString& appName);
173 void SetVendorName(const wxString& vendorName);
175 void SetStyle(long style);
178 bool Write(const wxString& key, const wxString& value);
179 %name(WriteInt)bool Write(const wxString& key, long value);
180 %name(WriteFloat)bool Write(const wxString& key, double value);
181 %name(WriteBool)bool Write(const wxString& key, bool value);
183 EntryType GetEntryType(const wxString& name);
184 bool RenameEntry(const wxString& oldName,
185 const wxString& newName);
186 bool RenameGroup(const wxString& oldName,
187 const wxString& newName);
188 wxString ExpandEnvVars(const wxString& str);
194 //---------------------------------------------------------------------------
196 // This will be a wxRegConfig on Win32 and wxFileConfig otherwise.
197 class wxConfig : public wxConfigBase {
199 wxConfig(const wxString& appName = wxEmptyString,
200 const wxString& vendorName = wxEmptyString,
201 const wxString& localFilename = wxEmptyString,
202 const wxString& globalFilename = wxEmptyString,
208 // Sometimes it's nice to explicitly have a wxFileConfig too.
209 class wxFileConfig : public wxConfigBase {
211 wxFileConfig(const wxString& appName = wxEmptyString,
212 const wxString& vendorName = wxEmptyString,
213 const wxString& localFilename = wxEmptyString,
214 const wxString& globalFilename = wxEmptyString,
220 //---------------------------------------------------------------------------
221 //---------------------------------------------------------------------------
228 %typemap(python,in) wxDateTime::TimeZone& {
229 $target = new wxDateTime::TimeZone((wxDateTime::TZ)PyInt_AsLong($source));
231 %typemap(python,freearg) wxDateTime::TimeZone& {
232 if ($source) delete $source;
236 #define LOCAL *(new wxDateTime::TimeZone(wxDateTime::Local))
240 %typemap(python, out) wxLongLong {
241 PyObject *hi, *lo, *shifter, *shifted;
242 hi = PyLong_FromLong($source->GetHi());
243 lo = PyLong_FromLong($source->GetLo());
244 shifter = PyLong_FromLong(32);
245 shifted = PyNumber_Lshift(hi, shifter);
246 $target = PyNumber_Or(shifted, lo);
258 typedef unsigned short wxDateTime_t;
264 GMT_12, GMT_11, GMT_10, GMT_9, GMT_8, GMT_7,
265 GMT_6, GMT_5, GMT_4, GMT_3, GMT_2, GMT_1,
267 GMT1, GMT2, GMT3, GMT4, GMT5, GMT6,
268 GMT7, GMT8, GMT9, GMT10, GMT11, GMT12,
271 WET = GMT0, // Western Europe Time
272 WEST = GMT1, // Western Europe Summer Time
273 CET = GMT1, // Central Europe Time
274 CEST = GMT2, // Central Europe Summer Time
275 EET = GMT2, // Eastern Europe Time
276 EEST = GMT3, // Eastern Europe Summer Time
277 MSK = GMT3, // Moscow Time
278 MSD = GMT4, // Moscow Summer Time
281 AST = GMT_4, // Atlantic Standard Time
282 ADT = GMT_3, // Atlantic Daylight Time
283 EST = GMT_5, // Eastern Standard Time
284 EDT = GMT_4, // Eastern Daylight Saving Time
285 CST = GMT_6, // Central Standard Time
286 CDT = GMT_5, // Central Daylight Saving Time
287 MST = GMT_7, // Mountain Standard Time
288 MDT = GMT_6, // Mountain Daylight Saving Time
289 PST = GMT_8, // Pacific Standard Time
290 PDT = GMT_7, // Pacific Daylight Saving Time
291 HST = GMT_10, // Hawaiian Standard Time
292 AKST = GMT_9, // Alaska Standard Time
293 AKDT = GMT_8, // Alaska Daylight Saving Time
297 A_WST = GMT8, // Western Standard Time
298 A_CST = GMT12 + 1, // Central Standard Time (+9.5)
299 A_EST = GMT10, // Eastern Standard Time
300 A_ESST = GMT11, // Eastern Summer Time
302 // Universal Coordinated Time = the new and politically correct name
309 Gregorian, // current calendar
310 Julian // calendar in use since -45 until the 1582 (or later)
315 Country_Unknown, // no special information for this country
316 Country_Default, // set the default country with SetCountry() method
317 // or use the default country with any other
319 // Western European countries: we assume that they all follow the same
320 // DST rules (true or false?)
321 Country_WesternEurope_Start,
322 Country_EEC = Country_WesternEurope_Start,
326 Country_WesternEurope_End = UK,
333 // symbolic names for the months
336 Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, Inv_Month
339 // symbolic names for the weekdays
342 Sun, Mon, Tue, Wed, Thu, Fri, Sat, Inv_WeekDay
345 // invalid value for the year
348 Inv_Year = SHRT_MIN // should hold in wxDateTime_t
351 // flags for GetWeekDayName and GetMonthName
354 Name_Full = 0x01, // return full name
355 Name_Abbr = 0x02 // return abbreviated name
358 // flags for GetWeekOfYear and GetWeekOfMonth
361 Default_First, // Sunday_First for US, Monday_First for the rest
362 Monday_First, // week starts with a Monday
363 Sunday_First // week starts with a Sunday
368 // ------------------------------------------------------------------------
370 // set the current country
371 static void SetCountry(Country country);
372 // get the current country
373 static Country GetCountry();
375 // return TRUE if the country is a West European one (in practice,
376 // this means that the same DST rules as for EEC apply)
377 static bool IsWestEuropeanCountry(Country country = Country_Default);
379 // return the current year
380 static int GetCurrentYear(Calendar cal = Gregorian);
382 // convert the year as returned by wxDateTime::GetYear() to a year
383 // suitable for BC/AD notation. The difference is that BC year 1
384 // corresponds to the year 0 (while BC year 0 didn't exist) and AD
385 // year N is just year N.
386 static int ConvertYearToBC(int year);
388 // return the current month
389 static Month GetCurrentMonth(Calendar cal = Gregorian);
391 // returns TRUE if the given year is a leap year in the given calendar
392 static bool IsLeapYear(int year = Inv_Year, Calendar cal = Gregorian);
394 // get the century (19 for 1999, 20 for 2000 and -5 for 492 BC)
395 static int GetCentury(int year = Inv_Year);
397 // returns the number of days in this year (356 or 355 for Gregorian
398 // calendar usually :-)
399 %name(GetNumberOfDaysinYear)
400 static wxDateTime_t GetNumberOfDays(int year, Calendar cal = Gregorian);
402 // get the number of the days in the given month (default value for
403 // the year means the current one)
404 %name(GetNumberOfDaysInMonth)
405 static wxDateTime_t GetNumberOfDays(Month month,
407 Calendar cal = Gregorian);
409 // get the full (default) or abbreviated month name in the current
410 // locale, returns empty string on error
411 static wxString GetMonthName(Month month,
412 NameFlags flags = Name_Full);
414 // get the full (default) or abbreviated weekday name in the current
415 // locale, returns empty string on error
416 static wxString GetWeekDayName(WeekDay weekday,
417 NameFlags flags = Name_Full);
419 // get the AM and PM strings in the current locale (may be empty)
420 static void GetAmPmStrings(wxString *OUTPUT, wxString *OUTPUT);
422 // return TRUE if the given country uses DST for this year
423 static bool IsDSTApplicable(int year = Inv_Year,
424 Country country = Country_Default);
426 // get the beginning of DST for this year, will return invalid object
427 // if no DST applicable in this year. The default value of the
428 // parameter means to take the current year.
429 static wxDateTime GetBeginDST(int year = Inv_Year,
430 Country country = Country_Default);
431 // get the end of DST for this year, will return invalid object
432 // if no DST applicable in this year. The default value of the
433 // parameter means to take the current year.
434 static wxDateTime GetEndDST(int year = Inv_Year,
435 Country country = Country_Default);
437 // return the wxDateTime object for the current time
438 static inline wxDateTime Now();
440 // return the wxDateTime object for today midnight: i.e. as Now() but
441 // with time set to 0
442 static inline wxDateTime Today();
446 // ------------------------------------------------------------------------
450 %name(wxDateTimeFromTimeT)wxDateTime(time_t timet);
451 %name(wxDateTimeFromJDN)wxDateTime(double jdn);
452 %name(wxDateTimeFromHMS)wxDateTime(wxDateTime_t hour,
453 wxDateTime_t minute = 0,
454 wxDateTime_t second = 0,
455 wxDateTime_t millisec = 0);
456 %name(wxDateTimeFromDMY)wxDateTime(wxDateTime_t day,
457 Month month = Inv_Month,
459 wxDateTime_t hour = 0,
460 wxDateTime_t minute = 0,
461 wxDateTime_t second = 0,
462 wxDateTime_t millisec = 0);
466 // ------------------------------------------------------------------------
469 wxDateTime& SetToCurrent();
471 // set to given time_t value
472 %name(SetTimeT)wxDateTime& Set(time_t timet);
474 // set to given JDN (beware of rounding errors)
475 %name(SetJDN)wxDateTime& Set(double jdn);
477 // set to given time, date = today
478 %name(SetHMS)wxDateTime& Set(wxDateTime_t hour,
479 wxDateTime_t minute = 0,
480 wxDateTime_t second = 0,
481 wxDateTime_t millisec = 0);
483 // from separate values for each component with explicit date
484 // (defaults for month and year are the current values)
485 wxDateTime& Set(wxDateTime_t day,
486 Month month = Inv_Month,
487 int year = Inv_Year, // 1999, not 99 please!
488 wxDateTime_t hour = 0,
489 wxDateTime_t minute = 0,
490 wxDateTime_t second = 0,
491 wxDateTime_t millisec = 0);
493 // resets time to 00:00:00, doesn't change the date
494 wxDateTime& ResetTime();
496 // the following functions don't change the values of the other
497 // fields, i.e. SetMinute() won't change either hour or seconds value
500 wxDateTime& SetYear(int year);
502 wxDateTime& SetMonth(Month month);
503 // set the day of the month
504 wxDateTime& SetDay(wxDateTime_t day);
506 wxDateTime& SetHour(wxDateTime_t hour);
508 wxDateTime& SetMinute(wxDateTime_t minute);
510 wxDateTime& SetSecond(wxDateTime_t second);
512 wxDateTime& SetMillisecond(wxDateTime_t millisecond);
515 // ------------------------------------------------------------------------
516 // calendar calculations
518 // set to the given week day in the same week as this one
519 wxDateTime& SetToWeekDayInSameWeek(WeekDay weekday);
520 wxDateTime GetWeekDayInSameWeek(WeekDay weekday);
522 // set to the next week day following this one
523 wxDateTime& SetToNextWeekDay(WeekDay weekday);
524 wxDateTime GetNextWeekDay(WeekDay weekday);
526 // set to the previous week day before this one
527 wxDateTime& SetToPrevWeekDay(WeekDay weekday);
528 wxDateTime GetPrevWeekDay(WeekDay weekday);
530 // set to Nth occurence of given weekday in the given month of the
531 // given year (time is set to 0), return TRUE on success and FALSE on
532 // failure. n may be positive (1..5) or negative to count from the end
533 // of the month (see helper function SetToLastWeekDay())
534 bool SetToWeekDay(WeekDay weekday,
536 Month month = Inv_Month,
537 int year = Inv_Year);
538 // wxDateTime GetWeekDay(WeekDay weekday,
540 // Month month = Inv_Month,
541 // int year = Inv_Year);
543 // sets to the last weekday in the given month, year
544 bool SetToLastWeekDay(WeekDay weekday,
545 Month month = Inv_Month,
546 int year = Inv_Year);
547 wxDateTime GetLastWeekDay(WeekDay weekday,
548 Month month = Inv_Month,
549 int year = Inv_Year);
551 // sets the date to the given day of the given week in the year,
552 // returns TRUE on success and FALSE if given date doesn't exist (e.g.
554 bool SetToTheWeek(wxDateTime_t numWeek, WeekDay weekday = Mon);
555 wxDateTime GetWeek(wxDateTime_t numWeek, WeekDay weekday = Mon);
557 // sets the date to the last day of the given (or current) month or the
558 // given (or current) year
559 wxDateTime& SetToLastMonthDay(Month month = Inv_Month,
560 int year = Inv_Year);
561 wxDateTime GetLastMonthDay(Month month = Inv_Month,
562 int year = Inv_Year);
564 // sets to the given year day (1..365 or 366)
565 wxDateTime& SetToYearDay(wxDateTime_t yday);
566 wxDateTime GetYearDay(wxDateTime_t yday);
568 // The definitions below were taken verbatim from
570 // http://www.capecod.net/~pbaum/date/date0.htm
572 // (Peter Baum's home page)
574 // definition: The Julian Day Number, Julian Day, or JD of a
575 // particular instant of time is the number of days and fractions of a
576 // day since 12 hours Universal Time (Greenwich mean noon) on January
577 // 1 of the year -4712, where the year is given in the Julian
578 // proleptic calendar. The idea of using this reference date was
579 // originally proposed by Joseph Scalizer in 1582 to count years but
580 // it was modified by 19th century astronomers to count days. One
581 // could have equivalently defined the reference time to be noon of
582 // November 24, -4713 if were understood that Gregorian calendar rules
583 // were applied. Julian days are Julian Day Numbers and are not to be
584 // confused with Julian dates.
586 // definition: The Rata Die number is a date specified as the number
587 // of days relative to a base date of December 31 of the year 0. Thus
588 // January 1 of the year 1 is Rata Die day 1.
590 // get the Julian Day number (the fractional part specifies the time of
591 // the day, related to noon - beware of rounding errors!)
592 double GetJulianDayNumber();
595 // get the Modified Julian Day number: it is equal to JDN - 2400000.5
596 // and so integral MJDs correspond to the midnights (and not noons).
597 // MJD 0 is Nov 17, 1858
598 double GetModifiedJulianDayNumber() const { return GetJDN() - 2400000.5; }
601 // get the Rata Die number
605 // ------------------------------------------------------------------------
608 // transform to any given timezone
609 wxDateTime ToTimezone(const wxDateTime::TimeZone& tz, bool noDST = FALSE);
610 wxDateTime& MakeTimezone(const wxDateTime::TimeZone& tz, bool noDST = FALSE);
612 // transform to GMT/UTC
613 wxDateTime ToGMT(bool noDST = FALSE);
614 wxDateTime& MakeGMT(bool noDST = FALSE);
616 // is daylight savings time in effect at this moment according to the
617 // rules of the specified country?
619 // Return value is > 0 if DST is in effect, 0 if it is not and -1 if
620 // the information is not available (this is compatible with ANSI C)
621 int IsDST(Country country = Country_Default);
625 // ------------------------------------------------------------------------
628 // is the date valid (TRUE even for non initialized objects)?
629 inline bool IsValid() const;
631 // get the number of seconds since the Unix epoch - returns (time_t)-1
632 // if the value is out of range
633 inline time_t GetTicks() const;
635 // get the year (returns Inv_Year if date is invalid)
636 int GetYear(const wxDateTime::TimeZone& tz = LOCAL) const;
638 // get the month (Inv_Month if date is invalid)
639 Month GetMonth(const wxDateTime::TimeZone& tz = LOCAL) const;
641 // get the month day (in 1..31 range, 0 if date is invalid)
642 wxDateTime_t GetDay(const wxDateTime::TimeZone& tz = LOCAL) const;
644 // get the day of the week (Inv_WeekDay if date is invalid)
645 WeekDay GetWeekDay(const wxDateTime::TimeZone& tz = LOCAL) const;
647 // get the hour of the day
648 wxDateTime_t GetHour(const wxDateTime::TimeZone& tz = LOCAL) const;
651 wxDateTime_t GetMinute(const wxDateTime::TimeZone& tz = LOCAL) const;
654 wxDateTime_t GetSecond(const wxDateTime::TimeZone& tz = LOCAL) const;
657 wxDateTime_t GetMillisecond(const wxDateTime::TimeZone& tz = LOCAL) const;
660 // get the day since the year start (1..366, 0 if date is invalid)
661 wxDateTime_t GetDayOfYear(const wxDateTime::TimeZone& tz = LOCAL) const;
662 // get the week number since the year start (1..52 or 53, 0 if date is
664 wxDateTime_t GetWeekOfYear(WeekFlags flags = Monday_First,
665 const wxDateTime::TimeZone& tz = LOCAL) const;
666 // get the week number since the month start (1..5, 0 if date is
668 wxDateTime_t GetWeekOfMonth(WeekFlags flags = Monday_First,
669 const wxDateTime::TimeZone& tz = LOCAL) const;
671 // is this date a work day? This depends on a country, of course,
672 // because the holidays are different in different countries
673 bool IsWorkDay(Country country = Country_Default) const;
675 // is this date later than Gregorian calendar introduction for the
676 // given country (see enum GregorianAdoption)?
678 // NB: this function shouldn't be considered as absolute authority in
679 // the matter. Besides, for some countries the exact date of
680 // adoption of the Gregorian calendar is simply unknown.
681 //bool IsGregorianDate(GregorianAdoption country = Gr_Standard) const;
684 // ------------------------------------------------------------------------
685 // comparison (see also functions below for operator versions)
687 // returns TRUE if the two moments are strictly identical
688 inline bool IsEqualTo(const wxDateTime& datetime) const;
690 // returns TRUE if the date is strictly earlier than the given one
691 inline bool IsEarlierThan(const wxDateTime& datetime) const;
693 // returns TRUE if the date is strictly later than the given one
694 inline bool IsLaterThan(const wxDateTime& datetime) const;
696 // returns TRUE if the date is strictly in the given range
697 inline bool IsStrictlyBetween(const wxDateTime& t1,
698 const wxDateTime& t2) const;
700 // returns TRUE if the date is in the given range
701 inline bool IsBetween(const wxDateTime& t1, const wxDateTime& t2) const;
703 // do these two objects refer to the same date?
704 inline bool IsSameDate(const wxDateTime& dt) const;
706 // do these two objects have the same time?
707 inline bool IsSameTime(const wxDateTime& dt) const;
709 // are these two objects equal up to given timespan?
710 inline bool IsEqualUpTo(const wxDateTime& dt, const wxTimeSpan& ts) const;
713 // ------------------------------------------------------------------------
714 // arithmetics with dates (see also below for more operators)
716 // add a time span (positive or negative)
717 %name(AddTS) wxDateTime& Add(const wxTimeSpan& diff);
718 // add a date span (positive or negative)
719 %name(AddDS) wxDateTime& Add(const wxDateSpan& diff);
721 // subtract a time span (positive or negative)
722 %name(SubtractTS) wxDateTime& Subtract(const wxTimeSpan& diff);
724 // subtract a date span (positive or negative)
725 %name(SubtractDS) wxDateTime& Subtract(const wxDateSpan& diff);
727 // return the difference between two dates
728 wxTimeSpan Subtract(const wxDateTime& dt) const;
732 wxDateTime __add__TS(const wxTimeSpan& other) { return *self + other; }
733 wxDateTime __add__DS(const wxDateSpan& other) { return *self + other; }
735 wxTimeSpan __sub__DT(const wxDateTime& other) { return *self - other; }
736 wxDateTime __sub__TS(const wxTimeSpan& other) { return *self - other; }
737 wxDateTime __sub__DS(const wxDateSpan& other) { return *self - other; }
739 int __cmp__(const wxDateTime& other) {
740 if (*self < other) return -1;
741 if (*self == other) return 0;
746 %pragma(python) addtoclass = "
747 def __add__(self, other):
748 if string.find(other.this, 'wxTimeSpan') != -1:
749 return self.__add__TS(other)
750 if string.find(other.this, 'wxDateSpan') != -1:
751 return self.__add__DS(other)
752 raise TypeError, 'Invalid r.h.s. type for __add__'
753 def __sub__(self, other):
754 if string.find(other.this, 'wxDateTime') != -1:
755 return self.__sub__DT(other)
756 if string.find(other.this, 'wxTimeSpan') != -1:
757 return self.__sub__TS(other)
758 if string.find(other.this, 'wxDateSpan') != -1:
759 return self.__sub__DS(other)
760 raise TypeError, 'Invalid r.h.s. type for __sub__'
763 // ------------------------------------------------------------------------
764 // conversion to/from text: all conversions from text return the pointer to
765 // the next character following the date specification (i.e. the one where
766 // the scan had to stop) or NULL on failure.
768 // parse a string in RFC 822 format (found e.g. in mail headers and
769 // having the form "Wed, 10 Feb 1999 19:07:07 +0100")
770 const char *ParseRfc822Date(const char* date);
772 // parse a date/time in the given format (see strptime(3)), fill in
773 // the missing (in the string) fields with the values of dateDef (by
774 // default, they will not change if they had valid values or will
775 // default to Today() otherwise)
776 const char *ParseFormat(const char *date,
777 const char *format = "%c",
778 const wxDateTime& dateDef = wxDefaultDateTime);
780 // parse a string containing the date/time in "free" format, this
781 // function will try to make an educated guess at the string contents
782 const char *ParseDateTime(const char *datetime);
784 // parse a string containing the date only in "free" format (less
785 // flexible than ParseDateTime)
786 const char *ParseDate(const char *date);
788 // parse a string containing the time only in "free" format
789 const char *ParseTime(const char *time);
791 // this function accepts strftime()-like format string (default
792 // argument corresponds to the preferred date and time representation
793 // for the current locale) and returns the string containing the
794 // resulting text representation
795 wxString Format(const char *format = "%c",
796 const wxDateTime::TimeZone& tz = LOCAL) const;
798 // preferred date representation for the current locale
799 wxString FormatDate() const;
801 // preferred time representation for the current locale
802 wxString FormatTime() const;
804 // returns the string representing the date in ISO 8601 format
806 wxString FormatISODate() const;
808 // returns the string representing the time in ISO 8601 format
810 wxString FormatISOTime() const;
812 %pragma(python) addtoclass = "
814 return '<wxDateTime: \"%s\" at %s>' % ( self.Format(), self.this)
821 //---------------------------------------------------------------------------
822 //---------------------------------------------------------------------------
828 // return the timespan for the given number of seconds
829 static wxTimeSpan Seconds(long sec);
830 static wxTimeSpan Second();
832 // return the timespan for the given number of minutes
833 static wxTimeSpan Minutes(long min);
834 static wxTimeSpan Minute();
836 // return the timespan for the given number of hours
837 static wxTimeSpan Hours(long hours);
838 static wxTimeSpan Hour();
840 // return the timespan for the given number of days
841 static wxTimeSpan Days(long days);
842 static wxTimeSpan Day();
844 // return the timespan for the given number of weeks
845 static wxTimeSpan Weeks(long days);
846 static wxTimeSpan Week();
848 // ------------------------------------------------------------------------
851 // from separate values for each component, date set to 0 (hours are
852 // not restricted to 0..24 range, neither are minutes, seconds or
854 wxTimeSpan(long hours = 0,
857 long milliseconds = 0);
861 // ------------------------------------------------------------------------
862 // arithmetics with time spans
864 // add two timespans together
865 inline wxTimeSpan& Add(const wxTimeSpan& diff);
867 // subtract another timespan
868 inline wxTimeSpan& Subtract(const wxTimeSpan& diff);
870 // multiply timespan by a scalar
871 inline wxTimeSpan& Multiply(int n);
873 // negate the value of the timespan
876 // return the absolute value of the timespan: does _not_ modify the
878 inline wxTimeSpan Abs() const;
881 wxTimeSpan __add__(const wxTimeSpan& other) { return *self + other; }
882 wxTimeSpan __sub__(const wxTimeSpan& other) { return *self - other; }
883 wxTimeSpan __mul__(int n) { return *self * n; }
884 wxTimeSpan __rmul__(int n) { return n * *self; }
885 wxTimeSpan __neg__() { return self->Negate(); }
886 int __cmp__(const wxTimeSpan& other) {
887 if (*self < other) return -1;
888 if (*self == other) return 0;
893 // comparaison (see also operator versions below)
894 // ------------------------------------------------------------------------
896 // is the timespan null?
899 // is the timespan positive?
900 bool IsPositive() const;
902 // is the timespan negative?
903 bool IsNegative() const;
905 // are two timespans equal?
906 inline bool IsEqualTo(const wxTimeSpan& ts) const;
908 // compare two timestamps: works with the absolute values, i.e. -2
909 // hours is longer than 1 hour. Also, it will return FALSE if the
910 // timespans are equal in absolute value.
911 inline bool IsLongerThan(const wxTimeSpan& ts) const;
913 // compare two timestamps: works with the absolute values, i.e. 1
914 // hour is shorter than -2 hours. Also, it will return FALSE if the
915 // timespans are equal in absolute value.
916 bool IsShorterThan(const wxTimeSpan& t) const;
918 // ------------------------------------------------------------------------
919 // breaking into days, hours, minutes and seconds
921 // get the max number of weeks in this timespan
922 inline int GetWeeks() const;
923 // get the max number of days in this timespan
924 inline int GetDays() const;
925 // get the max number of hours in this timespan
926 inline int GetHours() const;
927 // get the max number of minutes in this timespan
928 inline int GetMinutes() const;
931 // get the max number of seconds in this timespan
932 inline wxLongLong GetSeconds() const;
933 // get the number of milliseconds in this timespan
934 wxLongLong GetMilliseconds() const;
936 // ------------------------------------------------------------------------
937 // conversion to text
939 // this function accepts strftime()-like format string (default
940 // argument corresponds to the preferred date and time representation
941 // for the current locale) and returns the string containing the
942 // resulting text representation. Notice that only some of format
943 // specifiers valid for wxDateTime are valid for wxTimeSpan: hours,
944 // minutes and seconds make sense, but not "PM/AM" string for example.
945 wxString Format(const char *format = "%c") const;
947 // // preferred date representation for the current locale
948 // wxString FormatDate() const;
950 // // preferred time representation for the current locale
951 // wxString FormatTime() const;
953 // %pragma(python) addtoclass = "
954 // def __repr__(self):
955 // return '<wxTimeSpan: \"%s\" at %s>' % ( self.Format(), self.this)
956 // def __str__(self):
957 // return self.Format()
962 //---------------------------------------------------------------------------
963 //---------------------------------------------------------------------------
968 // this many years/months/weeks/days
969 wxDateSpan(int years = 0, int months = 0, int weeks = 0, int days = 0)
979 // get an object for the given number of days
980 static wxDateSpan Days(int days);
981 static wxDateSpan Day();
983 // get an object for the given number of weeks
984 static wxDateSpan Weeks(int weeks);
985 static wxDateSpan Week();
987 // get an object for the given number of months
988 static wxDateSpan Months(int mon);
989 static wxDateSpan Month();
991 // get an object for the given number of years
992 static wxDateSpan Years(int years);
993 static wxDateSpan Year();
996 // ------------------------------------------------------------------------
998 // set number of years
999 wxDateSpan& SetYears(int n);
1000 // set number of months
1001 wxDateSpan& SetMonths(int n);
1002 // set number of weeks
1003 wxDateSpan& SetWeeks(int n);
1004 // set number of days
1005 wxDateSpan& SetDays(int n);
1007 // get number of years
1008 int GetYears() const;
1009 // get number of months
1010 int GetMonths() const;
1011 // get number of weeks
1012 int GetWeeks() const;
1013 // get number of days
1014 int GetDays() const;
1015 // returns 7*GetWeeks() + GetDays()
1016 int GetTotalDays() const;
1019 // ------------------------------------------------------------------------
1021 // add another wxDateSpan to us
1022 inline wxDateSpan& Add(const wxDateSpan& other);
1024 // subtract another wxDateSpan from us
1025 inline wxDateSpan& Subtract(const wxDateSpan& other);
1027 // inverse the sign of this timespan
1028 inline wxDateSpan& Neg();
1030 // multiply all components by a (signed) number
1031 inline wxDateSpan& Multiply(int factor);
1034 wxDateSpan __add__(const wxDateSpan& other) { return *self + other; }
1035 wxDateSpan __sub__(const wxDateSpan& other) { return *self - other; }
1036 wxDateSpan __mul__(int n) { return *self * n; }
1037 wxDateSpan __rmul__(int n) { return n * *self; }
1038 wxDateSpan __neg__() { return self->Negate(); }
1043 //---------------------------------------------------------------------------
1045 long wxGetLocalTime();
1046 long wxGetUTCTime();
1047 long wxGetCurrentTime();
1048 wxLongLong wxGetLocalTimeMillis();
1050 //---------------------------------------------------------------------------
1051 //---------------------------------------------------------------------------
1054 wxClassInfo::CleanUpClasses();
1055 wxClassInfo::InitializeClasses();
1058 //---------------------------------------------------------------------------