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 wxString wxPyEmptyStr("");
39 static PyObject* __EnumerationHelper(bool flag, wxString& str, long index) {
40 PyObject* ret = PyTuple_New(3);
42 PyTuple_SET_ITEM(ret, 0, PyInt_FromLong(flag));
43 PyTuple_SET_ITEM(ret, 1, PyString_FromString(str));
44 PyTuple_SET_ITEM(ret, 2, PyInt_FromLong(index));
50 //---------------------------------------------------------------------------
54 wxCONFIG_USE_LOCAL_FILE = 1,
55 wxCONFIG_USE_GLOBAL_FILE = 2,
56 wxCONFIG_USE_RELATIVE_PATH = 4
59 //---------------------------------------------------------------------------
63 // wxConfigBase(const wxString& appName = wxPyEmptyStr, **** An ABC
64 // const wxString& vendorName = wxPyEmptyStr,
65 // const wxString& localFilename = wxPyEmptyStr,
66 // const wxString& globalFilename = wxPyEmptyStr,
75 Type_Integer, // use Read(long *)
76 Type_Float // use Read(double *)
80 // sets the config object, returns the previous pointer
81 static wxConfigBase *Set(wxConfigBase *pConfig);
82 // get the config object, creates it on demand unless DontCreateOnDemand
84 static wxConfigBase *Get(bool createOnDemand = TRUE);
85 // create a new config object: this function will create the "best"
86 // implementation of wxConfig available for the current platform, see
87 // comments near definition wxUSE_CONFIG_NATIVE for details. It returns
88 // the created object and also sets it as ms_pConfig.
89 static wxConfigBase *Create();
90 // should Get() try to create a new log object if the current one is NULL?
91 static void DontCreateOnDemand();
95 bool DeleteAll(); // This is supposed to have been fixed...
96 bool DeleteEntry(const wxString& key, bool bDeleteGroupIfEmpty = TRUE);
97 bool DeleteGroup(const wxString& key);
98 bool Exists(wxString& strName);
99 bool Flush(bool bCurrentOnly = FALSE);
100 wxString GetAppName();
103 // Each of these enumeration methods return a 3-tuple consisting of
104 // the continue flag, the value string, and the index for the next call.
106 PyObject* GetFirstGroup() {
111 cont = self->GetFirstGroup(value, index);
112 return __EnumerationHelper(cont, value, index);
115 PyObject* GetFirstEntry() {
120 cont = self->GetFirstEntry(value, index);
121 return __EnumerationHelper(cont, value, index);
124 PyObject* GetNextGroup(long index) {
128 cont = self->GetNextGroup(value, index);
129 return __EnumerationHelper(cont, value, index);
132 PyObject* GetNextEntry(long index) {
136 cont = self->GetNextEntry(value, index);
137 return __EnumerationHelper(cont, value, index);
142 int GetNumberOfEntries(bool bRecursive = FALSE);
143 int GetNumberOfGroups(bool bRecursive = FALSE);
145 wxString GetVendorName();
146 bool HasEntry(wxString& strName);
147 bool HasGroup(const wxString& strName);
148 bool IsExpandingEnvVars();
149 bool IsRecordingDefaults();
151 wxString Read(const wxString& key, const wxString& defaultVal = wxPyEmptyStr);
152 %name(ReadInt)long Read(const wxString& key, long defaultVal = 0);
153 %name(ReadFloat)double Read(const wxString& key, double defaultVal = 0.0);
155 void SetExpandEnvVars (bool bDoIt = TRUE);
156 void SetPath(const wxString& strPath);
157 void SetRecordDefaults(bool bDoIt = TRUE);
158 void SetAppName(const wxString& appName);
159 void SetVendorName(const wxString& vendorName);
161 void SetStyle(long style);
164 bool Write(const wxString& key, const wxString& value);
165 %name(WriteInt)bool Write(const wxString& key, long value);
166 %name(WriteFloat)bool Write(const wxString& key, double value);
168 EntryType GetEntryType(const wxString& name);
169 bool RenameEntry(const wxString& oldName,
170 const wxString& newName);
171 bool RenameGroup(const wxString& oldName,
172 const wxString& newName);
173 wxString ExpandEnvVars(const wxString& str);
178 //---------------------------------------------------------------------------
180 class wxConfig : public wxConfigBase {
182 wxConfig(const wxString& appName = wxPyEmptyStr,
183 const wxString& vendorName = wxPyEmptyStr,
184 const wxString& localFilename = wxPyEmptyStr,
185 const wxString& globalFilename = wxPyEmptyStr,
190 class wxFileConfig : public wxConfigBase {
192 wxFileConfig(const wxString& appName = wxPyEmptyStr,
193 const wxString& vendorName = wxPyEmptyStr,
194 const wxString& localFilename = wxPyEmptyStr,
195 const wxString& globalFilename = wxPyEmptyStr,
201 //---------------------------------------------------------------------------
202 //---------------------------------------------------------------------------
209 %typemap(python,in) wxDateTime::TimeZone& {
210 $target = new wxDateTime::TimeZone((wxDateTime::TZ)PyInt_AsLong($source));
212 %typemap(python,freearg) wxDateTime::TimeZone& {
213 if ($source) delete $source;
217 #define LOCAL *(new wxDateTime::TimeZone(wxDateTime::Local))
221 %typemap(python, out) wxLongLong {
222 PyObject *hi, *lo, *shifter, *shifted;
223 hi = PyLong_FromLong($source->GetHi());
224 lo = PyLong_FromLong($source->GetLo());
225 shifter = PyLong_FromLong(32);
226 shifted = PyNumber_Lshift(hi, shifter);
227 $target = PyNumber_Or(shifted, lo);
239 typedef unsigned short wxDateTime_t;
245 GMT_12, GMT_11, GMT_10, GMT_9, GMT_8, GMT_7,
246 GMT_6, GMT_5, GMT_4, GMT_3, GMT_2, GMT_1,
248 GMT1, GMT2, GMT3, GMT4, GMT5, GMT6,
249 GMT7, GMT8, GMT9, GMT10, GMT11, GMT12,
252 WET = GMT0, // Western Europe Time
253 WEST = GMT1, // Western Europe Summer Time
254 CET = GMT1, // Central Europe Time
255 CEST = GMT2, // Central Europe Summer Time
256 EET = GMT2, // Eastern Europe Time
257 EEST = GMT3, // Eastern Europe Summer Time
258 MSK = GMT3, // Moscow Time
259 MSD = GMT4, // Moscow Summer Time
262 AST = GMT_4, // Atlantic Standard Time
263 ADT = GMT_3, // Atlantic Daylight Time
264 EST = GMT_5, // Eastern Standard Time
265 EDT = GMT_4, // Eastern Daylight Saving Time
266 CST = GMT_6, // Central Standard Time
267 CDT = GMT_5, // Central Daylight Saving Time
268 MST = GMT_7, // Mountain Standard Time
269 MDT = GMT_6, // Mountain Daylight Saving Time
270 PST = GMT_8, // Pacific Standard Time
271 PDT = GMT_7, // Pacific Daylight Saving Time
272 HST = GMT_10, // Hawaiian Standard Time
273 AKST = GMT_9, // Alaska Standard Time
274 AKDT = GMT_8, // Alaska Daylight Saving Time
278 A_WST = GMT8, // Western Standard Time
279 A_CST = GMT12 + 1, // Central Standard Time (+9.5)
280 A_EST = GMT10, // Eastern Standard Time
281 A_ESST = GMT11, // Eastern Summer Time
283 // Universal Coordinated Time = the new and politically correct name
290 Gregorian, // current calendar
291 Julian // calendar in use since -45 until the 1582 (or later)
296 Country_Unknown, // no special information for this country
297 Country_Default, // set the default country with SetCountry() method
298 // or use the default country with any other
300 // Western European countries: we assume that they all follow the same
301 // DST rules (true or false?)
302 Country_WesternEurope_Start,
303 Country_EEC = Country_WesternEurope_Start,
307 Country_WesternEurope_End = UK,
314 // symbolic names for the months
317 Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, Inv_Month
320 // symbolic names for the weekdays
323 Sun, Mon, Tue, Wed, Thu, Fri, Sat, Inv_WeekDay
326 // invalid value for the year
329 Inv_Year = SHRT_MIN // should hold in wxDateTime_t
332 // flags for GetWeekDayName and GetMonthName
335 Name_Full = 0x01, // return full name
336 Name_Abbr = 0x02 // return abbreviated name
339 // flags for GetWeekOfYear and GetWeekOfMonth
342 Default_First, // Sunday_First for US, Monday_First for the rest
343 Monday_First, // week starts with a Monday
344 Sunday_First // week starts with a Sunday
349 // ------------------------------------------------------------------------
351 // set the current country
352 static void SetCountry(Country country);
353 // get the current country
354 static Country GetCountry();
356 // return TRUE if the country is a West European one (in practice,
357 // this means that the same DST rules as for EEC apply)
358 static bool IsWestEuropeanCountry(Country country = Country_Default);
360 // return the current year
361 static int GetCurrentYear(Calendar cal = Gregorian);
363 // convert the year as returned by wxDateTime::GetYear() to a year
364 // suitable for BC/AD notation. The difference is that BC year 1
365 // corresponds to the year 0 (while BC year 0 didn't exist) and AD
366 // year N is just year N.
367 static int ConvertYearToBC(int year);
369 // return the current month
370 static Month GetCurrentMonth(Calendar cal = Gregorian);
372 // returns TRUE if the given year is a leap year in the given calendar
373 static bool IsLeapYear(int year = Inv_Year, Calendar cal = Gregorian);
375 // get the century (19 for 1999, 20 for 2000 and -5 for 492 BC)
376 static int GetCentury(int year = Inv_Year);
378 // returns the number of days in this year (356 or 355 for Gregorian
379 // calendar usually :-)
380 %name(GetNumberOfDaysinYear)
381 static wxDateTime_t GetNumberOfDays(int year, Calendar cal = Gregorian);
383 // get the number of the days in the given month (default value for
384 // the year means the current one)
385 %name(GetNumberOfDaysInMonth)
386 static wxDateTime_t GetNumberOfDays(Month month,
388 Calendar cal = Gregorian);
390 // get the full (default) or abbreviated month name in the current
391 // locale, returns empty string on error
392 static wxString GetMonthName(Month month,
393 NameFlags flags = Name_Full);
395 // get the full (default) or abbreviated weekday name in the current
396 // locale, returns empty string on error
397 static wxString GetWeekDayName(WeekDay weekday,
398 NameFlags flags = Name_Full);
400 // get the AM and PM strings in the current locale (may be empty)
401 static void GetAmPmStrings(wxString *OUTPUT, wxString *OUTPUT);
403 // return TRUE if the given country uses DST for this year
404 static bool IsDSTApplicable(int year = Inv_Year,
405 Country country = Country_Default);
407 // get the beginning 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 GetBeginDST(int year = Inv_Year,
411 Country country = Country_Default);
412 // get the end of DST for this year, will return invalid object
413 // if no DST applicable in this year. The default value of the
414 // parameter means to take the current year.
415 static wxDateTime GetEndDST(int year = Inv_Year,
416 Country country = Country_Default);
418 // return the wxDateTime object for the current time
419 static inline wxDateTime Now();
421 // return the wxDateTime object for today midnight: i.e. as Now() but
422 // with time set to 0
423 static inline wxDateTime Today();
427 // ------------------------------------------------------------------------
431 %name(wxDateTimeFromTimeT)wxDateTime(time_t timet);
432 %name(wxDateTimeFromJDN)wxDateTime(double jdn);
433 %name(wxDateTimeFromHMS)wxDateTime(wxDateTime_t hour,
434 wxDateTime_t minute = 0,
435 wxDateTime_t second = 0,
436 wxDateTime_t millisec = 0);
437 %name(wxDateTimeFromDMY)wxDateTime(wxDateTime_t day,
438 Month month = Inv_Month,
440 wxDateTime_t hour = 0,
441 wxDateTime_t minute = 0,
442 wxDateTime_t second = 0,
443 wxDateTime_t millisec = 0);
447 // ------------------------------------------------------------------------
450 wxDateTime& SetToCurrent();
452 // set to given time_t value
453 %name(SetTimeT)wxDateTime& Set(time_t timet);
455 // set to given JDN (beware of rounding errors)
456 %name(SetJDN)wxDateTime& Set(double jdn);
458 // set to given time, date = today
459 %name(SetHMS)wxDateTime& Set(wxDateTime_t hour,
460 wxDateTime_t minute = 0,
461 wxDateTime_t second = 0,
462 wxDateTime_t millisec = 0);
464 // from separate values for each component with explicit date
465 // (defaults for month and year are the current values)
466 wxDateTime& Set(wxDateTime_t day,
467 Month month = Inv_Month,
468 int year = Inv_Year, // 1999, not 99 please!
469 wxDateTime_t hour = 0,
470 wxDateTime_t minute = 0,
471 wxDateTime_t second = 0,
472 wxDateTime_t millisec = 0);
474 // resets time to 00:00:00, doesn't change the date
475 wxDateTime& ResetTime();
477 // the following functions don't change the values of the other
478 // fields, i.e. SetMinute() won't change either hour or seconds value
481 wxDateTime& SetYear(int year);
483 wxDateTime& SetMonth(Month month);
484 // set the day of the month
485 wxDateTime& SetDay(wxDateTime_t day);
487 wxDateTime& SetHour(wxDateTime_t hour);
489 wxDateTime& SetMinute(wxDateTime_t minute);
491 wxDateTime& SetSecond(wxDateTime_t second);
493 wxDateTime& SetMillisecond(wxDateTime_t millisecond);
496 // ------------------------------------------------------------------------
497 // calendar calculations
499 // set to the given week day in the same week as this one
500 wxDateTime& SetToWeekDayInSameWeek(WeekDay weekday);
501 wxDateTime GetWeekDayInSameWeek(WeekDay weekday);
503 // set to the next week day following this one
504 wxDateTime& SetToNextWeekDay(WeekDay weekday);
505 wxDateTime GetNextWeekDay(WeekDay weekday);
507 // set to the previous week day before this one
508 wxDateTime& SetToPrevWeekDay(WeekDay weekday);
509 wxDateTime GetPrevWeekDay(WeekDay weekday);
511 // set to Nth occurence of given weekday in the given month of the
512 // given year (time is set to 0), return TRUE on success and FALSE on
513 // failure. n may be positive (1..5) or negative to count from the end
514 // of the month (see helper function SetToLastWeekDay())
515 bool SetToWeekDay(WeekDay weekday,
517 Month month = Inv_Month,
518 int year = Inv_Year);
519 wxDateTime GetWeekDay(WeekDay weekday,
521 Month month = Inv_Month,
522 int year = Inv_Year);
524 // sets to the last weekday in the given month, year
525 bool SetToLastWeekDay(WeekDay weekday,
526 Month month = Inv_Month,
527 int year = Inv_Year);
528 wxDateTime GetLastWeekDay(WeekDay weekday,
529 Month month = Inv_Month,
530 int year = Inv_Year);
532 // sets the date to the given day of the given week in the year,
533 // returns TRUE on success and FALSE if given date doesn't exist (e.g.
535 bool SetToTheWeek(wxDateTime_t numWeek, WeekDay weekday = Mon);
536 wxDateTime GetWeek(wxDateTime_t numWeek, WeekDay weekday = Mon);
538 // sets the date to the last day of the given (or current) month or the
539 // given (or current) year
540 wxDateTime& SetToLastMonthDay(Month month = Inv_Month,
541 int year = Inv_Year);
542 wxDateTime GetLastMonthDay(Month month = Inv_Month,
543 int year = Inv_Year);
545 // sets to the given year day (1..365 or 366)
546 wxDateTime& SetToYearDay(wxDateTime_t yday);
547 wxDateTime GetYearDay(wxDateTime_t yday);
549 // The definitions below were taken verbatim from
551 // http://www.capecod.net/~pbaum/date/date0.htm
553 // (Peter Baum's home page)
555 // definition: The Julian Day Number, Julian Day, or JD of a
556 // particular instant of time is the number of days and fractions of a
557 // day since 12 hours Universal Time (Greenwich mean noon) on January
558 // 1 of the year -4712, where the year is given in the Julian
559 // proleptic calendar. The idea of using this reference date was
560 // originally proposed by Joseph Scalizer in 1582 to count years but
561 // it was modified by 19th century astronomers to count days. One
562 // could have equivalently defined the reference time to be noon of
563 // November 24, -4713 if were understood that Gregorian calendar rules
564 // were applied. Julian days are Julian Day Numbers and are not to be
565 // confused with Julian dates.
567 // definition: The Rata Die number is a date specified as the number
568 // of days relative to a base date of December 31 of the year 0. Thus
569 // January 1 of the year 1 is Rata Die day 1.
571 // get the Julian Day number (the fractional part specifies the time of
572 // the day, related to noon - beware of rounding errors!)
573 double GetJulianDayNumber();
576 // get the Modified Julian Day number: it is equal to JDN - 2400000.5
577 // and so integral MJDs correspond to the midnights (and not noons).
578 // MJD 0 is Nov 17, 1858
579 double GetModifiedJulianDayNumber() const { return GetJDN() - 2400000.5; }
582 // get the Rata Die number
586 // ------------------------------------------------------------------------
589 // transform to any given timezone
590 wxDateTime ToTimezone(const wxDateTime::TimeZone& tz, bool noDST = FALSE);
591 wxDateTime& MakeTimezone(const wxDateTime::TimeZone& tz, bool noDST = FALSE);
593 // transform to GMT/UTC
594 wxDateTime ToGMT(bool noDST = FALSE);
595 wxDateTime& MakeGMT(bool noDST = FALSE);
597 // is daylight savings time in effect at this moment according to the
598 // rules of the specified country?
600 // Return value is > 0 if DST is in effect, 0 if it is not and -1 if
601 // the information is not available (this is compatible with ANSI C)
602 int IsDST(Country country = Country_Default);
606 // ------------------------------------------------------------------------
609 // is the date valid (TRUE even for non initialized objects)?
610 inline bool IsValid() const;
612 // get the number of seconds since the Unix epoch - returns (time_t)-1
613 // if the value is out of range
614 inline time_t GetTicks() const;
616 // get the year (returns Inv_Year if date is invalid)
617 int GetYear(const wxDateTime::TimeZone& tz = LOCAL) const;
619 // get the month (Inv_Month if date is invalid)
620 Month GetMonth(const wxDateTime::TimeZone& tz = LOCAL) const;
622 // get the month day (in 1..31 range, 0 if date is invalid)
623 wxDateTime_t GetDay(const wxDateTime::TimeZone& tz = LOCAL) const;
625 // get the day of the week (Inv_WeekDay if date is invalid)
626 WeekDay GetWeekDay(const wxDateTime::TimeZone& tz = LOCAL) const;
628 // get the hour of the day
629 wxDateTime_t GetHour(const wxDateTime::TimeZone& tz = LOCAL) const;
632 wxDateTime_t GetMinute(const wxDateTime::TimeZone& tz = LOCAL) const;
635 wxDateTime_t GetSecond(const wxDateTime::TimeZone& tz = LOCAL) const;
638 wxDateTime_t GetMillisecond(const wxDateTime::TimeZone& tz = LOCAL) const;
641 // get the day since the year start (1..366, 0 if date is invalid)
642 wxDateTime_t GetDayOfYear(const wxDateTime::TimeZone& tz = LOCAL) const;
643 // get the week number since the year start (1..52 or 53, 0 if date is
645 wxDateTime_t GetWeekOfYear(WeekFlags flags = Monday_First,
646 const wxDateTime::TimeZone& tz = LOCAL) const;
647 // get the week number since the month start (1..5, 0 if date is
649 wxDateTime_t GetWeekOfMonth(WeekFlags flags = Monday_First,
650 const wxDateTime::TimeZone& tz = LOCAL) const;
652 // is this date a work day? This depends on a country, of course,
653 // because the holidays are different in different countries
654 bool IsWorkDay(Country country = Country_Default) const;
656 // is this date later than Gregorian calendar introduction for the
657 // given country (see enum GregorianAdoption)?
659 // NB: this function shouldn't be considered as absolute authority in
660 // the matter. Besides, for some countries the exact date of
661 // adoption of the Gregorian calendar is simply unknown.
662 //bool IsGregorianDate(GregorianAdoption country = Gr_Standard) const;
665 // ------------------------------------------------------------------------
666 // comparison (see also functions below for operator versions)
668 // returns TRUE if the two moments are strictly identical
669 inline bool IsEqualTo(const wxDateTime& datetime) const;
671 // returns TRUE if the date is strictly earlier than the given one
672 inline bool IsEarlierThan(const wxDateTime& datetime) const;
674 // returns TRUE if the date is strictly later than the given one
675 inline bool IsLaterThan(const wxDateTime& datetime) const;
677 // returns TRUE if the date is strictly in the given range
678 inline bool IsStrictlyBetween(const wxDateTime& t1,
679 const wxDateTime& t2) const;
681 // returns TRUE if the date is in the given range
682 inline bool IsBetween(const wxDateTime& t1, const wxDateTime& t2) const;
684 // do these two objects refer to the same date?
685 inline bool IsSameDate(const wxDateTime& dt) const;
687 // do these two objects have the same time?
688 inline bool IsSameTime(const wxDateTime& dt) const;
690 // are these two objects equal up to given timespan?
691 inline bool IsEqualUpTo(const wxDateTime& dt, const wxTimeSpan& ts) const;
694 // ------------------------------------------------------------------------
695 // arithmetics with dates (see also below for more operators)
697 // add a time span (positive or negative)
698 %name(AddTS) wxDateTime& Add(const wxTimeSpan& diff);
699 // add a date span (positive or negative)
700 %name(AddDS) wxDateTime& Add(const wxDateSpan& diff);
702 // subtract a time span (positive or negative)
703 %name(SubtractTS) wxDateTime& Subtract(const wxTimeSpan& diff);
705 // subtract a date span (positive or negative)
706 %name(SubtractDS) wxDateTime& Subtract(const wxDateSpan& diff);
708 // return the difference between two dates
709 wxTimeSpan Subtract(const wxDateTime& dt) const;
713 wxDateTime __add__TS(const wxTimeSpan& other) { return *self + other; }
714 wxDateTime __add__DS(const wxDateSpan& other) { return *self + other; }
716 wxTimeSpan __sub__DT(const wxDateTime& other) { return *self - other; }
717 wxDateTime __sub__TS(const wxTimeSpan& other) { return *self - other; }
718 wxDateTime __sub__DS(const wxDateSpan& other) { return *self - other; }
720 int __cmp__(const wxDateTime& other) {
721 if (*self < other) return -1;
722 if (*self == other) return 0;
727 %pragma(python) addtoclass = "
728 def __add__(self, other):
729 if string.find(other.this, 'wxTimeSpan') != -1:
730 return self.__add__TS(other)
731 if string.find(other.this, 'wxDateSpan') != -1:
732 return self.__add__DS(other)
733 raise TypeError, 'Invalid r.h.s. type for __add__'
734 def __sub__(self, other):
735 if string.find(other.this, 'wxDateTime') != -1:
736 return self.__sub__DT(other)
737 if string.find(other.this, 'wxTimeSpan') != -1:
738 return self.__sub__TS(other)
739 if string.find(other.this, 'wxDateSpan') != -1:
740 return self.__sub__DS(other)
741 raise TypeError, 'Invalid r.h.s. type for __sub__'
744 // ------------------------------------------------------------------------
745 // conversion to/from text: all conversions from text return the pointer to
746 // the next character following the date specification (i.e. the one where
747 // the scan had to stop) or NULL on failure.
749 // parse a string in RFC 822 format (found e.g. in mail headers and
750 // having the form "Wed, 10 Feb 1999 19:07:07 +0100")
751 const char *ParseRfc822Date(const char* date);
753 // parse a date/time in the given format (see strptime(3)), fill in
754 // the missing (in the string) fields with the values of dateDef (by
755 // default, they will not change if they had valid values or will
756 // default to Today() otherwise)
757 const char *ParseFormat(const char *date,
758 const char *format = "%c",
759 const wxDateTime& dateDef = wxDefaultDateTime);
761 // parse a string containing the date/time in "free" format, this
762 // function will try to make an educated guess at the string contents
763 const char *ParseDateTime(const char *datetime);
765 // parse a string containing the date only in "free" format (less
766 // flexible than ParseDateTime)
767 const char *ParseDate(const char *date);
769 // parse a string containing the time only in "free" format
770 const char *ParseTime(const char *time);
772 // this function accepts strftime()-like format string (default
773 // argument corresponds to the preferred date and time representation
774 // for the current locale) and returns the string containing the
775 // resulting text representation
776 wxString Format(const char *format = "%c",
777 const wxDateTime::TimeZone& tz = LOCAL) const;
779 // preferred date representation for the current locale
780 wxString FormatDate() const;
782 // preferred time representation for the current locale
783 wxString FormatTime() const;
785 // returns the string representing the date in ISO 8601 format
787 wxString FormatISODate() const;
789 // returns the string representing the time in ISO 8601 format
791 wxString FormatISOTime() const;
793 %pragma(python) addtoclass = "
795 return '<wxDateTime: \"%s\" at %s>' % ( self.Format(), self.this)
802 //---------------------------------------------------------------------------
803 //---------------------------------------------------------------------------
809 // return the timespan for the given number of seconds
810 static wxTimeSpan Seconds(long sec);
811 static wxTimeSpan Second();
813 // return the timespan for the given number of minutes
814 static wxTimeSpan Minutes(long min);
815 static wxTimeSpan Minute();
817 // return the timespan for the given number of hours
818 static wxTimeSpan Hours(long hours);
819 static wxTimeSpan Hour();
821 // return the timespan for the given number of days
822 static wxTimeSpan Days(long days);
823 static wxTimeSpan Day();
825 // return the timespan for the given number of weeks
826 static wxTimeSpan Weeks(long days);
827 static wxTimeSpan Week();
829 // ------------------------------------------------------------------------
832 // from separate values for each component, date set to 0 (hours are
833 // not restricted to 0..24 range, neither are minutes, seconds or
835 wxTimeSpan(long hours = 0,
838 long milliseconds = 0);
842 // ------------------------------------------------------------------------
843 // arithmetics with time spans
845 // add two timespans together
846 inline wxTimeSpan& Add(const wxTimeSpan& diff);
848 // subtract another timespan
849 inline wxTimeSpan& Subtract(const wxTimeSpan& diff);
851 // multiply timespan by a scalar
852 inline wxTimeSpan& Multiply(int n);
854 // negate the value of the timespan
857 // return the absolute value of the timespan: does _not_ modify the
859 inline wxTimeSpan Abs() const;
862 wxTimeSpan __add__(const wxTimeSpan& other) { return *self + other; }
863 wxTimeSpan __sub__(const wxTimeSpan& other) { return *self - other; }
864 wxTimeSpan __mul__(int n) { return *self * n; }
865 wxTimeSpan __rmul__(int n) { return n * *self; }
866 wxTimeSpan __neg__() { return self->Negate(); }
867 int __cmp__(const wxTimeSpan& other) {
868 if (*self < other) return -1;
869 if (*self == other) return 0;
874 // comparaison (see also operator versions below)
875 // ------------------------------------------------------------------------
877 // is the timespan null?
880 // is the timespan positive?
881 bool IsPositive() const;
883 // is the timespan negative?
884 bool IsNegative() const;
886 // are two timespans equal?
887 inline bool IsEqualTo(const wxTimeSpan& ts) const;
889 // compare two timestamps: works with the absolute values, i.e. -2
890 // hours is longer than 1 hour. Also, it will return FALSE if the
891 // timespans are equal in absolute value.
892 inline bool IsLongerThan(const wxTimeSpan& ts) const;
894 // compare two timestamps: works with the absolute values, i.e. 1
895 // hour is shorter than -2 hours. Also, it will return FALSE if the
896 // timespans are equal in absolute value.
897 bool IsShorterThan(const wxTimeSpan& t) const;
899 // ------------------------------------------------------------------------
900 // breaking into days, hours, minutes and seconds
902 // get the max number of weeks in this timespan
903 inline int GetWeeks() const;
904 // get the max number of days in this timespan
905 inline int GetDays() const;
906 // get the max number of hours in this timespan
907 inline int GetHours() const;
908 // get the max number of minutes in this timespan
909 inline int GetMinutes() const;
912 // get the max number of seconds in this timespan
913 inline wxLongLong GetSeconds() const;
914 // get the number of milliseconds in this timespan
915 wxLongLong GetMilliseconds() const;
917 // ------------------------------------------------------------------------
918 // conversion to text
920 // this function accepts strftime()-like format string (default
921 // argument corresponds to the preferred date and time representation
922 // for the current locale) and returns the string containing the
923 // resulting text representation. Notice that only some of format
924 // specifiers valid for wxDateTime are valid for wxTimeSpan: hours,
925 // minutes and seconds make sense, but not "PM/AM" string for example.
926 wxString Format(const char *format = "%c") const;
928 // // preferred date representation for the current locale
929 // wxString FormatDate() const;
931 // // preferred time representation for the current locale
932 // wxString FormatTime() const;
934 // %pragma(python) addtoclass = "
935 // def __repr__(self):
936 // return '<wxTimeSpan: \"%s\" at %s>' % ( self.Format(), self.this)
937 // def __str__(self):
938 // return self.Format()
943 //---------------------------------------------------------------------------
944 //---------------------------------------------------------------------------
949 // this many years/months/weeks/days
950 wxDateSpan(int years = 0, int months = 0, int weeks = 0, int days = 0)
960 // get an object for the given number of days
961 static wxDateSpan Days(int days);
962 static wxDateSpan Day();
964 // get an object for the given number of weeks
965 static wxDateSpan Weeks(int weeks);
966 static wxDateSpan Week();
968 // get an object for the given number of months
969 static wxDateSpan Months(int mon);
970 static wxDateSpan Month();
972 // get an object for the given number of years
973 static wxDateSpan Years(int years);
974 static wxDateSpan Year();
977 // ------------------------------------------------------------------------
979 // set number of years
980 wxDateSpan& SetYears(int n);
981 // set number of months
982 wxDateSpan& SetMonths(int n);
983 // set number of weeks
984 wxDateSpan& SetWeeks(int n);
985 // set number of days
986 wxDateSpan& SetDays(int n);
988 // get number of years
989 int GetYears() const;
990 // get number of months
991 int GetMonths() const;
992 // get number of weeks
993 int GetWeeks() const;
994 // get number of days
996 // returns 7*GetWeeks() + GetDays()
997 int GetTotalDays() const;
1000 // ------------------------------------------------------------------------
1002 // add another wxDateSpan to us
1003 inline wxDateSpan& Add(const wxDateSpan& other);
1005 // subtract another wxDateSpan from us
1006 inline wxDateSpan& Subtract(const wxDateSpan& other);
1008 // inverse the sign of this timespan
1009 inline wxDateSpan& Neg();
1011 // multiply all components by a (signed) number
1012 inline wxDateSpan& Multiply(int factor);
1015 wxDateSpan __add__(const wxDateSpan& other) { return *self + other; }
1016 wxDateSpan __sub__(const wxDateSpan& other) { return *self - other; }
1017 wxDateSpan __mul__(int n) { return *self * n; }
1018 wxDateSpan __rmul__(int n) { return n * *self; }
1019 wxDateSpan __neg__() { return self->Negate(); }
1024 //---------------------------------------------------------------------------
1026 long wxGetLocalTime();
1027 long wxGetUTCTime();
1028 long wxGetCurrentTime();
1029 wxLongLong wxGetLocalTimeMillis();
1031 //---------------------------------------------------------------------------
1032 //---------------------------------------------------------------------------
1035 wxClassInfo::CleanUpClasses();
1036 wxClassInfo::InitializeClasses();
1039 //---------------------------------------------------------------------------