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);
154 long ReadInt(const wxString& key, long defaultVal = 0) {
156 self->Read(key, &rv, defaultVal);
159 double ReadFloat(const wxString& key, double defaultVal = 0.0) {
161 self->Read(key, &rv, defaultVal);
164 bool ReadBool(const wxString& key, bool defaultVal = FALSE) {
166 self->Read(key, &rv, defaultVal);
171 void SetExpandEnvVars (bool bDoIt = TRUE);
172 void SetPath(const wxString& strPath);
173 void SetRecordDefaults(bool bDoIt = TRUE);
174 void SetAppName(const wxString& appName);
175 void SetVendorName(const wxString& vendorName);
177 void SetStyle(long style);
180 bool Write(const wxString& key, const wxString& value);
181 %name(WriteInt)bool Write(const wxString& key, long value);
182 %name(WriteFloat)bool Write(const wxString& key, double value);
183 %name(WriteBool)bool Write(const wxString& key, bool value);
185 EntryType GetEntryType(const wxString& name);
186 bool RenameEntry(const wxString& oldName,
187 const wxString& newName);
188 bool RenameGroup(const wxString& oldName,
189 const wxString& newName);
190 wxString ExpandEnvVars(const wxString& str);
196 //---------------------------------------------------------------------------
198 // This will be a wxRegConfig on Win32 and wxFileConfig otherwise.
199 class wxConfig : public wxConfigBase {
201 wxConfig(const wxString& appName = wxPyEmptyStr,
202 const wxString& vendorName = wxPyEmptyStr,
203 const wxString& localFilename = wxPyEmptyStr,
204 const wxString& globalFilename = wxPyEmptyStr,
210 // Sometimes it's nice to explicitly have a wxFileConfig too.
211 class wxFileConfig : public wxConfigBase {
213 wxFileConfig(const wxString& appName = wxPyEmptyStr,
214 const wxString& vendorName = wxPyEmptyStr,
215 const wxString& localFilename = wxPyEmptyStr,
216 const wxString& globalFilename = wxPyEmptyStr,
222 //---------------------------------------------------------------------------
223 //---------------------------------------------------------------------------
230 %typemap(python,in) wxDateTime::TimeZone& {
231 $target = new wxDateTime::TimeZone((wxDateTime::TZ)PyInt_AsLong($source));
233 %typemap(python,freearg) wxDateTime::TimeZone& {
234 if ($source) delete $source;
238 #define LOCAL *(new wxDateTime::TimeZone(wxDateTime::Local))
242 %typemap(python, out) wxLongLong {
243 PyObject *hi, *lo, *shifter, *shifted;
244 hi = PyLong_FromLong($source->GetHi());
245 lo = PyLong_FromLong($source->GetLo());
246 shifter = PyLong_FromLong(32);
247 shifted = PyNumber_Lshift(hi, shifter);
248 $target = PyNumber_Or(shifted, lo);
260 typedef unsigned short wxDateTime_t;
266 GMT_12, GMT_11, GMT_10, GMT_9, GMT_8, GMT_7,
267 GMT_6, GMT_5, GMT_4, GMT_3, GMT_2, GMT_1,
269 GMT1, GMT2, GMT3, GMT4, GMT5, GMT6,
270 GMT7, GMT8, GMT9, GMT10, GMT11, GMT12,
273 WET = GMT0, // Western Europe Time
274 WEST = GMT1, // Western Europe Summer Time
275 CET = GMT1, // Central Europe Time
276 CEST = GMT2, // Central Europe Summer Time
277 EET = GMT2, // Eastern Europe Time
278 EEST = GMT3, // Eastern Europe Summer Time
279 MSK = GMT3, // Moscow Time
280 MSD = GMT4, // Moscow Summer Time
283 AST = GMT_4, // Atlantic Standard Time
284 ADT = GMT_3, // Atlantic Daylight Time
285 EST = GMT_5, // Eastern Standard Time
286 EDT = GMT_4, // Eastern Daylight Saving Time
287 CST = GMT_6, // Central Standard Time
288 CDT = GMT_5, // Central Daylight Saving Time
289 MST = GMT_7, // Mountain Standard Time
290 MDT = GMT_6, // Mountain Daylight Saving Time
291 PST = GMT_8, // Pacific Standard Time
292 PDT = GMT_7, // Pacific Daylight Saving Time
293 HST = GMT_10, // Hawaiian Standard Time
294 AKST = GMT_9, // Alaska Standard Time
295 AKDT = GMT_8, // Alaska Daylight Saving Time
299 A_WST = GMT8, // Western Standard Time
300 A_CST = GMT12 + 1, // Central Standard Time (+9.5)
301 A_EST = GMT10, // Eastern Standard Time
302 A_ESST = GMT11, // Eastern Summer Time
304 // Universal Coordinated Time = the new and politically correct name
311 Gregorian, // current calendar
312 Julian // calendar in use since -45 until the 1582 (or later)
317 Country_Unknown, // no special information for this country
318 Country_Default, // set the default country with SetCountry() method
319 // or use the default country with any other
321 // Western European countries: we assume that they all follow the same
322 // DST rules (true or false?)
323 Country_WesternEurope_Start,
324 Country_EEC = Country_WesternEurope_Start,
328 Country_WesternEurope_End = UK,
335 // symbolic names for the months
338 Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, Inv_Month
341 // symbolic names for the weekdays
344 Sun, Mon, Tue, Wed, Thu, Fri, Sat, Inv_WeekDay
347 // invalid value for the year
350 Inv_Year = SHRT_MIN // should hold in wxDateTime_t
353 // flags for GetWeekDayName and GetMonthName
356 Name_Full = 0x01, // return full name
357 Name_Abbr = 0x02 // return abbreviated name
360 // flags for GetWeekOfYear and GetWeekOfMonth
363 Default_First, // Sunday_First for US, Monday_First for the rest
364 Monday_First, // week starts with a Monday
365 Sunday_First // week starts with a Sunday
370 // ------------------------------------------------------------------------
372 // set the current country
373 static void SetCountry(Country country);
374 // get the current country
375 static Country GetCountry();
377 // return TRUE if the country is a West European one (in practice,
378 // this means that the same DST rules as for EEC apply)
379 static bool IsWestEuropeanCountry(Country country = Country_Default);
381 // return the current year
382 static int GetCurrentYear(Calendar cal = Gregorian);
384 // convert the year as returned by wxDateTime::GetYear() to a year
385 // suitable for BC/AD notation. The difference is that BC year 1
386 // corresponds to the year 0 (while BC year 0 didn't exist) and AD
387 // year N is just year N.
388 static int ConvertYearToBC(int year);
390 // return the current month
391 static Month GetCurrentMonth(Calendar cal = Gregorian);
393 // returns TRUE if the given year is a leap year in the given calendar
394 static bool IsLeapYear(int year = Inv_Year, Calendar cal = Gregorian);
396 // get the century (19 for 1999, 20 for 2000 and -5 for 492 BC)
397 static int GetCentury(int year = Inv_Year);
399 // returns the number of days in this year (356 or 355 for Gregorian
400 // calendar usually :-)
401 %name(GetNumberOfDaysinYear)
402 static wxDateTime_t GetNumberOfDays(int year, Calendar cal = Gregorian);
404 // get the number of the days in the given month (default value for
405 // the year means the current one)
406 %name(GetNumberOfDaysInMonth)
407 static wxDateTime_t GetNumberOfDays(Month month,
409 Calendar cal = Gregorian);
411 // get the full (default) or abbreviated month name in the current
412 // locale, returns empty string on error
413 static wxString GetMonthName(Month month,
414 NameFlags flags = Name_Full);
416 // get the full (default) or abbreviated weekday name in the current
417 // locale, returns empty string on error
418 static wxString GetWeekDayName(WeekDay weekday,
419 NameFlags flags = Name_Full);
421 // get the AM and PM strings in the current locale (may be empty)
422 static void GetAmPmStrings(wxString *OUTPUT, wxString *OUTPUT);
424 // return TRUE if the given country uses DST for this year
425 static bool IsDSTApplicable(int year = Inv_Year,
426 Country country = Country_Default);
428 // get the beginning of DST for this year, will return invalid object
429 // if no DST applicable in this year. The default value of the
430 // parameter means to take the current year.
431 static wxDateTime GetBeginDST(int year = Inv_Year,
432 Country country = Country_Default);
433 // get the end of DST for this year, will return invalid object
434 // if no DST applicable in this year. The default value of the
435 // parameter means to take the current year.
436 static wxDateTime GetEndDST(int year = Inv_Year,
437 Country country = Country_Default);
439 // return the wxDateTime object for the current time
440 static inline wxDateTime Now();
442 // return the wxDateTime object for today midnight: i.e. as Now() but
443 // with time set to 0
444 static inline wxDateTime Today();
448 // ------------------------------------------------------------------------
452 %name(wxDateTimeFromTimeT)wxDateTime(time_t timet);
453 %name(wxDateTimeFromJDN)wxDateTime(double jdn);
454 %name(wxDateTimeFromHMS)wxDateTime(wxDateTime_t hour,
455 wxDateTime_t minute = 0,
456 wxDateTime_t second = 0,
457 wxDateTime_t millisec = 0);
458 %name(wxDateTimeFromDMY)wxDateTime(wxDateTime_t day,
459 Month month = Inv_Month,
461 wxDateTime_t hour = 0,
462 wxDateTime_t minute = 0,
463 wxDateTime_t second = 0,
464 wxDateTime_t millisec = 0);
468 // ------------------------------------------------------------------------
471 wxDateTime& SetToCurrent();
473 // set to given time_t value
474 %name(SetTimeT)wxDateTime& Set(time_t timet);
476 // set to given JDN (beware of rounding errors)
477 %name(SetJDN)wxDateTime& Set(double jdn);
479 // set to given time, date = today
480 %name(SetHMS)wxDateTime& Set(wxDateTime_t hour,
481 wxDateTime_t minute = 0,
482 wxDateTime_t second = 0,
483 wxDateTime_t millisec = 0);
485 // from separate values for each component with explicit date
486 // (defaults for month and year are the current values)
487 wxDateTime& Set(wxDateTime_t day,
488 Month month = Inv_Month,
489 int year = Inv_Year, // 1999, not 99 please!
490 wxDateTime_t hour = 0,
491 wxDateTime_t minute = 0,
492 wxDateTime_t second = 0,
493 wxDateTime_t millisec = 0);
495 // resets time to 00:00:00, doesn't change the date
496 wxDateTime& ResetTime();
498 // the following functions don't change the values of the other
499 // fields, i.e. SetMinute() won't change either hour or seconds value
502 wxDateTime& SetYear(int year);
504 wxDateTime& SetMonth(Month month);
505 // set the day of the month
506 wxDateTime& SetDay(wxDateTime_t day);
508 wxDateTime& SetHour(wxDateTime_t hour);
510 wxDateTime& SetMinute(wxDateTime_t minute);
512 wxDateTime& SetSecond(wxDateTime_t second);
514 wxDateTime& SetMillisecond(wxDateTime_t millisecond);
517 // ------------------------------------------------------------------------
518 // calendar calculations
520 // set to the given week day in the same week as this one
521 wxDateTime& SetToWeekDayInSameWeek(WeekDay weekday);
522 wxDateTime GetWeekDayInSameWeek(WeekDay weekday);
524 // set to the next week day following this one
525 wxDateTime& SetToNextWeekDay(WeekDay weekday);
526 wxDateTime GetNextWeekDay(WeekDay weekday);
528 // set to the previous week day before this one
529 wxDateTime& SetToPrevWeekDay(WeekDay weekday);
530 wxDateTime GetPrevWeekDay(WeekDay weekday);
532 // set to Nth occurence of given weekday in the given month of the
533 // given year (time is set to 0), return TRUE on success and FALSE on
534 // failure. n may be positive (1..5) or negative to count from the end
535 // of the month (see helper function SetToLastWeekDay())
536 bool SetToWeekDay(WeekDay weekday,
538 Month month = Inv_Month,
539 int year = Inv_Year);
540 // wxDateTime GetWeekDay(WeekDay weekday,
542 // Month month = Inv_Month,
543 // int year = Inv_Year);
545 // sets to the last weekday in the given month, year
546 bool SetToLastWeekDay(WeekDay weekday,
547 Month month = Inv_Month,
548 int year = Inv_Year);
549 wxDateTime GetLastWeekDay(WeekDay weekday,
550 Month month = Inv_Month,
551 int year = Inv_Year);
553 // sets the date to the given day of the given week in the year,
554 // returns TRUE on success and FALSE if given date doesn't exist (e.g.
556 bool SetToTheWeek(wxDateTime_t numWeek, WeekDay weekday = Mon);
557 wxDateTime GetWeek(wxDateTime_t numWeek, WeekDay weekday = Mon);
559 // sets the date to the last day of the given (or current) month or the
560 // given (or current) year
561 wxDateTime& SetToLastMonthDay(Month month = Inv_Month,
562 int year = Inv_Year);
563 wxDateTime GetLastMonthDay(Month month = Inv_Month,
564 int year = Inv_Year);
566 // sets to the given year day (1..365 or 366)
567 wxDateTime& SetToYearDay(wxDateTime_t yday);
568 wxDateTime GetYearDay(wxDateTime_t yday);
570 // The definitions below were taken verbatim from
572 // http://www.capecod.net/~pbaum/date/date0.htm
574 // (Peter Baum's home page)
576 // definition: The Julian Day Number, Julian Day, or JD of a
577 // particular instant of time is the number of days and fractions of a
578 // day since 12 hours Universal Time (Greenwich mean noon) on January
579 // 1 of the year -4712, where the year is given in the Julian
580 // proleptic calendar. The idea of using this reference date was
581 // originally proposed by Joseph Scalizer in 1582 to count years but
582 // it was modified by 19th century astronomers to count days. One
583 // could have equivalently defined the reference time to be noon of
584 // November 24, -4713 if were understood that Gregorian calendar rules
585 // were applied. Julian days are Julian Day Numbers and are not to be
586 // confused with Julian dates.
588 // definition: The Rata Die number is a date specified as the number
589 // of days relative to a base date of December 31 of the year 0. Thus
590 // January 1 of the year 1 is Rata Die day 1.
592 // get the Julian Day number (the fractional part specifies the time of
593 // the day, related to noon - beware of rounding errors!)
594 double GetJulianDayNumber();
597 // get the Modified Julian Day number: it is equal to JDN - 2400000.5
598 // and so integral MJDs correspond to the midnights (and not noons).
599 // MJD 0 is Nov 17, 1858
600 double GetModifiedJulianDayNumber() const { return GetJDN() - 2400000.5; }
603 // get the Rata Die number
607 // ------------------------------------------------------------------------
610 // transform to any given timezone
611 wxDateTime ToTimezone(const wxDateTime::TimeZone& tz, bool noDST = FALSE);
612 wxDateTime& MakeTimezone(const wxDateTime::TimeZone& tz, bool noDST = FALSE);
614 // transform to GMT/UTC
615 wxDateTime ToGMT(bool noDST = FALSE);
616 wxDateTime& MakeGMT(bool noDST = FALSE);
618 // is daylight savings time in effect at this moment according to the
619 // rules of the specified country?
621 // Return value is > 0 if DST is in effect, 0 if it is not and -1 if
622 // the information is not available (this is compatible with ANSI C)
623 int IsDST(Country country = Country_Default);
627 // ------------------------------------------------------------------------
630 // is the date valid (TRUE even for non initialized objects)?
631 inline bool IsValid() const;
633 // get the number of seconds since the Unix epoch - returns (time_t)-1
634 // if the value is out of range
635 inline time_t GetTicks() const;
637 // get the year (returns Inv_Year if date is invalid)
638 int GetYear(const wxDateTime::TimeZone& tz = LOCAL) const;
640 // get the month (Inv_Month if date is invalid)
641 Month GetMonth(const wxDateTime::TimeZone& tz = LOCAL) const;
643 // get the month day (in 1..31 range, 0 if date is invalid)
644 wxDateTime_t GetDay(const wxDateTime::TimeZone& tz = LOCAL) const;
646 // get the day of the week (Inv_WeekDay if date is invalid)
647 WeekDay GetWeekDay(const wxDateTime::TimeZone& tz = LOCAL) const;
649 // get the hour of the day
650 wxDateTime_t GetHour(const wxDateTime::TimeZone& tz = LOCAL) const;
653 wxDateTime_t GetMinute(const wxDateTime::TimeZone& tz = LOCAL) const;
656 wxDateTime_t GetSecond(const wxDateTime::TimeZone& tz = LOCAL) const;
659 wxDateTime_t GetMillisecond(const wxDateTime::TimeZone& tz = LOCAL) const;
662 // get the day since the year start (1..366, 0 if date is invalid)
663 wxDateTime_t GetDayOfYear(const wxDateTime::TimeZone& tz = LOCAL) const;
664 // get the week number since the year start (1..52 or 53, 0 if date is
666 wxDateTime_t GetWeekOfYear(WeekFlags flags = Monday_First,
667 const wxDateTime::TimeZone& tz = LOCAL) const;
668 // get the week number since the month start (1..5, 0 if date is
670 wxDateTime_t GetWeekOfMonth(WeekFlags flags = Monday_First,
671 const wxDateTime::TimeZone& tz = LOCAL) const;
673 // is this date a work day? This depends on a country, of course,
674 // because the holidays are different in different countries
675 bool IsWorkDay(Country country = Country_Default) const;
677 // is this date later than Gregorian calendar introduction for the
678 // given country (see enum GregorianAdoption)?
680 // NB: this function shouldn't be considered as absolute authority in
681 // the matter. Besides, for some countries the exact date of
682 // adoption of the Gregorian calendar is simply unknown.
683 //bool IsGregorianDate(GregorianAdoption country = Gr_Standard) const;
686 // ------------------------------------------------------------------------
687 // comparison (see also functions below for operator versions)
689 // returns TRUE if the two moments are strictly identical
690 inline bool IsEqualTo(const wxDateTime& datetime) const;
692 // returns TRUE if the date is strictly earlier than the given one
693 inline bool IsEarlierThan(const wxDateTime& datetime) const;
695 // returns TRUE if the date is strictly later than the given one
696 inline bool IsLaterThan(const wxDateTime& datetime) const;
698 // returns TRUE if the date is strictly in the given range
699 inline bool IsStrictlyBetween(const wxDateTime& t1,
700 const wxDateTime& t2) const;
702 // returns TRUE if the date is in the given range
703 inline bool IsBetween(const wxDateTime& t1, const wxDateTime& t2) const;
705 // do these two objects refer to the same date?
706 inline bool IsSameDate(const wxDateTime& dt) const;
708 // do these two objects have the same time?
709 inline bool IsSameTime(const wxDateTime& dt) const;
711 // are these two objects equal up to given timespan?
712 inline bool IsEqualUpTo(const wxDateTime& dt, const wxTimeSpan& ts) const;
715 // ------------------------------------------------------------------------
716 // arithmetics with dates (see also below for more operators)
718 // add a time span (positive or negative)
719 %name(AddTS) wxDateTime& Add(const wxTimeSpan& diff);
720 // add a date span (positive or negative)
721 %name(AddDS) wxDateTime& Add(const wxDateSpan& diff);
723 // subtract a time span (positive or negative)
724 %name(SubtractTS) wxDateTime& Subtract(const wxTimeSpan& diff);
726 // subtract a date span (positive or negative)
727 %name(SubtractDS) wxDateTime& Subtract(const wxDateSpan& diff);
729 // return the difference between two dates
730 wxTimeSpan Subtract(const wxDateTime& dt) const;
734 wxDateTime __add__TS(const wxTimeSpan& other) { return *self + other; }
735 wxDateTime __add__DS(const wxDateSpan& other) { return *self + other; }
737 wxTimeSpan __sub__DT(const wxDateTime& other) { return *self - other; }
738 wxDateTime __sub__TS(const wxTimeSpan& other) { return *self - other; }
739 wxDateTime __sub__DS(const wxDateSpan& other) { return *self - other; }
741 int __cmp__(const wxDateTime& other) {
742 if (*self < other) return -1;
743 if (*self == other) return 0;
748 %pragma(python) addtoclass = "
749 def __add__(self, other):
750 if string.find(other.this, 'wxTimeSpan') != -1:
751 return self.__add__TS(other)
752 if string.find(other.this, 'wxDateSpan') != -1:
753 return self.__add__DS(other)
754 raise TypeError, 'Invalid r.h.s. type for __add__'
755 def __sub__(self, other):
756 if string.find(other.this, 'wxDateTime') != -1:
757 return self.__sub__DT(other)
758 if string.find(other.this, 'wxTimeSpan') != -1:
759 return self.__sub__TS(other)
760 if string.find(other.this, 'wxDateSpan') != -1:
761 return self.__sub__DS(other)
762 raise TypeError, 'Invalid r.h.s. type for __sub__'
765 // ------------------------------------------------------------------------
766 // conversion to/from text: all conversions from text return the pointer to
767 // the next character following the date specification (i.e. the one where
768 // the scan had to stop) or NULL on failure.
770 // parse a string in RFC 822 format (found e.g. in mail headers and
771 // having the form "Wed, 10 Feb 1999 19:07:07 +0100")
772 const char *ParseRfc822Date(const char* date);
774 // parse a date/time in the given format (see strptime(3)), fill in
775 // the missing (in the string) fields with the values of dateDef (by
776 // default, they will not change if they had valid values or will
777 // default to Today() otherwise)
778 const char *ParseFormat(const char *date,
779 const char *format = "%c",
780 const wxDateTime& dateDef = wxDefaultDateTime);
782 // parse a string containing the date/time in "free" format, this
783 // function will try to make an educated guess at the string contents
784 const char *ParseDateTime(const char *datetime);
786 // parse a string containing the date only in "free" format (less
787 // flexible than ParseDateTime)
788 const char *ParseDate(const char *date);
790 // parse a string containing the time only in "free" format
791 const char *ParseTime(const char *time);
793 // this function accepts strftime()-like format string (default
794 // argument corresponds to the preferred date and time representation
795 // for the current locale) and returns the string containing the
796 // resulting text representation
797 wxString Format(const char *format = "%c",
798 const wxDateTime::TimeZone& tz = LOCAL) const;
800 // preferred date representation for the current locale
801 wxString FormatDate() const;
803 // preferred time representation for the current locale
804 wxString FormatTime() const;
806 // returns the string representing the date in ISO 8601 format
808 wxString FormatISODate() const;
810 // returns the string representing the time in ISO 8601 format
812 wxString FormatISOTime() const;
814 %pragma(python) addtoclass = "
816 return '<wxDateTime: \"%s\" at %s>' % ( self.Format(), self.this)
823 //---------------------------------------------------------------------------
824 //---------------------------------------------------------------------------
830 // return the timespan for the given number of seconds
831 static wxTimeSpan Seconds(long sec);
832 static wxTimeSpan Second();
834 // return the timespan for the given number of minutes
835 static wxTimeSpan Minutes(long min);
836 static wxTimeSpan Minute();
838 // return the timespan for the given number of hours
839 static wxTimeSpan Hours(long hours);
840 static wxTimeSpan Hour();
842 // return the timespan for the given number of days
843 static wxTimeSpan Days(long days);
844 static wxTimeSpan Day();
846 // return the timespan for the given number of weeks
847 static wxTimeSpan Weeks(long days);
848 static wxTimeSpan Week();
850 // ------------------------------------------------------------------------
853 // from separate values for each component, date set to 0 (hours are
854 // not restricted to 0..24 range, neither are minutes, seconds or
856 wxTimeSpan(long hours = 0,
859 long milliseconds = 0);
863 // ------------------------------------------------------------------------
864 // arithmetics with time spans
866 // add two timespans together
867 inline wxTimeSpan& Add(const wxTimeSpan& diff);
869 // subtract another timespan
870 inline wxTimeSpan& Subtract(const wxTimeSpan& diff);
872 // multiply timespan by a scalar
873 inline wxTimeSpan& Multiply(int n);
875 // negate the value of the timespan
878 // return the absolute value of the timespan: does _not_ modify the
880 inline wxTimeSpan Abs() const;
883 wxTimeSpan __add__(const wxTimeSpan& other) { return *self + other; }
884 wxTimeSpan __sub__(const wxTimeSpan& other) { return *self - other; }
885 wxTimeSpan __mul__(int n) { return *self * n; }
886 wxTimeSpan __rmul__(int n) { return n * *self; }
887 wxTimeSpan __neg__() { return self->Negate(); }
888 int __cmp__(const wxTimeSpan& other) {
889 if (*self < other) return -1;
890 if (*self == other) return 0;
895 // comparaison (see also operator versions below)
896 // ------------------------------------------------------------------------
898 // is the timespan null?
901 // is the timespan positive?
902 bool IsPositive() const;
904 // is the timespan negative?
905 bool IsNegative() const;
907 // are two timespans equal?
908 inline bool IsEqualTo(const wxTimeSpan& ts) const;
910 // compare two timestamps: works with the absolute values, i.e. -2
911 // hours is longer than 1 hour. Also, it will return FALSE if the
912 // timespans are equal in absolute value.
913 inline bool IsLongerThan(const wxTimeSpan& ts) const;
915 // compare two timestamps: works with the absolute values, i.e. 1
916 // hour is shorter than -2 hours. Also, it will return FALSE if the
917 // timespans are equal in absolute value.
918 bool IsShorterThan(const wxTimeSpan& t) const;
920 // ------------------------------------------------------------------------
921 // breaking into days, hours, minutes and seconds
923 // get the max number of weeks in this timespan
924 inline int GetWeeks() const;
925 // get the max number of days in this timespan
926 inline int GetDays() const;
927 // get the max number of hours in this timespan
928 inline int GetHours() const;
929 // get the max number of minutes in this timespan
930 inline int GetMinutes() const;
933 // get the max number of seconds in this timespan
934 inline wxLongLong GetSeconds() const;
935 // get the number of milliseconds in this timespan
936 wxLongLong GetMilliseconds() const;
938 // ------------------------------------------------------------------------
939 // conversion to text
941 // this function accepts strftime()-like format string (default
942 // argument corresponds to the preferred date and time representation
943 // for the current locale) and returns the string containing the
944 // resulting text representation. Notice that only some of format
945 // specifiers valid for wxDateTime are valid for wxTimeSpan: hours,
946 // minutes and seconds make sense, but not "PM/AM" string for example.
947 wxString Format(const char *format = "%c") const;
949 // // preferred date representation for the current locale
950 // wxString FormatDate() const;
952 // // preferred time representation for the current locale
953 // wxString FormatTime() const;
955 // %pragma(python) addtoclass = "
956 // def __repr__(self):
957 // return '<wxTimeSpan: \"%s\" at %s>' % ( self.Format(), self.this)
958 // def __str__(self):
959 // return self.Format()
964 //---------------------------------------------------------------------------
965 //---------------------------------------------------------------------------
970 // this many years/months/weeks/days
971 wxDateSpan(int years = 0, int months = 0, int weeks = 0, int days = 0)
981 // get an object for the given number of days
982 static wxDateSpan Days(int days);
983 static wxDateSpan Day();
985 // get an object for the given number of weeks
986 static wxDateSpan Weeks(int weeks);
987 static wxDateSpan Week();
989 // get an object for the given number of months
990 static wxDateSpan Months(int mon);
991 static wxDateSpan Month();
993 // get an object for the given number of years
994 static wxDateSpan Years(int years);
995 static wxDateSpan Year();
998 // ------------------------------------------------------------------------
1000 // set number of years
1001 wxDateSpan& SetYears(int n);
1002 // set number of months
1003 wxDateSpan& SetMonths(int n);
1004 // set number of weeks
1005 wxDateSpan& SetWeeks(int n);
1006 // set number of days
1007 wxDateSpan& SetDays(int n);
1009 // get number of years
1010 int GetYears() const;
1011 // get number of months
1012 int GetMonths() const;
1013 // get number of weeks
1014 int GetWeeks() const;
1015 // get number of days
1016 int GetDays() const;
1017 // returns 7*GetWeeks() + GetDays()
1018 int GetTotalDays() const;
1021 // ------------------------------------------------------------------------
1023 // add another wxDateSpan to us
1024 inline wxDateSpan& Add(const wxDateSpan& other);
1026 // subtract another wxDateSpan from us
1027 inline wxDateSpan& Subtract(const wxDateSpan& other);
1029 // inverse the sign of this timespan
1030 inline wxDateSpan& Neg();
1032 // multiply all components by a (signed) number
1033 inline wxDateSpan& Multiply(int factor);
1036 wxDateSpan __add__(const wxDateSpan& other) { return *self + other; }
1037 wxDateSpan __sub__(const wxDateSpan& other) { return *self - other; }
1038 wxDateSpan __mul__(int n) { return *self * n; }
1039 wxDateSpan __rmul__(int n) { return n * *self; }
1040 wxDateSpan __neg__() { return self->Negate(); }
1045 //---------------------------------------------------------------------------
1047 long wxGetLocalTime();
1048 long wxGetUTCTime();
1049 long wxGetCurrentTime();
1050 wxLongLong wxGetLocalTimeMillis();
1052 //---------------------------------------------------------------------------
1053 //---------------------------------------------------------------------------
1056 wxClassInfo::CleanUpClasses();
1057 wxClassInfo::InitializeClasses();
1060 //---------------------------------------------------------------------------