1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     SWIG interface for wxDateTime and etc.
 
   7 // Created:     25-Nov-1998
 
   9 // Copyright:   (c) 2003 by Total Control Software
 
  10 // Licence:     wxWindows license
 
  11 /////////////////////////////////////////////////////////////////////////////
 
  16 //---------------------------------------------------------------------------
 
  20 #include <wx/datetime.h>
 
  23 MAKE_CONST_WXSTRING(DefaultDateTimeFormat);
 
  24 MAKE_CONST_WXSTRING(DefaultTimeSpanFormat);
 
  26 //---------------------------------------------------------------------------
 
  29 %typemap(in) wxDateTime::TimeZone& (bool temp=false) {
 
  30     $1 = new wxDateTime::TimeZone((wxDateTime::TZ)PyInt_AsLong($input));
 
  33 %typemap(python,freearg) wxDateTime::TimeZone& {
 
  34     if (temp$argnum) delete $1;
 
  39 #define LOCAL_TZ wxDateTime::Local
 
  43 // Convert a wxLongLong to a Python Long by getting the hi/lo dwords, then
 
  44 // shifting and oring them together
 
  45 %typemap(python, out) wxLongLong {
 
  46     PyObject *hi, *lo, *shifter, *shifted;
 
  47     hi = PyLong_FromLong( $1.GetHi() );
 
  48     lo = PyLong_FromLong( $1.GetLo() );
 
  49     shifter = PyLong_FromLong(32);
 
  50     shifted = PyNumber_Lshift(hi, shifter);
 
  51     $result = PyNumber_Or(shifted, lo);
 
  59 //---------------------------------------------------------------------------
 
  61 //typedef unsigned short wxDateTime_t;
 
  62 #define wxDateTime_t int
 
  64 // wxDateTime represents an absolute moment in the time
 
  70         // the time in the current time zone
 
  73         // zones from GMT (= Greenwhich Mean Time): they're guaranteed to be
 
  74         // consequent numbers, so writing something like `GMT0 + offset' is
 
  75         // safe if abs(offset) <= 12
 
  76         // underscore stands for minus
 
  77         GMT_12, GMT_11, GMT_10, GMT_9, GMT_8, GMT_7,
 
  78         GMT_6, GMT_5, GMT_4, GMT_3, GMT_2, GMT_1,
 
  80         GMT1, GMT2, GMT3, GMT4, GMT5, GMT6,
 
  81         GMT7, GMT8, GMT9, GMT10, GMT11, GMT12,
 
  84         WET = GMT0,                         // Western Europe Time
 
  85         WEST = GMT1,                        // Western Europe Summer Time
 
  86         CET = GMT1,                         // Central Europe Time
 
  87         CEST = GMT2,                        // Central Europe Summer Time
 
  88         EET = GMT2,                         // Eastern Europe Time
 
  89         EEST = GMT3,                        // Eastern Europe Summer Time
 
  90         MSK = GMT3,                         // Moscow Time
 
  91         MSD = GMT4,                         // Moscow Summer Time
 
  94         AST = GMT_4,                        // Atlantic Standard Time
 
  95         ADT = GMT_3,                        // Atlantic Daylight Time
 
  96         EST = GMT_5,                        // Eastern Standard Time
 
  97         EDT = GMT_4,                        // Eastern Daylight Saving Time
 
  98         CST = GMT_6,                        // Central Standard Time
 
  99         CDT = GMT_5,                        // Central Daylight Saving Time
 
 100         MST = GMT_7,                        // Mountain Standard Time
 
 101         MDT = GMT_6,                        // Mountain Daylight Saving Time
 
 102         PST = GMT_8,                        // Pacific Standard Time
 
 103         PDT = GMT_7,                        // Pacific Daylight Saving Time
 
 104         HST = GMT_10,                       // Hawaiian Standard Time
 
 105         AKST = GMT_9,                       // Alaska Standard Time
 
 106         AKDT = GMT_8,                       // Alaska Daylight Saving Time
 
 110         A_WST = GMT8,                       // Western Standard Time
 
 111         A_CST = GMT12 + 1,                  // Central Standard Time (+9.5)
 
 112         A_EST = GMT10,                      // Eastern Standard Time
 
 113         A_ESST = GMT11,                     // Eastern Summer Time
 
 115         // Universal Coordinated Time = the new and politically correct name
 
 121         // the calendar systems we know about: notice that it's valid (for
 
 122         // this classes purpose anyhow) to work with any of these calendars
 
 123         // even with the dates before the historical appearance of the
 
 127         Gregorian,  // current calendar
 
 128         Julian      // calendar in use since -45 until the 1582 (or later)
 
 131         // these values only are used to identify the different dates of
 
 132         // adoption of the Gregorian calendar (see IsGregorian())
 
 134         // All data and comments taken verbatim from "The Calendar FAQ (v 2.0)"
 
 135         // by Claus Tøndering, http://www.pip.dknet.dk/~c-t/calendar.html
 
 136         // except for the comments "we take".
 
 138         // Symbol "->" should be read as "was followed by" in the comments
 
 140     enum GregorianAdoption
 
 142         Gr_Unknown,    // no data for this country or it's too uncertain to use
 
 143         Gr_Standard,   // on the day 0 of Gregorian calendar: 15 Oct 1582
 
 145         Gr_Alaska,             // Oct 1867 when Alaska became part of the USA
 
 146         Gr_Albania,            // Dec 1912
 
 148         Gr_Austria = Gr_Unknown,    // Different regions on different dates
 
 149         Gr_Austria_Brixen,          // 5 Oct 1583 -> 16 Oct 1583
 
 150         Gr_Austria_Salzburg = Gr_Austria_Brixen,
 
 151         Gr_Austria_Tyrol = Gr_Austria_Brixen,
 
 152         Gr_Austria_Carinthia,       // 14 Dec 1583 -> 25 Dec 1583
 
 153         Gr_Austria_Styria = Gr_Austria_Carinthia,
 
 155         Gr_Belgium,            // Then part of the Netherlands
 
 157         Gr_Bulgaria = Gr_Unknown, // Unknown precisely (from 1915 to 1920)
 
 158         Gr_Bulgaria_1,         //      18 Mar 1916 -> 1 Apr 1916
 
 159         Gr_Bulgaria_2,         //      31 Mar 1916 -> 14 Apr 1916
 
 160         Gr_Bulgaria_3,         //      3 Sep 1920 -> 17 Sep 1920
 
 162         Gr_Canada = Gr_Unknown,   // Different regions followed the changes in
 
 163                                // Great Britain or France
 
 165         Gr_China = Gr_Unknown,    // Different authorities say:
 
 166         Gr_China_1,            //      18 Dec 1911 -> 1 Jan 1912
 
 167         Gr_China_2,            //      18 Dec 1928 -> 1 Jan 1929
 
 169         Gr_Czechoslovakia,     // (Bohemia and Moravia) 6 Jan 1584 -> 17 Jan 1584
 
 170         Gr_Denmark,            // (including Norway) 18 Feb 1700 -> 1 Mar 1700
 
 173         Gr_Finland,            // Then part of Sweden
 
 175         Gr_France,             // 9 Dec 1582 -> 20 Dec 1582
 
 176         Gr_France_Alsace,      //      4 Feb 1682 -> 16 Feb 1682
 
 177         Gr_France_Lorraine,    //      16 Feb 1760 -> 28 Feb 1760
 
 178         Gr_France_Strasbourg,  // February 1682
 
 180         Gr_Germany = Gr_Unknown,  // Different states on different dates:
 
 181         Gr_Germany_Catholic,   //      1583-1585 (we take 1584)
 
 182         Gr_Germany_Prussia,    //      22 Aug 1610 -> 2 Sep 1610
 
 183         Gr_Germany_Protestant, //      18 Feb 1700 -> 1 Mar 1700
 
 185         Gr_GreatBritain,       // 2 Sep 1752 -> 14 Sep 1752 (use 'cal(1)')
 
 187         Gr_Greece,             // 9 Mar 1924 -> 23 Mar 1924
 
 188         Gr_Hungary,            // 21 Oct 1587 -> 1 Nov 1587
 
 189         Gr_Ireland = Gr_GreatBritain,
 
 190         Gr_Italy = Gr_Standard,
 
 192         Gr_Japan = Gr_Unknown,    // Different authorities say:
 
 193         Gr_Japan_1,            //      19 Dec 1872 -> 1 Jan 1873
 
 194         Gr_Japan_2,            //      19 Dec 1892 -> 1 Jan 1893
 
 195         Gr_Japan_3,            //      18 Dec 1918 -> 1 Jan 1919
 
 197         Gr_Latvia,             // 1915-1918 (we take 1915)
 
 198         Gr_Lithuania,          // 1915
 
 199         Gr_Luxemburg,          // 14 Dec 1582 -> 25 Dec 1582
 
 200         Gr_Netherlands = Gr_Belgium, // (including Belgium) 1 Jan 1583
 
 202         // this is too weird to take into account: the Gregorian calendar was
 
 203         // introduced twice in Groningen, first time 28 Feb 1583 was followed
 
 204         // by 11 Mar 1583, then it has gone back to Julian in the summer of
 
 205         // 1584 and then 13 Dec 1700 -> 12 Jan 1701 - which is
 
 206         // the date we take here
 
 207         Gr_Netherlands_Groningen,  // 13 Dec 1700 -> 12 Jan 1701
 
 208         Gr_Netherlands_Gelderland, // 30 Jun 1700 -> 12 Jul 1700
 
 209         Gr_Netherlands_Utrecht,    // (and Overijssel) 30 Nov 1700->12 Dec 1700
 
 210         Gr_Netherlands_Friesland,  // (and Drenthe) 31 Dec 1700 -> 12 Jan 1701
 
 212         Gr_Norway = Gr_Denmark,       // Then part of Denmark
 
 213         Gr_Poland = Gr_Standard,
 
 214         Gr_Portugal = Gr_Standard,
 
 215         Gr_Romania,                // 31 Mar 1919 -> 14 Apr 1919
 
 216         Gr_Russia,                 // 31 Jan 1918 -> 14 Feb 1918
 
 217         Gr_Scotland = Gr_GreatBritain,
 
 218         Gr_Spain = Gr_Standard,
 
 220         // Sweden has a curious history. Sweden decided to make a gradual
 
 221         // change from the Julian to the Gregorian calendar. By dropping every
 
 222         // leap year from 1700 through 1740 the eleven superfluous days would
 
 223         // be omitted and from 1 Mar 1740 they would be in sync with the
 
 224         // Gregorian calendar. (But in the meantime they would be in sync with
 
 227         // So 1700 (which should have been a leap year in the Julian calendar)
 
 228         // was not a leap year in Sweden. However, by mistake 1704 and 1708
 
 229         // became leap years. This left Sweden out of synchronisation with
 
 230         // both the Julian and the Gregorian world, so they decided to go back
 
 231         // to the Julian calendar. In order to do this, they inserted an extra
 
 232         // day in 1712, making that year a double leap year! So in 1712,
 
 233         // February had 30 days in Sweden.
 
 235         // Later, in 1753, Sweden changed to the Gregorian calendar by
 
 236         // dropping 11 days like everyone else.
 
 237         Gr_Sweden = Gr_Finland,       // 17 Feb 1753 -> 1 Mar 1753
 
 239         Gr_Switzerland = Gr_Unknown,// Different cantons used different dates
 
 240         Gr_Switzerland_Catholic,    //      1583, 1584 or 1597 (we take 1584)
 
 241         Gr_Switzerland_Protestant,  //      31 Dec 1700 -> 12 Jan 1701
 
 243         Gr_Turkey,                 // 1 Jan 1927
 
 244         Gr_USA = Gr_GreatBritain,
 
 245         Gr_Wales = Gr_GreatBritain,
 
 246         Gr_Yugoslavia              // 1919
 
 251         // the country parameter is used so far for calculating the start and
 
 252         // the end of DST period and for deciding whether the date is a work
 
 256         Country_Unknown, // no special information for this country
 
 257         Country_Default, // set the default country with SetCountry() method
 
 258                          // or use the default country with any other
 
 260         // Western European countries: we assume that they all follow the same
 
 261         // DST rules (True or False?)
 
 262         Country_WesternEurope_Start,
 
 263         Country_EEC = Country_WesternEurope_Start,
 
 267         Country_WesternEurope_End = UK,
 
 274         // symbolic names for the months
 
 277         Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, Inv_Month
 
 280         // symbolic names for the weekdays
 
 283         Sun, Mon, Tue, Wed, Thu, Fri, Sat, Inv_WeekDay
 
 286         // invalid value for the year
 
 289         Inv_Year = SHRT_MIN    // should hold in wxDateTime_t
 
 292         // flags for GetWeekDayName and GetMonthName
 
 295         Name_Full = 0x01,       // return full name
 
 296         Name_Abbr = 0x02        // return abbreviated name
 
 299         // flags for GetWeekOfYear and GetWeekOfMonth
 
 302         Default_First,   // Sunday_First for US, Monday_First for the rest
 
 303         Monday_First,    // week starts with a Monday
 
 304         Sunday_First     // week starts with a Sunday
 
 308     //**  Nested class TimeZone is handled by a typemap instead
 
 310     //**  Is nested class Tm needed?
 
 314     // ------------------------------------------------------------------------
 
 316         // set the current country
 
 317     static void SetCountry(Country country);
 
 319         // get the current country
 
 320     static Country GetCountry();
 
 322         // return True if the country is a West European one (in practice,
 
 323         // this means that the same DST rules as for EEC apply)
 
 324     static bool IsWestEuropeanCountry(Country country = Country_Default);
 
 326         // return the current year
 
 327     static int GetCurrentYear(Calendar cal = Gregorian);
 
 329         // convert the year as returned by wxDateTime::GetYear() to a year
 
 330         // suitable for BC/AD notation. The difference is that BC year 1
 
 331         // corresponds to the year 0 (while BC year 0 didn't exist) and AD
 
 332         // year N is just year N.
 
 333     static int ConvertYearToBC(int year);
 
 335         // return the current month
 
 336     static Month GetCurrentMonth(Calendar cal = Gregorian);
 
 338         // returns True if the given year is a leap year in the given calendar
 
 339     static bool IsLeapYear(int year = Inv_Year, Calendar cal = Gregorian);
 
 341         // get the century (19 for 1999, 20 for 2000 and -5 for 492 BC)
 
 342     static int GetCentury(int year = Inv_Year);
 
 344         // returns the number of days in this year (356 or 355 for Gregorian
 
 345         // calendar usually :-)
 
 346     %Rename(GetNumberOfDaysinYear, 
 
 347         static wxDateTime_t, GetNumberOfDays(int year, Calendar cal = Gregorian));
 
 349         // get the number of the days in the given month (default value for
 
 350         // the year means the current one)
 
 351     %Rename(GetNumberOfDaysInMonth, 
 
 352         static wxDateTime_t, GetNumberOfDays(Month month,
 
 354                                             Calendar cal = Gregorian));
 
 356         // get the full (default) or abbreviated month name in the current
 
 357         // locale, returns empty string on error
 
 358     static wxString GetMonthName(Month month,
 
 359                                  NameFlags flags = Name_Full);
 
 361         // get the full (default) or abbreviated weekday name in the current
 
 362         // locale, returns empty string on error
 
 363     static wxString GetWeekDayName(WeekDay weekday,
 
 364                                    NameFlags flags = Name_Full);
 
 369             "GetAmPmStrings() -> (am, pm)",
 
 370             "Get the AM and PM strings in the current locale (may be empty)", "");
 
 371         static PyObject* GetAmPmStrings() {
 
 374             wxDateTime::GetAmPmStrings(&am, &pm);
 
 375             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 376             PyObject* tup = PyTuple_New(2);
 
 377             PyTuple_SET_ITEM(tup, 0, wx2PyString(am));
 
 378             PyTuple_SET_ITEM(tup, 1, wx2PyString(pm));
 
 379             wxPyEndBlockThreads(blocked);
 
 384         // return True if the given country uses DST for this year
 
 385     static bool IsDSTApplicable(int year = Inv_Year,
 
 386                                 Country country = Country_Default);
 
 388         // get the beginning of DST for this year, will return invalid object
 
 389         // if no DST applicable in this year. The default value of the
 
 390         // parameter means to take the current year.
 
 391     static wxDateTime GetBeginDST(int year = Inv_Year,
 
 392                                   Country country = Country_Default);
 
 393         // get the end of DST for this year, will return invalid object
 
 394         // if no DST applicable in this year. The default value of the
 
 395         // parameter means to take the current year.
 
 396     static wxDateTime GetEndDST(int year = Inv_Year,
 
 397                                 Country country = Country_Default);
 
 399         // return the wxDateTime object for the current time
 
 400     static inline wxDateTime Now();
 
 402         // return the wxDateTime object for the current time with millisecond
 
 403         // precision (if available on this platform)
 
 404     static wxDateTime UNow();
 
 406         // return the wxDateTime object for today midnight: i.e. as Now() but
 
 407         // with time set to 0
 
 408     static inline wxDateTime Today();
 
 412     // ------------------------------------------------------------------------
 
 416     %RenameCtor(DateTimeFromTimeT, wxDateTime(time_t timet));
 
 417     %RenameCtor(DateTimeFromJDN, wxDateTime(double jdn));
 
 418     %RenameCtor(DateTimeFromHMS, wxDateTime(wxDateTime_t hour,
 
 419                                      wxDateTime_t minute = 0,
 
 420                                      wxDateTime_t second = 0,
 
 421                                      wxDateTime_t millisec = 0));
 
 422     %RenameCtor(DateTimeFromDMY, wxDateTime(wxDateTime_t day,
 
 423                                      Month        month = Inv_Month,
 
 425                                      wxDateTime_t hour = 0,
 
 426                                      wxDateTime_t minute = 0,
 
 427                                      wxDateTime_t second = 0,
 
 428                                      wxDateTime_t millisec = 0));
 
 432     // ------------------------------------------------------------------------
 
 435     wxDateTime& SetToCurrent();
 
 437         // set to given time_t value
 
 438     %Rename(SetTimeT, wxDateTime&, Set(time_t timet));
 
 440         // set to given JDN (beware of rounding errors)
 
 441     %Rename(SetJDN, wxDateTime&, Set(double jdn));
 
 443         // set to given time, date = today
 
 444     %Rename(SetHMS, wxDateTime&, Set(wxDateTime_t hour,
 
 445                     wxDateTime_t minute = 0,
 
 446                     wxDateTime_t second = 0,
 
 447                     wxDateTime_t millisec = 0));
 
 449         // from separate values for each component with explicit date
 
 450         // (defaults for month and year are the current values)
 
 451     wxDateTime& Set(wxDateTime_t day,
 
 452                     Month        month = Inv_Month,
 
 453                     int          year = Inv_Year, // 1999, not 99 please!
 
 454                     wxDateTime_t hour = 0,
 
 455                     wxDateTime_t minute = 0,
 
 456                     wxDateTime_t second = 0,
 
 457                     wxDateTime_t millisec = 0);
 
 459         // resets time to 00:00:00, doesn't change the date
 
 460     wxDateTime& ResetTime();
 
 462         // the following functions don't change the values of the other
 
 463         // fields, i.e. SetMinute() won't change either hour or seconds value
 
 466     wxDateTime& SetYear(int year);
 
 468     wxDateTime& SetMonth(Month month);
 
 469         // set the day of the month
 
 470     wxDateTime& SetDay(wxDateTime_t day);
 
 472     wxDateTime& SetHour(wxDateTime_t hour);
 
 474     wxDateTime& SetMinute(wxDateTime_t minute);
 
 476     wxDateTime& SetSecond(wxDateTime_t second);
 
 478     wxDateTime& SetMillisecond(wxDateTime_t millisecond);
 
 481     // ------------------------------------------------------------------------
 
 482     // calendar calculations
 
 484         // set to the given week day in the same week as this one
 
 485     wxDateTime& SetToWeekDayInSameWeek(WeekDay weekday, WeekFlags flags = Monday_First);
 
 486     wxDateTime GetWeekDayInSameWeek(WeekDay weekday, WeekFlags flags = Monday_First);
 
 488         // set to the next week day following this one
 
 489     wxDateTime& SetToNextWeekDay(WeekDay weekday);
 
 490     wxDateTime GetNextWeekDay(WeekDay weekday);
 
 492         // set to the previous week day before this one
 
 493     wxDateTime& SetToPrevWeekDay(WeekDay weekday);
 
 494     wxDateTime GetPrevWeekDay(WeekDay weekday);
 
 496         // set to Nth occurence of given weekday in the given month of the
 
 497         // given year (time is set to 0), return True on success and False on
 
 498         // failure. n may be positive (1..5) or negative to count from the end
 
 499         // of the month (see helper function SetToLastWeekDay())
 
 500     bool SetToWeekDay(WeekDay weekday,
 
 502                       Month month = Inv_Month,
 
 503                       int year = Inv_Year);
 
 504 //      wxDateTime GetWeekDay(WeekDay weekday,
 
 506 //                            Month month = Inv_Month,
 
 507 //                            int year = Inv_Year);
 
 509         // sets to the last weekday in the given month, year
 
 510     bool SetToLastWeekDay(WeekDay weekday,
 
 511                           Month month = Inv_Month,
 
 512                           int year = Inv_Year);
 
 513     wxDateTime GetLastWeekDay(WeekDay weekday,
 
 514                               Month month = Inv_Month,
 
 515                               int year = Inv_Year);
 
 517         // sets the date to the given day of the given week in the year,
 
 518         // returns True on success and False if given date doesn't exist (e.g.
 
 520     bool SetToTheWeek(wxDateTime_t numWeek, WeekDay weekday = Mon, WeekFlags flags = Monday_First);
 
 521     wxDateTime GetWeek(wxDateTime_t numWeek, WeekDay weekday = Mon, WeekFlags flags = Monday_First);
 
 524         SetToTheWeek = wx._deprecated(SetToTheWeek, "SetToTheWeek is deprecated, use (static) SetToWeekOfYear instead")
 
 525         GetWeek = wx._deprecated(GetWeek, "GetWeek is deprecated, use GetWeekOfYear instead")
 
 528         // returns the date corresponding to the given week day of the given
 
 529         // week (in ISO notation) of the specified year
 
 530     static wxDateTime SetToWeekOfYear(int year,
 
 531                                       wxDateTime_t numWeek,
 
 532                                       WeekDay weekday = Mon);
 
 534         // sets the date to the last day of the given (or current) month or the
 
 535         // given (or current) year
 
 536     wxDateTime& SetToLastMonthDay(Month month = Inv_Month,
 
 537                                   int year = Inv_Year);
 
 538     wxDateTime GetLastMonthDay(Month month = Inv_Month,
 
 539                                int year = Inv_Year);
 
 541         // sets to the given year day (1..365 or 366)
 
 542     wxDateTime& SetToYearDay(wxDateTime_t yday);
 
 543     wxDateTime GetYearDay(wxDateTime_t yday);
 
 545         // The definitions below were taken verbatim from
 
 547         //      http://www.capecod.net/~pbaum/date/date0.htm
 
 549         // (Peter Baum's home page)
 
 551         // definition: The Julian Day Number, Julian Day, or JD of a
 
 552         // particular instant of time is the number of days and fractions of a
 
 553         // day since 12 hours Universal Time (Greenwich mean noon) on January
 
 554         // 1 of the year -4712, where the year is given in the Julian
 
 555         // proleptic calendar. The idea of using this reference date was
 
 556         // originally proposed by Joseph Scalizer in 1582 to count years but
 
 557         // it was modified by 19th century astronomers to count days. One
 
 558         // could have equivalently defined the reference time to be noon of
 
 559         // November 24, -4713 if were understood that Gregorian calendar rules
 
 560         // were applied. Julian days are Julian Day Numbers and are not to be
 
 561         // confused with Julian dates.
 
 563         // definition: The Rata Die number is a date specified as the number
 
 564         // of days relative to a base date of December 31 of the year 0. Thus
 
 565         // January 1 of the year 1 is Rata Die day 1.
 
 567         // get the Julian Day number (the fractional part specifies the time of
 
 568         // the day, related to noon - beware of rounding errors!)
 
 569     double GetJulianDayNumber();
 
 572         // get the Modified Julian Day number: it is equal to JDN - 2400000.5
 
 573         // and so integral MJDs correspond to the midnights (and not noons).
 
 574         // MJD 0 is Nov 17, 1858
 
 575     double GetModifiedJulianDayNumber() const { return GetJDN() - 2400000.5; }
 
 578         // get the Rata Die number
 
 582     // ------------------------------------------------------------------------
 
 585         // transform to any given timezone
 
 586     wxDateTime ToTimezone(const wxDateTime::TimeZone& tz, bool noDST = false);
 
 587     wxDateTime& MakeTimezone(const wxDateTime::TimeZone& tz, bool noDST = false);
 
 589         // transform to GMT/UTC
 
 590     wxDateTime ToGMT(bool noDST = false);
 
 591     wxDateTime& MakeGMT(bool noDST = false);
 
 593         // is daylight savings time in effect at this moment according to the
 
 594         // rules of the specified country?
 
 596         // Return value is > 0 if DST is in effect, 0 if it is not and -1 if
 
 597         // the information is not available (this is compatible with ANSI C)
 
 598     int IsDST(Country country = Country_Default);
 
 602     // ------------------------------------------------------------------------
 
 605         // is the date valid (True even for non initialized objects)?
 
 606     inline bool IsValid() const;
 
 607     %pythoncode { Ok = IsValid }
 
 608     %pythoncode { def __nonzero__(self): return self.Ok() };
 
 611         // get the number of seconds since the Unix epoch - returns (time_t)-1
 
 612         // if the value is out of range
 
 613     inline time_t GetTicks() const;
 
 615         // get the year (returns Inv_Year if date is invalid)
 
 616     int GetYear(const wxDateTime::TimeZone& tz = LOCAL_TZ) const;
 
 618         // get the month (Inv_Month if date is invalid)
 
 619     Month GetMonth(const wxDateTime::TimeZone& tz = LOCAL_TZ) const;
 
 621         // get the month day (in 1..31 range, 0 if date is invalid)
 
 622     wxDateTime_t GetDay(const wxDateTime::TimeZone& tz = LOCAL_TZ) const;
 
 624         // get the day of the week (Inv_WeekDay if date is invalid)
 
 625     WeekDay GetWeekDay(const wxDateTime::TimeZone& tz = LOCAL_TZ) const;
 
 627         // get the hour of the day
 
 628     wxDateTime_t GetHour(const wxDateTime::TimeZone& tz = LOCAL_TZ) const;
 
 631     wxDateTime_t GetMinute(const wxDateTime::TimeZone& tz = LOCAL_TZ) const;
 
 634     wxDateTime_t GetSecond(const wxDateTime::TimeZone& tz = LOCAL_TZ) const;
 
 637     wxDateTime_t GetMillisecond(const wxDateTime::TimeZone& tz = LOCAL_TZ) const;
 
 640         // get the day since the year start (1..366, 0 if date is invalid)
 
 641     wxDateTime_t GetDayOfYear(const wxDateTime::TimeZone& tz = LOCAL_TZ) const;
 
 642         // get the week number since the year start (1..52 or 53, 0 if date is
 
 644     wxDateTime_t GetWeekOfYear(WeekFlags flags = Monday_First,
 
 645                                const wxDateTime::TimeZone& tz = LOCAL_TZ) const;
 
 646         // get the week number since the month start (1..5, 0 if date is
 
 648     wxDateTime_t GetWeekOfMonth(WeekFlags flags = Monday_First,
 
 649                                 const wxDateTime::TimeZone& tz = LOCAL_TZ) const;
 
 651         // is this date a work day? This depends on a country, of course,
 
 652         // because the holidays are different in different countries
 
 653     bool IsWorkDay(Country country = Country_Default) const;
 
 655         // is this date later than Gregorian calendar introduction for the
 
 656         // given country (see enum GregorianAdoption)?
 
 658         // NB: this function shouldn't be considered as absolute authority in
 
 659         //     the matter. Besides, for some countries the exact date of
 
 660         //     adoption of the Gregorian calendar is simply unknown.
 
 661 //    bool IsGregorianDate(GregorianAdoption country = Gr_Standard) const;
 
 664     // ------------------------------------------------------------------------
 
 665     // comparison (see also functions below for operator versions)
 
 667         // returns True if the two moments are strictly identical
 
 668     inline bool IsEqualTo(const wxDateTime& datetime) const;
 
 670         // returns True if the date is strictly earlier than the given one
 
 671     inline bool IsEarlierThan(const wxDateTime& datetime) const;
 
 673         // returns True if the date is strictly later than the given one
 
 674     inline bool IsLaterThan(const wxDateTime& datetime) const;
 
 676         // returns True if the date is strictly in the given range
 
 677     inline bool IsStrictlyBetween(const wxDateTime& t1,
 
 678                                   const wxDateTime& t2) const;
 
 680         // returns True if the date is in the given range
 
 681     inline bool IsBetween(const wxDateTime& t1, const wxDateTime& t2) const;
 
 683         // do these two objects refer to the same date?
 
 684     inline bool IsSameDate(const wxDateTime& dt) const;
 
 686         // do these two objects have the same time?
 
 687     inline bool IsSameTime(const wxDateTime& dt) const;
 
 689         // are these two objects equal up to given timespan?
 
 690     inline bool IsEqualUpTo(const wxDateTime& dt, const wxTimeSpan& ts) const;
 
 693     // ------------------------------------------------------------------------
 
 694     // arithmetics with dates (see also below for more operators)
 
 696         // add a time span (positive or negative)
 
 697     %Rename(AddTS,  wxDateTime&, Add(const wxTimeSpan& diff));
 
 698         // add a date span (positive or negative)
 
 699     %Rename(AddDS,  wxDateTime&, Add(const wxDateSpan& diff));
 
 701         // subtract a time span (positive or negative)
 
 702     %Rename(SubtractTS,  wxDateTime&, Subtract(const wxTimeSpan& diff));
 
 704         // subtract a date span (positive or negative)
 
 705     %Rename(SubtractDS,  wxDateTime&, Subtract(const wxDateSpan& diff));
 
 707         // return the difference between two dates
 
 708     wxTimeSpan Subtract(const wxDateTime& dt) const;
 
 711     %nokwargs operator+=;
 
 712         // add a time span (positive or negative)
 
 713     inline wxDateTime& operator+=(const wxTimeSpan& diff);
 
 714         // add a date span (positive or negative)
 
 715     inline wxDateTime& operator+=(const wxDateSpan& diff);
 
 717     %nokwargs operator-=;
 
 718         // subtract a time span (positive or negative)
 
 719     inline wxDateTime& operator-=(const wxTimeSpan& diff);
 
 720         // subtract a date span (positive or negative)
 
 721     inline wxDateTime& operator-=(const wxDateSpan& diff);
 
 724 //     inline bool operator<(const wxDateTime& dt) const;
 
 725 //     inline bool operator<=(const wxDateTime& dt) const;
 
 726 //     inline bool operator>(const wxDateTime& dt) const;
 
 727 //     inline bool operator>=(const wxDateTime& dt) const;
 
 728 //     inline bool operator==(const wxDateTime& dt) const;
 
 729 //     inline bool operator!=(const wxDateTime& dt) const;
 
 734         wxDateTime __add__(const wxTimeSpan& other) { return *self + other; }
 
 735         wxDateTime __add__(const wxDateSpan& other) { return *self + other; }
 
 737         wxTimeSpan __sub__(const wxDateTime& other) { return *self - other; }
 
 738         wxDateTime __sub__(const wxTimeSpan& other) { return *self - other; }
 
 739         wxDateTime __sub__(const wxDateSpan& other) { return *self - other; }
 
 741         // These fall back to just comparing pointers if other is NULL, or if
 
 742         // either operand is invalid.  This allows Python comparrisons to None
 
 743         // to not assert and to return a sane value for the compare.
 
 744         bool __lt__(const wxDateTime* other) { 
 
 745             if (!other || !self->IsValid() || !other->IsValid()) return self <  other; 
 
 746             return (*self <  *other);
 
 748         bool __le__(const wxDateTime* other) { 
 
 749             if (!other || !self->IsValid() || !other->IsValid()) return self <= other; 
 
 750             return (*self <= *other);
 
 752         bool __gt__(const wxDateTime* other) { 
 
 753             if (!other || !self->IsValid() || !other->IsValid()) return self >  other; 
 
 754             return (*self >  *other);
 
 756         bool __ge__(const wxDateTime* other) { 
 
 757             if (!other || !self->IsValid() || !other->IsValid()) return self >= other; 
 
 758             return (*self >= *other);
 
 761         bool __eq__(const wxDateTime* other) {
 
 762             if (!other || !self->IsValid() || !other->IsValid()) return self == other; 
 
 763             return (*self == *other);
 
 765         bool __ne__(const wxDateTime* other) {
 
 766             if (!other || !self->IsValid() || !other->IsValid()) return self != other; 
 
 767             return (*self != *other);
 
 775     // ------------------------------------------------------------------------
 
 776     // conversion from text: all conversions from text return -1 on failure,
 
 777     // or the index in the string where the next character following the date
 
 778     // specification (i.e. the one where the scan had to stop) is located.
 
 782         // parse a string in RFC 822 format (found e.g. in mail headers and
 
 783         // having the form "Wed, 10 Feb 1999 19:07:07 +0100")
 
 784         int ParseRfc822Date(const wxString& date) {
 
 786             const wxChar* _date = date;
 
 787             rv = self->ParseRfc822Date(_date);
 
 788             if (rv == NULL) return -1;
 
 793         // parse a date/time in the given format (see strptime(3)), fill in
 
 794         // the missing (in the string) fields with the values of dateDef (by
 
 795         // default, they will not change if they had valid values or will
 
 796         // default to Today() otherwise)
 
 797         int ParseFormat(const wxString& date,
 
 798                         const wxString& format = wxPyDefaultDateTimeFormat,
 
 799                         const wxDateTime& dateDef = wxDefaultDateTime) {
 
 801             const wxChar* _date = date;
 
 802             rv = self->ParseFormat(_date, format, dateDef);
 
 803             if (rv == NULL) return -1;
 
 807         // parse a string containing the date/time in "free" format, this
 
 808         // function will try to make an educated guess at the string contents
 
 809         int ParseDateTime(const wxString& datetime) {
 
 811             const wxChar* _datetime = datetime;
 
 812             rv = self->ParseDateTime(_datetime);
 
 813             if (rv == NULL) return -1;
 
 814             return rv - _datetime;
 
 818         // parse a string containing the date only in "free" format (less
 
 819         // flexible than ParseDateTime)
 
 820         int ParseDate(const wxString& date) {
 
 822             const wxChar* _date = date;
 
 823             rv = self->ParseDate(_date);
 
 824             if (rv == NULL) return -1;
 
 828         // parse a string containing the time only in "free" format
 
 829         int ParseTime(const wxString& time) {
 
 831             const wxChar* _time = time;
 
 832             rv = self->ParseTime(_time);
 
 833             if (rv == NULL) return -1;
 
 839         // this function accepts strftime()-like format string (default
 
 840         // argument corresponds to the preferred date and time representation
 
 841         // for the current locale) and returns the string containing the
 
 842         // resulting text representation
 
 843     wxString Format(const wxString& format = wxPyDefaultDateTimeFormat,
 
 844                     const wxDateTime::TimeZone& tz = LOCAL_TZ) const;
 
 846         // preferred date representation for the current locale
 
 847     wxString FormatDate() const;
 
 849         // preferred time representation for the current locale
 
 850     wxString FormatTime() const;
 
 852         // returns the string representing the date in ISO 8601 format
 
 854     wxString FormatISODate() const;
 
 856         // returns the string representing the time in ISO 8601 format
 
 858     wxString FormatISOTime() const;
 
 863             return '<wx.DateTime: \"%s\" at %s>' % ( self.Format(), self.this)
 
 865             return '<wx.DateTime: \"INVALID\" at %s>' % self.this
 
 870             return "INVALID DateTime"
 
 874 //---------------------------------------------------------------------------
 
 875 //---------------------------------------------------------------------------
 
 878 // This class contains a difference between 2 wxDateTime values, so it makes
 
 879 // sense to add it to wxDateTime and it is the result of subtraction of 2
 
 880 // objects of that class. See also wxDateSpan.
 
 885         // return the timespan for the given number of seconds
 
 886     static wxTimeSpan Seconds(long sec);
 
 887     static wxTimeSpan Second();
 
 889         // return the timespan for the given number of minutes
 
 890     static wxTimeSpan Minutes(long min);
 
 891     static wxTimeSpan Minute();
 
 893         // return the timespan for the given number of hours
 
 894     static wxTimeSpan Hours(long hours);
 
 895     static wxTimeSpan Hour();
 
 897         // return the timespan for the given number of days
 
 898     static wxTimeSpan Days(long days);
 
 899     static wxTimeSpan Day();
 
 901         // return the timespan for the given number of weeks
 
 902     static wxTimeSpan Weeks(long days);
 
 903     static wxTimeSpan Week();
 
 905     // ------------------------------------------------------------------------
 
 908         // from separate values for each component, date set to 0 (hours are
 
 909         // not restricted to 0..24 range, neither are minutes, seconds or
 
 911     wxTimeSpan(long hours = 0,
 
 914                long milliseconds = 0);
 
 918     // ------------------------------------------------------------------------
 
 919     // arithmetics with time spans
 
 921         // add two timespans together
 
 922     inline wxTimeSpan& Add(const wxTimeSpan& diff);
 
 924         // subtract another timespan
 
 925     inline wxTimeSpan& Subtract(const wxTimeSpan& diff);
 
 927         // multiply timespan by a scalar
 
 928     inline wxTimeSpan& Multiply(int n);
 
 930         // negate the value of the timespan
 
 933         // return the absolute value of the timespan: does _not_ modify the
 
 935     inline wxTimeSpan Abs() const;
 
 938     wxTimeSpan& operator+=(const wxTimeSpan& diff);
 
 939     wxTimeSpan& operator-=(const wxTimeSpan& diff);
 
 940     wxTimeSpan& operator*=(int n);
 
 941     wxTimeSpan& operator-();
 
 944         wxTimeSpan __add__(const wxTimeSpan& other) { return *self + other; }
 
 945         wxTimeSpan __sub__(const wxTimeSpan& other) { return *self - other; }
 
 946         wxTimeSpan __mul__(int n)                   { return *self * n; }
 
 947         wxTimeSpan __rmul__(int n)                  { return n * *self; }
 
 949         bool __lt__(const wxTimeSpan* other) { return other ? (*self <  *other) : false; }
 
 950         bool __le__(const wxTimeSpan* other) { return other ? (*self <= *other) : false; }
 
 951         bool __gt__(const wxTimeSpan* other) { return other ? (*self >  *other) : true;  }
 
 952         bool __ge__(const wxTimeSpan* other) { return other ? (*self >= *other) : true;  }
 
 953         bool __eq__(const wxTimeSpan* other) { return other ? (*self == *other) : false; }
 
 954         bool __ne__(const wxTimeSpan* other) { return other ? (*self != *other) : true;  }
 
 959     // ------------------------------------------------------------------------
 
 961         // is the timespan null?
 
 964         // is the timespan positive?
 
 965     bool IsPositive() const;
 
 967         // is the timespan negative?
 
 968     bool IsNegative() const;
 
 970         // are two timespans equal?
 
 971     inline bool IsEqualTo(const wxTimeSpan& ts) const;
 
 973         // compare two timestamps: works with the absolute values, i.e. -2
 
 974         // hours is longer than 1 hour. Also, it will return False if the
 
 975         // timespans are equal in absolute value.
 
 976     inline bool IsLongerThan(const wxTimeSpan& ts) const;
 
 978         // compare two timestamps: works with the absolute values, i.e. 1
 
 979         // hour is shorter than -2 hours. Also, it will return False if the
 
 980         // timespans are equal in absolute value.
 
 981     bool IsShorterThan(const wxTimeSpan& t) const;
 
 983     // ------------------------------------------------------------------------
 
 984     // breaking into days, hours, minutes and seconds
 
 986         // get the max number of weeks in this timespan
 
 987     inline int GetWeeks() const;
 
 988         // get the max number of days in this timespan
 
 989     inline int GetDays() const;
 
 990         // get the max number of hours in this timespan
 
 991     inline int GetHours() const;
 
 992         // get the max number of minutes in this timespan
 
 993     inline int GetMinutes() const;
 
 996          // get the max number of seconds in this timespan
 
 997     inline wxLongLong GetSeconds() const;
 
 998          // get the number of milliseconds in this timespan
 
 999     wxLongLong GetMilliseconds() const;
 
1001     // ------------------------------------------------------------------------
 
1002     // conversion to text
 
1004         // this function accepts strftime()-like format string (default
 
1005         // argument corresponds to the preferred date and time representation
 
1006         // for the current locale) and returns the string containing the
 
1007         // resulting text representation. Notice that only some of format
 
1008         // specifiers valid for wxDateTime are valid for wxTimeSpan: hours,
 
1009         // minutes and seconds make sense, but not "PM/AM" string for example.
 
1010     wxString Format(const wxString& format = wxPyDefaultTimeSpanFormat) const;
 
1014          return '<wx.TimeSpan: \"%s\" at %s>' % ( self.Format(), self.this)
 
1016          return self.Format()
 
1021 //---------------------------------------------------------------------------
 
1022 //---------------------------------------------------------------------------
 
1024 // This class is a "logical time span" and is useful for implementing program
 
1025 // logic for such things as "add one month to the date" which, in general,
 
1026 // doesn't mean to add 60*60*24*31 seconds to it, but to take the same date
 
1027 // the next month (to understand that this is indeed different consider adding
 
1028 // one month to Feb, 15 - we want to get Mar, 15, of course).
 
1030 // When adding a month to the date, all lesser components (days, hours, ...)
 
1031 // won't be changed unless the resulting date would be invalid: for example,
 
1032 // Jan 31 + 1 month will be Feb 28, not (non existing) Feb 31.
 
1034 // Because of this feature, adding and subtracting back again the same
 
1035 // wxDateSpan will *not*, in general give back the original date: Feb 28 - 1
 
1036 // month will be Jan 28, not Jan 31!
 
1038 // wxDateSpan can be either positive or negative. They may be
 
1039 // multiplied by scalars which multiply all deltas by the scalar: i.e. 2*(1
 
1040 // month and 1 day) is 2 months and 2 days. They can be added together and
 
1041 // with wxDateTime or wxTimeSpan, but the type of result is different for each
 
1044 // Beware about weeks: if you specify both weeks and days, the total number of
 
1045 // days added will be 7*weeks + days! See also GetTotalDays() function.
 
1047 // Equality operators are defined for wxDateSpans. Two datespans are equal if
 
1048 // they both give the same target date when added to *every* source date.
 
1049 // Thus wxDateSpan::Months(1) is not equal to wxDateSpan::Days(30), because
 
1050 // they not give the same date when added to 1 Feb. But wxDateSpan::Days(14) is
 
1051 // equal to wxDateSpan::Weeks(2)
 
1053 // Finally, notice that for adding hours, minutes &c you don't need this
 
1054 // class: wxTimeSpan will do the job because there are no subtleties
 
1055 // associated with those.
 
1059         // this many years/months/weeks/days
 
1060     wxDateSpan(int years = 0, int months = 0, int weeks = 0, int days = 0)
 
1070         // get an object for the given number of days
 
1071     static wxDateSpan Days(int days);
 
1072     static wxDateSpan Day();
 
1074         // get an object for the given number of weeks
 
1075     static wxDateSpan Weeks(int weeks);
 
1076     static wxDateSpan Week();
 
1078         // get an object for the given number of months
 
1079     static wxDateSpan Months(int mon);
 
1080     static wxDateSpan Month();
 
1082         // get an object for the given number of years
 
1083     static wxDateSpan Years(int years);
 
1084     static wxDateSpan Year();
 
1087     // ------------------------------------------------------------------------
 
1089         // set number of years
 
1090     wxDateSpan& SetYears(int n);
 
1091         // set number of months
 
1092     wxDateSpan& SetMonths(int n);
 
1093         // set number of weeks
 
1094     wxDateSpan& SetWeeks(int n);
 
1095         // set number of days
 
1096     wxDateSpan& SetDays(int n);
 
1098         // get number of years
 
1099     int GetYears() const;
 
1100         // get number of months
 
1101     int GetMonths() const;
 
1102         // get number of weeks
 
1103     int GetWeeks() const;
 
1104         // get number of days
 
1105     int GetDays() const;
 
1106         // returns 7*GetWeeks() + GetDays()
 
1107     int GetTotalDays() const;
 
1110     // ------------------------------------------------------------------------
 
1112         // add another wxDateSpan to us
 
1113     inline wxDateSpan& Add(const wxDateSpan& other);
 
1115         // subtract another wxDateSpan from us
 
1116     inline wxDateSpan& Subtract(const wxDateSpan& other);
 
1118         // inverse the sign of this timespan
 
1119     inline wxDateSpan& Neg();
 
1121         // multiply all components by a (signed) number
 
1122     inline wxDateSpan& Multiply(int factor);
 
1124     inline wxDateSpan& operator+=(const wxDateSpan& other);
 
1125     inline wxDateSpan& operator-=(const wxDateSpan& other);
 
1126     wxDateSpan& operator-() { return Neg(); }
 
1127     inline wxDateSpan& operator*=(int factor) { return Multiply(factor); }
 
1130         wxDateSpan __add__(const wxDateSpan& other) { return *self + other; }
 
1131         wxDateSpan __sub__(const wxDateSpan& other) { return *self - other; }
 
1132         wxDateSpan __mul__(int n)                   { return *self * n; }
 
1133         wxDateSpan __rmul__(int n)                  { return n * *self; }
 
1135 //         bool __lt__(const wxDateSpan* other) { return other ? (*self <  *other) : false; }
 
1136 //         bool __le__(const wxDateSpan* other) { return other ? (*self <= *other) : false; }
 
1137 //         bool __gt__(const wxDateSpan* other) { return other ? (*self >  *other) : true;  }
 
1138 //         bool __ge__(const wxDateSpan* other) { return other ? (*self >= *other) : true;  }
 
1140         bool __eq__(const wxDateSpan* other) { return other ? (*self == *other) : false; }
 
1141         bool __ne__(const wxDateSpan* other) { return other ? (*self != *other) : true;  }
 
1146 //---------------------------------------------------------------------------
 
1148 // TODO: wxDateTimeHolidayAuthority
 
1150 //---------------------------------------------------------------------------
 
1152 long wxGetLocalTime();
 
1153 long wxGetUTCTime();
 
1154 long wxGetCurrentTime();
 
1155 wxLongLong wxGetLocalTimeMillis();
 
1158 const wxDateTime        wxDefaultDateTime;
 
1161 //---------------------------------------------------------------------------
 
1162 //---------------------------------------------------------------------------