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));
42 PyTuple_SET_ITEM(ret, 1, PyUnicode_FromUnicode(str.c_str(), str.Len()));
44 PyTuple_SET_ITEM(ret, 1, PyString_FromStringAndSize(str.c_str(), str.Len()));
46 PyTuple_SET_ITEM(ret, 2, PyInt_FromLong(index));
52 //---------------------------------------------------------------------------
56 wxCONFIG_USE_LOCAL_FILE = 1,
57 wxCONFIG_USE_GLOBAL_FILE = 2,
58 wxCONFIG_USE_RELATIVE_PATH = 4
61 //---------------------------------------------------------------------------
65 // wxConfigBase(const wxString& appName = wxEmptyString, **** An ABC
66 // const wxString& vendorName = wxEmptyString,
67 // const wxString& localFilename = wxEmptyString,
68 // const wxString& globalFilename = wxEmptyString,
77 Type_Integer, // use Read(long *)
78 Type_Float // use Read(double *)
82 // sets the config object, returns the previous pointer
83 static wxConfigBase *Set(wxConfigBase *pConfig);
84 // get the config object, creates it on demand unless DontCreateOnDemand
86 static wxConfigBase *Get(bool createOnDemand = TRUE);
87 // create a new config object: this function will create the "best"
88 // implementation of wxConfig available for the current platform, see
89 // comments near definition wxUSE_CONFIG_NATIVE for details. It returns
90 // the created object and also sets it as ms_pConfig.
91 static wxConfigBase *Create();
92 // should Get() try to create a new log object if the current one is NULL?
93 static void DontCreateOnDemand();
97 bool DeleteAll(); // This is supposed to have been fixed...
98 bool DeleteEntry(const wxString& key, bool bDeleteGroupIfEmpty = TRUE);
99 bool DeleteGroup(const wxString& key);
100 bool Exists(wxString& strName);
101 bool Flush(bool bCurrentOnly = FALSE);
102 wxString GetAppName();
105 // Each of these enumeration methods return a 3-tuple consisting of
106 // the continue flag, the value string, and the index for the next call.
108 PyObject* GetFirstGroup() {
113 cont = self->GetFirstGroup(value, index);
114 return __EnumerationHelper(cont, value, index);
117 PyObject* GetFirstEntry() {
122 cont = self->GetFirstEntry(value, index);
123 return __EnumerationHelper(cont, value, index);
126 PyObject* GetNextGroup(long index) {
130 cont = self->GetNextGroup(value, index);
131 return __EnumerationHelper(cont, value, index);
134 PyObject* GetNextEntry(long index) {
138 cont = self->GetNextEntry(value, index);
139 return __EnumerationHelper(cont, value, index);
144 int GetNumberOfEntries(bool bRecursive = FALSE);
145 int GetNumberOfGroups(bool bRecursive = FALSE);
147 wxString GetVendorName();
148 bool HasEntry(wxString& strName);
149 bool HasGroup(const wxString& strName);
150 bool IsExpandingEnvVars();
151 bool IsRecordingDefaults();
153 wxString Read(const wxString& key, const wxString& defaultVal = wxEmptyString);
156 long ReadInt(const wxString& key, long defaultVal = 0) {
158 self->Read(key, &rv, defaultVal);
161 double ReadFloat(const wxString& key, double defaultVal = 0.0) {
163 self->Read(key, &rv, defaultVal);
166 bool ReadBool(const wxString& key, bool defaultVal = FALSE) {
168 self->Read(key, &rv, defaultVal);
173 void SetExpandEnvVars (bool bDoIt = TRUE);
174 void SetPath(const wxString& strPath);
175 void SetRecordDefaults(bool bDoIt = TRUE);
176 void SetAppName(const wxString& appName);
177 void SetVendorName(const wxString& vendorName);
179 void SetStyle(long style);
182 bool Write(const wxString& key, const wxString& value);
183 %name(WriteInt)bool Write(const wxString& key, long value);
184 %name(WriteFloat)bool Write(const wxString& key, double value);
185 %name(WriteBool)bool Write(const wxString& key, bool value);
187 EntryType GetEntryType(const wxString& name);
188 bool RenameEntry(const wxString& oldName,
189 const wxString& newName);
190 bool RenameGroup(const wxString& oldName,
191 const wxString& newName);
192 wxString ExpandEnvVars(const wxString& str);
198 //---------------------------------------------------------------------------
200 // This will be a wxRegConfig on Win32 and wxFileConfig otherwise.
201 class wxConfig : public wxConfigBase {
203 wxConfig(const wxString& appName = wxEmptyString,
204 const wxString& vendorName = wxEmptyString,
205 const wxString& localFilename = wxEmptyString,
206 const wxString& globalFilename = wxEmptyString,
212 // Sometimes it's nice to explicitly have a wxFileConfig too.
213 class wxFileConfig : public wxConfigBase {
215 wxFileConfig(const wxString& appName = wxEmptyString,
216 const wxString& vendorName = wxEmptyString,
217 const wxString& localFilename = wxEmptyString,
218 const wxString& globalFilename = wxEmptyString,
224 //---------------------------------------------------------------------------
225 //---------------------------------------------------------------------------
232 %typemap(python,in) wxDateTime::TimeZone& {
233 $target = new wxDateTime::TimeZone((wxDateTime::TZ)PyInt_AsLong($source));
235 %typemap(python,freearg) wxDateTime::TimeZone& {
236 if ($source) delete $source;
240 #define LOCAL *(new wxDateTime::TimeZone(wxDateTime::Local))
244 %typemap(python, out) wxLongLong {
245 PyObject *hi, *lo, *shifter, *shifted;
246 hi = PyLong_FromLong($source->GetHi());
247 lo = PyLong_FromLong($source->GetLo());
248 shifter = PyLong_FromLong(32);
249 shifted = PyNumber_Lshift(hi, shifter);
250 $target = PyNumber_Or(shifted, lo);
262 typedef unsigned short wxDateTime_t;
268 GMT_12, GMT_11, GMT_10, GMT_9, GMT_8, GMT_7,
269 GMT_6, GMT_5, GMT_4, GMT_3, GMT_2, GMT_1,
271 GMT1, GMT2, GMT3, GMT4, GMT5, GMT6,
272 GMT7, GMT8, GMT9, GMT10, GMT11, GMT12,
275 WET = GMT0, // Western Europe Time
276 WEST = GMT1, // Western Europe Summer Time
277 CET = GMT1, // Central Europe Time
278 CEST = GMT2, // Central Europe Summer Time
279 EET = GMT2, // Eastern Europe Time
280 EEST = GMT3, // Eastern Europe Summer Time
281 MSK = GMT3, // Moscow Time
282 MSD = GMT4, // Moscow Summer Time
285 AST = GMT_4, // Atlantic Standard Time
286 ADT = GMT_3, // Atlantic Daylight Time
287 EST = GMT_5, // Eastern Standard Time
288 EDT = GMT_4, // Eastern Daylight Saving Time
289 CST = GMT_6, // Central Standard Time
290 CDT = GMT_5, // Central Daylight Saving Time
291 MST = GMT_7, // Mountain Standard Time
292 MDT = GMT_6, // Mountain Daylight Saving Time
293 PST = GMT_8, // Pacific Standard Time
294 PDT = GMT_7, // Pacific Daylight Saving Time
295 HST = GMT_10, // Hawaiian Standard Time
296 AKST = GMT_9, // Alaska Standard Time
297 AKDT = GMT_8, // Alaska Daylight Saving Time
301 A_WST = GMT8, // Western Standard Time
302 A_CST = GMT12 + 1, // Central Standard Time (+9.5)
303 A_EST = GMT10, // Eastern Standard Time
304 A_ESST = GMT11, // Eastern Summer Time
306 // Universal Coordinated Time = the new and politically correct name
313 Gregorian, // current calendar
314 Julian // calendar in use since -45 until the 1582 (or later)
319 Country_Unknown, // no special information for this country
320 Country_Default, // set the default country with SetCountry() method
321 // or use the default country with any other
323 // Western European countries: we assume that they all follow the same
324 // DST rules (true or false?)
325 Country_WesternEurope_Start,
326 Country_EEC = Country_WesternEurope_Start,
330 Country_WesternEurope_End = UK,
337 // symbolic names for the months
340 Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, Inv_Month
343 // symbolic names for the weekdays
346 Sun, Mon, Tue, Wed, Thu, Fri, Sat, Inv_WeekDay
349 // invalid value for the year
352 Inv_Year = SHRT_MIN // should hold in wxDateTime_t
355 // flags for GetWeekDayName and GetMonthName
358 Name_Full = 0x01, // return full name
359 Name_Abbr = 0x02 // return abbreviated name
362 // flags for GetWeekOfYear and GetWeekOfMonth
365 Default_First, // Sunday_First for US, Monday_First for the rest
366 Monday_First, // week starts with a Monday
367 Sunday_First // week starts with a Sunday
372 // ------------------------------------------------------------------------
374 // set the current country
375 static void SetCountry(Country country);
376 // get the current country
377 static Country GetCountry();
379 // return TRUE if the country is a West European one (in practice,
380 // this means that the same DST rules as for EEC apply)
381 static bool IsWestEuropeanCountry(Country country = Country_Default);
383 // return the current year
384 static int GetCurrentYear(Calendar cal = Gregorian);
386 // convert the year as returned by wxDateTime::GetYear() to a year
387 // suitable for BC/AD notation. The difference is that BC year 1
388 // corresponds to the year 0 (while BC year 0 didn't exist) and AD
389 // year N is just year N.
390 static int ConvertYearToBC(int year);
392 // return the current month
393 static Month GetCurrentMonth(Calendar cal = Gregorian);
395 // returns TRUE if the given year is a leap year in the given calendar
396 static bool IsLeapYear(int year = Inv_Year, Calendar cal = Gregorian);
398 // get the century (19 for 1999, 20 for 2000 and -5 for 492 BC)
399 static int GetCentury(int year = Inv_Year);
401 // returns the number of days in this year (356 or 355 for Gregorian
402 // calendar usually :-)
403 %name(GetNumberOfDaysinYear)
404 static wxDateTime_t GetNumberOfDays(int year, Calendar cal = Gregorian);
406 // get the number of the days in the given month (default value for
407 // the year means the current one)
408 %name(GetNumberOfDaysInMonth)
409 static wxDateTime_t GetNumberOfDays(Month month,
411 Calendar cal = Gregorian);
413 // get the full (default) or abbreviated month name in the current
414 // locale, returns empty string on error
415 static wxString GetMonthName(Month month,
416 NameFlags flags = Name_Full);
418 // get the full (default) or abbreviated weekday name in the current
419 // locale, returns empty string on error
420 static wxString GetWeekDayName(WeekDay weekday,
421 NameFlags flags = Name_Full);
423 // get the AM and PM strings in the current locale (may be empty)
424 static void GetAmPmStrings(wxString *OUTPUT, wxString *OUTPUT);
426 // return TRUE if the given country uses DST for this year
427 static bool IsDSTApplicable(int year = Inv_Year,
428 Country country = Country_Default);
430 // get the beginning of DST for this year, will return invalid object
431 // if no DST applicable in this year. The default value of the
432 // parameter means to take the current year.
433 static wxDateTime GetBeginDST(int year = Inv_Year,
434 Country country = Country_Default);
435 // get the end of DST for this year, will return invalid object
436 // if no DST applicable in this year. The default value of the
437 // parameter means to take the current year.
438 static wxDateTime GetEndDST(int year = Inv_Year,
439 Country country = Country_Default);
441 // return the wxDateTime object for the current time
442 static inline wxDateTime Now();
444 // return the wxDateTime object for today midnight: i.e. as Now() but
445 // with time set to 0
446 static inline wxDateTime Today();
450 // ------------------------------------------------------------------------
454 %name(wxDateTimeFromTimeT)wxDateTime(time_t timet);
455 %name(wxDateTimeFromJDN)wxDateTime(double jdn);
456 %name(wxDateTimeFromHMS)wxDateTime(wxDateTime_t hour,
457 wxDateTime_t minute = 0,
458 wxDateTime_t second = 0,
459 wxDateTime_t millisec = 0);
460 %name(wxDateTimeFromDMY)wxDateTime(wxDateTime_t day,
461 Month month = Inv_Month,
463 wxDateTime_t hour = 0,
464 wxDateTime_t minute = 0,
465 wxDateTime_t second = 0,
466 wxDateTime_t millisec = 0);
470 // ------------------------------------------------------------------------
473 wxDateTime& SetToCurrent();
475 // set to given time_t value
476 %name(SetTimeT)wxDateTime& Set(time_t timet);
478 // set to given JDN (beware of rounding errors)
479 %name(SetJDN)wxDateTime& Set(double jdn);
481 // set to given time, date = today
482 %name(SetHMS)wxDateTime& Set(wxDateTime_t hour,
483 wxDateTime_t minute = 0,
484 wxDateTime_t second = 0,
485 wxDateTime_t millisec = 0);
487 // from separate values for each component with explicit date
488 // (defaults for month and year are the current values)
489 wxDateTime& Set(wxDateTime_t day,
490 Month month = Inv_Month,
491 int year = Inv_Year, // 1999, not 99 please!
492 wxDateTime_t hour = 0,
493 wxDateTime_t minute = 0,
494 wxDateTime_t second = 0,
495 wxDateTime_t millisec = 0);
497 // resets time to 00:00:00, doesn't change the date
498 wxDateTime& ResetTime();
500 // the following functions don't change the values of the other
501 // fields, i.e. SetMinute() won't change either hour or seconds value
504 wxDateTime& SetYear(int year);
506 wxDateTime& SetMonth(Month month);
507 // set the day of the month
508 wxDateTime& SetDay(wxDateTime_t day);
510 wxDateTime& SetHour(wxDateTime_t hour);
512 wxDateTime& SetMinute(wxDateTime_t minute);
514 wxDateTime& SetSecond(wxDateTime_t second);
516 wxDateTime& SetMillisecond(wxDateTime_t millisecond);
519 // ------------------------------------------------------------------------
520 // calendar calculations
522 // set to the given week day in the same week as this one
523 wxDateTime& SetToWeekDayInSameWeek(WeekDay weekday);
524 wxDateTime GetWeekDayInSameWeek(WeekDay weekday);
526 // set to the next week day following this one
527 wxDateTime& SetToNextWeekDay(WeekDay weekday);
528 wxDateTime GetNextWeekDay(WeekDay weekday);
530 // set to the previous week day before this one
531 wxDateTime& SetToPrevWeekDay(WeekDay weekday);
532 wxDateTime GetPrevWeekDay(WeekDay weekday);
534 // set to Nth occurence of given weekday in the given month of the
535 // given year (time is set to 0), return TRUE on success and FALSE on
536 // failure. n may be positive (1..5) or negative to count from the end
537 // of the month (see helper function SetToLastWeekDay())
538 bool SetToWeekDay(WeekDay weekday,
540 Month month = Inv_Month,
541 int year = Inv_Year);
542 // wxDateTime GetWeekDay(WeekDay weekday,
544 // Month month = Inv_Month,
545 // int year = Inv_Year);
547 // sets to the last weekday in the given month, year
548 bool SetToLastWeekDay(WeekDay weekday,
549 Month month = Inv_Month,
550 int year = Inv_Year);
551 wxDateTime GetLastWeekDay(WeekDay weekday,
552 Month month = Inv_Month,
553 int year = Inv_Year);
555 // sets the date to the given day of the given week in the year,
556 // returns TRUE on success and FALSE if given date doesn't exist (e.g.
558 bool SetToTheWeek(wxDateTime_t numWeek, WeekDay weekday = Mon);
559 wxDateTime GetWeek(wxDateTime_t numWeek, WeekDay weekday = Mon);
561 // sets the date to the last day of the given (or current) month or the
562 // given (or current) year
563 wxDateTime& SetToLastMonthDay(Month month = Inv_Month,
564 int year = Inv_Year);
565 wxDateTime GetLastMonthDay(Month month = Inv_Month,
566 int year = Inv_Year);
568 // sets to the given year day (1..365 or 366)
569 wxDateTime& SetToYearDay(wxDateTime_t yday);
570 wxDateTime GetYearDay(wxDateTime_t yday);
572 // The definitions below were taken verbatim from
574 // http://www.capecod.net/~pbaum/date/date0.htm
576 // (Peter Baum's home page)
578 // definition: The Julian Day Number, Julian Day, or JD of a
579 // particular instant of time is the number of days and fractions of a
580 // day since 12 hours Universal Time (Greenwich mean noon) on January
581 // 1 of the year -4712, where the year is given in the Julian
582 // proleptic calendar. The idea of using this reference date was
583 // originally proposed by Joseph Scalizer in 1582 to count years but
584 // it was modified by 19th century astronomers to count days. One
585 // could have equivalently defined the reference time to be noon of
586 // November 24, -4713 if were understood that Gregorian calendar rules
587 // were applied. Julian days are Julian Day Numbers and are not to be
588 // confused with Julian dates.
590 // definition: The Rata Die number is a date specified as the number
591 // of days relative to a base date of December 31 of the year 0. Thus
592 // January 1 of the year 1 is Rata Die day 1.
594 // get the Julian Day number (the fractional part specifies the time of
595 // the day, related to noon - beware of rounding errors!)
596 double GetJulianDayNumber();
599 // get the Modified Julian Day number: it is equal to JDN - 2400000.5
600 // and so integral MJDs correspond to the midnights (and not noons).
601 // MJD 0 is Nov 17, 1858
602 double GetModifiedJulianDayNumber() const { return GetJDN() - 2400000.5; }
605 // get the Rata Die number
609 // ------------------------------------------------------------------------
612 // transform to any given timezone
613 wxDateTime ToTimezone(const wxDateTime::TimeZone& tz, bool noDST = FALSE);
614 wxDateTime& MakeTimezone(const wxDateTime::TimeZone& tz, bool noDST = FALSE);
616 // transform to GMT/UTC
617 wxDateTime ToGMT(bool noDST = FALSE);
618 wxDateTime& MakeGMT(bool noDST = FALSE);
620 // is daylight savings time in effect at this moment according to the
621 // rules of the specified country?
623 // Return value is > 0 if DST is in effect, 0 if it is not and -1 if
624 // the information is not available (this is compatible with ANSI C)
625 int IsDST(Country country = Country_Default);
629 // ------------------------------------------------------------------------
632 // is the date valid (TRUE even for non initialized objects)?
633 inline bool IsValid() const;
635 // get the number of seconds since the Unix epoch - returns (time_t)-1
636 // if the value is out of range
637 inline time_t GetTicks() const;
639 // get the year (returns Inv_Year if date is invalid)
640 int GetYear(const wxDateTime::TimeZone& tz = LOCAL) const;
642 // get the month (Inv_Month if date is invalid)
643 Month GetMonth(const wxDateTime::TimeZone& tz = LOCAL) const;
645 // get the month day (in 1..31 range, 0 if date is invalid)
646 wxDateTime_t GetDay(const wxDateTime::TimeZone& tz = LOCAL) const;
648 // get the day of the week (Inv_WeekDay if date is invalid)
649 WeekDay GetWeekDay(const wxDateTime::TimeZone& tz = LOCAL) const;
651 // get the hour of the day
652 wxDateTime_t GetHour(const wxDateTime::TimeZone& tz = LOCAL) const;
655 wxDateTime_t GetMinute(const wxDateTime::TimeZone& tz = LOCAL) const;
658 wxDateTime_t GetSecond(const wxDateTime::TimeZone& tz = LOCAL) const;
661 wxDateTime_t GetMillisecond(const wxDateTime::TimeZone& tz = LOCAL) const;
664 // get the day since the year start (1..366, 0 if date is invalid)
665 wxDateTime_t GetDayOfYear(const wxDateTime::TimeZone& tz = LOCAL) const;
666 // get the week number since the year start (1..52 or 53, 0 if date is
668 wxDateTime_t GetWeekOfYear(WeekFlags flags = Monday_First,
669 const wxDateTime::TimeZone& tz = LOCAL) const;
670 // get the week number since the month start (1..5, 0 if date is
672 wxDateTime_t GetWeekOfMonth(WeekFlags flags = Monday_First,
673 const wxDateTime::TimeZone& tz = LOCAL) const;
675 // is this date a work day? This depends on a country, of course,
676 // because the holidays are different in different countries
677 bool IsWorkDay(Country country = Country_Default) const;
679 // is this date later than Gregorian calendar introduction for the
680 // given country (see enum GregorianAdoption)?
682 // NB: this function shouldn't be considered as absolute authority in
683 // the matter. Besides, for some countries the exact date of
684 // adoption of the Gregorian calendar is simply unknown.
685 //bool IsGregorianDate(GregorianAdoption country = Gr_Standard) const;
688 // ------------------------------------------------------------------------
689 // comparison (see also functions below for operator versions)
691 // returns TRUE if the two moments are strictly identical
692 inline bool IsEqualTo(const wxDateTime& datetime) const;
694 // returns TRUE if the date is strictly earlier than the given one
695 inline bool IsEarlierThan(const wxDateTime& datetime) const;
697 // returns TRUE if the date is strictly later than the given one
698 inline bool IsLaterThan(const wxDateTime& datetime) const;
700 // returns TRUE if the date is strictly in the given range
701 inline bool IsStrictlyBetween(const wxDateTime& t1,
702 const wxDateTime& t2) const;
704 // returns TRUE if the date is in the given range
705 inline bool IsBetween(const wxDateTime& t1, const wxDateTime& t2) const;
707 // do these two objects refer to the same date?
708 inline bool IsSameDate(const wxDateTime& dt) const;
710 // do these two objects have the same time?
711 inline bool IsSameTime(const wxDateTime& dt) const;
713 // are these two objects equal up to given timespan?
714 inline bool IsEqualUpTo(const wxDateTime& dt, const wxTimeSpan& ts) const;
717 // ------------------------------------------------------------------------
718 // arithmetics with dates (see also below for more operators)
720 // add a time span (positive or negative)
721 %name(AddTS) wxDateTime& Add(const wxTimeSpan& diff);
722 // add a date span (positive or negative)
723 %name(AddDS) wxDateTime& Add(const wxDateSpan& diff);
725 // subtract a time span (positive or negative)
726 %name(SubtractTS) wxDateTime& Subtract(const wxTimeSpan& diff);
728 // subtract a date span (positive or negative)
729 %name(SubtractDS) wxDateTime& Subtract(const wxDateSpan& diff);
731 // return the difference between two dates
732 wxTimeSpan Subtract(const wxDateTime& dt) const;
736 wxDateTime __add__TS(const wxTimeSpan& other) { return *self + other; }
737 wxDateTime __add__DS(const wxDateSpan& other) { return *self + other; }
739 wxTimeSpan __sub__DT(const wxDateTime& other) { return *self - other; }
740 wxDateTime __sub__TS(const wxTimeSpan& other) { return *self - other; }
741 wxDateTime __sub__DS(const wxDateSpan& other) { return *self - other; }
743 int __cmp__(const wxDateTime& other) {
744 if (*self < other) return -1;
745 if (*self == other) return 0;
750 %pragma(python) addtoclass = "
751 def __add__(self, other):
752 if string.find(other.this, 'wxTimeSpan') != -1:
753 return self.__add__TS(other)
754 if string.find(other.this, 'wxDateSpan') != -1:
755 return self.__add__DS(other)
756 raise TypeError, 'Invalid r.h.s. type for __add__'
757 def __sub__(self, other):
758 if string.find(other.this, 'wxDateTime') != -1:
759 return self.__sub__DT(other)
760 if string.find(other.this, 'wxTimeSpan') != -1:
761 return self.__sub__TS(other)
762 if string.find(other.this, 'wxDateSpan') != -1:
763 return self.__sub__DS(other)
764 raise TypeError, 'Invalid r.h.s. type for __sub__'
767 // ------------------------------------------------------------------------
768 // conversion to/from text: all conversions from text return the pointer to
769 // the next character following the date specification (i.e. the one where
770 // the scan had to stop) or NULL on failure.
772 // parse a string in RFC 822 format (found e.g. in mail headers and
773 // having the form "Wed, 10 Feb 1999 19:07:07 +0100")
774 const char *ParseRfc822Date(const wxChar* date);
776 // parse a date/time in the given format (see strptime(3)), fill in
777 // the missing (in the string) fields with the values of dateDef (by
778 // default, they will not change if they had valid values or will
779 // default to Today() otherwise)
780 const char *ParseFormat(const wxChar *date,
781 const wxChar *format = "%c",
782 const wxDateTime& dateDef = wxDefaultDateTime);
784 // parse a string containing the date/time in "free" format, this
785 // function will try to make an educated guess at the string contents
786 const char *ParseDateTime(const wxChar *datetime);
788 // parse a string containing the date only in "free" format (less
789 // flexible than ParseDateTime)
790 const char *ParseDate(const wxChar *date);
792 // parse a string containing the time only in "free" format
793 const char *ParseTime(const wxChar *time);
795 // this function accepts strftime()-like format string (default
796 // argument corresponds to the preferred date and time representation
797 // for the current locale) and returns the string containing the
798 // resulting text representation
799 wxString Format(const wxChar *format = "%c",
800 const wxDateTime::TimeZone& tz = LOCAL) const;
802 // preferred date representation for the current locale
803 wxString FormatDate() const;
805 // preferred time representation for the current locale
806 wxString FormatTime() const;
808 // returns the string representing the date in ISO 8601 format
810 wxString FormatISODate() const;
812 // returns the string representing the time in ISO 8601 format
814 wxString FormatISOTime() const;
816 %pragma(python) addtoclass = "
818 return '<wxDateTime: \"%s\" at %s>' % ( self.Format(), self.this)
825 //---------------------------------------------------------------------------
826 //---------------------------------------------------------------------------
832 // return the timespan for the given number of seconds
833 static wxTimeSpan Seconds(long sec);
834 static wxTimeSpan Second();
836 // return the timespan for the given number of minutes
837 static wxTimeSpan Minutes(long min);
838 static wxTimeSpan Minute();
840 // return the timespan for the given number of hours
841 static wxTimeSpan Hours(long hours);
842 static wxTimeSpan Hour();
844 // return the timespan for the given number of days
845 static wxTimeSpan Days(long days);
846 static wxTimeSpan Day();
848 // return the timespan for the given number of weeks
849 static wxTimeSpan Weeks(long days);
850 static wxTimeSpan Week();
852 // ------------------------------------------------------------------------
855 // from separate values for each component, date set to 0 (hours are
856 // not restricted to 0..24 range, neither are minutes, seconds or
858 wxTimeSpan(long hours = 0,
861 long milliseconds = 0);
865 // ------------------------------------------------------------------------
866 // arithmetics with time spans
868 // add two timespans together
869 inline wxTimeSpan& Add(const wxTimeSpan& diff);
871 // subtract another timespan
872 inline wxTimeSpan& Subtract(const wxTimeSpan& diff);
874 // multiply timespan by a scalar
875 inline wxTimeSpan& Multiply(int n);
877 // negate the value of the timespan
880 // return the absolute value of the timespan: does _not_ modify the
882 inline wxTimeSpan Abs() const;
885 wxTimeSpan __add__(const wxTimeSpan& other) { return *self + other; }
886 wxTimeSpan __sub__(const wxTimeSpan& other) { return *self - other; }
887 wxTimeSpan __mul__(int n) { return *self * n; }
888 wxTimeSpan __rmul__(int n) { return n * *self; }
889 wxTimeSpan __neg__() { return self->Negate(); }
890 int __cmp__(const wxTimeSpan& other) {
891 if (*self < other) return -1;
892 if (*self == other) return 0;
897 // comparaison (see also operator versions below)
898 // ------------------------------------------------------------------------
900 // is the timespan null?
903 // is the timespan positive?
904 bool IsPositive() const;
906 // is the timespan negative?
907 bool IsNegative() const;
909 // are two timespans equal?
910 inline bool IsEqualTo(const wxTimeSpan& ts) const;
912 // compare two timestamps: works with the absolute values, i.e. -2
913 // hours is longer than 1 hour. Also, it will return FALSE if the
914 // timespans are equal in absolute value.
915 inline bool IsLongerThan(const wxTimeSpan& ts) const;
917 // compare two timestamps: works with the absolute values, i.e. 1
918 // hour is shorter than -2 hours. Also, it will return FALSE if the
919 // timespans are equal in absolute value.
920 bool IsShorterThan(const wxTimeSpan& t) const;
922 // ------------------------------------------------------------------------
923 // breaking into days, hours, minutes and seconds
925 // get the max number of weeks in this timespan
926 inline int GetWeeks() const;
927 // get the max number of days in this timespan
928 inline int GetDays() const;
929 // get the max number of hours in this timespan
930 inline int GetHours() const;
931 // get the max number of minutes in this timespan
932 inline int GetMinutes() const;
935 // get the max number of seconds in this timespan
936 inline wxLongLong GetSeconds() const;
937 // get the number of milliseconds in this timespan
938 wxLongLong GetMilliseconds() const;
940 // ------------------------------------------------------------------------
941 // conversion to text
943 // this function accepts strftime()-like format string (default
944 // argument corresponds to the preferred date and time representation
945 // for the current locale) and returns the string containing the
946 // resulting text representation. Notice that only some of format
947 // specifiers valid for wxDateTime are valid for wxTimeSpan: hours,
948 // minutes and seconds make sense, but not "PM/AM" string for example.
949 wxString Format(const wxChar *format = "%c") const;
951 // // preferred date representation for the current locale
952 // wxString FormatDate() const;
954 // // preferred time representation for the current locale
955 // wxString FormatTime() const;
957 // %pragma(python) addtoclass = "
958 // def __repr__(self):
959 // return '<wxTimeSpan: \"%s\" at %s>' % ( self.Format(), self.this)
960 // def __str__(self):
961 // return self.Format()
966 //---------------------------------------------------------------------------
967 //---------------------------------------------------------------------------
972 // this many years/months/weeks/days
973 wxDateSpan(int years = 0, int months = 0, int weeks = 0, int days = 0)
983 // get an object for the given number of days
984 static wxDateSpan Days(int days);
985 static wxDateSpan Day();
987 // get an object for the given number of weeks
988 static wxDateSpan Weeks(int weeks);
989 static wxDateSpan Week();
991 // get an object for the given number of months
992 static wxDateSpan Months(int mon);
993 static wxDateSpan Month();
995 // get an object for the given number of years
996 static wxDateSpan Years(int years);
997 static wxDateSpan Year();
1000 // ------------------------------------------------------------------------
1002 // set number of years
1003 wxDateSpan& SetYears(int n);
1004 // set number of months
1005 wxDateSpan& SetMonths(int n);
1006 // set number of weeks
1007 wxDateSpan& SetWeeks(int n);
1008 // set number of days
1009 wxDateSpan& SetDays(int n);
1011 // get number of years
1012 int GetYears() const;
1013 // get number of months
1014 int GetMonths() const;
1015 // get number of weeks
1016 int GetWeeks() const;
1017 // get number of days
1018 int GetDays() const;
1019 // returns 7*GetWeeks() + GetDays()
1020 int GetTotalDays() const;
1023 // ------------------------------------------------------------------------
1025 // add another wxDateSpan to us
1026 inline wxDateSpan& Add(const wxDateSpan& other);
1028 // subtract another wxDateSpan from us
1029 inline wxDateSpan& Subtract(const wxDateSpan& other);
1031 // inverse the sign of this timespan
1032 inline wxDateSpan& Neg();
1034 // multiply all components by a (signed) number
1035 inline wxDateSpan& Multiply(int factor);
1038 wxDateSpan __add__(const wxDateSpan& other) { return *self + other; }
1039 wxDateSpan __sub__(const wxDateSpan& other) { return *self - other; }
1040 wxDateSpan __mul__(int n) { return *self * n; }
1041 wxDateSpan __rmul__(int n) { return n * *self; }
1042 wxDateSpan __neg__() { return self->Negate(); }
1047 //---------------------------------------------------------------------------
1049 long wxGetLocalTime();
1050 long wxGetUTCTime();
1051 long wxGetCurrentTime();
1052 wxLongLong wxGetLocalTimeMillis();
1054 //---------------------------------------------------------------------------
1055 //---------------------------------------------------------------------------
1058 wxClassInfo::CleanUpClasses();
1059 wxClassInfo::InitializeClasses();
1062 //---------------------------------------------------------------------------