X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/400930d3445bd8d8745c621b9ad0b352433db622..b09857ae000a60704207d63290be937584805fb0:/interface/wx/datetime.h diff --git a/interface/wx/datetime.h b/interface/wx/datetime.h index 950ac809e8..46106b11bf 100644 --- a/interface/wx/datetime.h +++ b/interface/wx/datetime.h @@ -9,7 +9,7 @@ /** @class wxDateTime - wxDateTime class represents an absolute moment in the time. + wxDateTime class represents an absolute moment in time. The type @c wxDateTime_t is typedefed as unsigned short and is used to contain the number of years, hours, minutes, seconds and @@ -29,12 +29,6 @@ parameter, it is currently ignored as only the Gregorian calendar is supported. Future versions will support other calendars. - @beginWxPythonOnly - These methods are standalone functions named - "wxDateTime_" in wxPython. - @endWxPythonOnly - - @section datetime_formatting Date Formatting and Parsing The date formatting and parsing functions convert wxDateTime objects to and @@ -438,45 +432,33 @@ public: object later. */ wxDateTime(); + + /** + Copy constructor. + */ + wxDateTime(const wxDateTime& date); + /** Same as Set(). - - @beginWxPythonOnly - This constructor is named "wxDateTimeFromTimeT" in wxPython. - @endWxPythonOnly */ wxDateTime(time_t timet); /** Same as Set(). - - @beginWxPythonOnly Unsupported. @endWxPythonOnly */ wxDateTime(const struct tm& tm); /** Same as Set(). - - @beginWxPythonOnly - This constructor is named "wxDateTimeFromJDN" in wxPython. - @endWxPythonOnly */ wxDateTime(double jdn); /** Same as Set(). - - @beginWxPythonOnly - This constructor is named "wxDateTimeFromHMS" in wxPython. - @endWxPythonOnly */ wxDateTime(wxDateTime_t hour, wxDateTime_t minute = 0, wxDateTime_t second = 0, wxDateTime_t millisec = 0); /** Same as Set(). - - @beginWxPythonOnly - This constructor is named "wxDateTimeFromDMY" in wxPython. - @endWxPythonOnly */ - wxDateTime(wxDateTime_t day, Month month = Inv_Month, + wxDateTime(wxDateTime_t day, Month month, int year = Inv_Year, wxDateTime_t hour = 0, wxDateTime_t minute = 0, wxDateTime_t second = 0, wxDateTime_t millisec = 0); @@ -488,6 +470,7 @@ public: Input, Windows SYSTEMTIME reference @since 2.9.0 @remarks MSW only + @onlyfor{wxmsw} */ wxDateTime(const struct _SYSTEMTIME& st); @@ -501,18 +484,22 @@ public: Constructs the object from @a timet value holding the number of seconds since Jan 1, 1970. - @beginWxPythonOnly - This method is named "SetTimeT" in wxPython. - @endWxPythonOnly + If @a timet is invalid, i.e. @code (time_t)-1 @endcode, wxDateTime + becomes invalid too, i.e. its IsValid() will return @false. */ wxDateTime& Set(time_t timet); /** Sets the date and time from the broken down representation in the standard @a tm structure. - - @beginWxPythonOnly Unsupported. @endWxPythonOnly */ wxDateTime& Set(const struct tm& tm); + + /** + Sets the date and time from the broken down representation in the + @a wxDateTime::Tm structure. + */ + wxDateTime& Set(const Tm& tm); + /** Sets the date from the so-called Julian Day Number. @@ -520,26 +507,18 @@ public: particular instant is the fractional number of days since 12 hours Universal Coordinated Time (Greenwich mean noon) on January 1 of the year -4712 in the Julian proleptic calendar. - - @beginWxPythonOnly - This method is named "SetJDN" in wxPython. - @endWxPythonOnly */ wxDateTime& Set(double jdn); /** Sets the date to be equal to Today() and the time from supplied parameters. - - @beginWxPythonOnly - This method is named "SetHMS" in wxPython. - @endWxPythonOnly */ wxDateTime& Set(wxDateTime_t hour, wxDateTime_t minute = 0, wxDateTime_t second = 0, wxDateTime_t millisec = 0); /** Sets the date and time from the parameters. */ - wxDateTime& Set(wxDateTime_t day, Month month = Inv_Month, + wxDateTime& Set(wxDateTime_t day, Month month, int year = Inv_Year, wxDateTime_t hour = 0, wxDateTime_t minute = 0, wxDateTime_t second = 0, wxDateTime_t millisec = 0); @@ -615,7 +594,7 @@ public: /** Returns the date and time in DOS format. */ - long unsigned int GetAsDOS() const; + unsigned long GetAsDOS() const; /** Initialize using the Windows SYSTEMTIME structure. @@ -623,6 +602,7 @@ public: Input, Windows SYSTEMTIME reference @since 2.9.0 @remarks MSW only + @onlyfor{wxmsw} */ wxDateTime& SetFromMSWSysTime(const struct _SYSTEMTIME& st); @@ -632,6 +612,7 @@ public: Output, pointer to Windows SYSTEMTIME @since 2.9.0 @remarks MSW only + @onlyfor{wxmsw} */ void GetAsMSWSysTime(struct _SYSTEMTIME* st) const; @@ -653,28 +634,28 @@ public: /** Returns the day in the given timezone (local one by default). */ - short unsigned int GetDay(const TimeZone& tz = Local) const; + unsigned short GetDay(const TimeZone& tz = Local) const; /** Returns the day of the year (in 1-366 range) in the given timezone (local one by default). */ - short unsigned int GetDayOfYear(const TimeZone& tz = Local) const; + unsigned short GetDayOfYear(const TimeZone& tz = Local) const; /** Returns the hour in the given timezone (local one by default). */ - short unsigned int GetHour(const TimeZone& tz = Local) const; + unsigned short GetHour(const TimeZone& tz = Local) const; /** Returns the milliseconds in the given timezone (local one by default). */ - short unsigned int GetMillisecond(const TimeZone& tz = Local) const; + unsigned short GetMillisecond(const TimeZone& tz = Local) const; /** Returns the minute in the given timezone (local one by default). */ - short unsigned int GetMinute(const TimeZone& tz = Local) const; + unsigned short GetMinute(const TimeZone& tz = Local) const; /** Returns the month in the given timezone (local one by default). @@ -684,7 +665,7 @@ public: /** Returns the seconds in the given timezone (local one by default). */ - short unsigned int GetSecond(const TimeZone& tz = Local) const; + unsigned short GetSecond(const TimeZone& tz = Local) const; /** Returns the number of seconds since Jan 1, 1970. An assert failure will @@ -773,7 +754,7 @@ public: /** Returns @true if the date is equal to another one up to the given time - interval, i.e. if the absolute difference between the two dates is less + interval, i.e.\ if the absolute difference between the two dates is less than this interval. */ bool IsEqualUpTo(const wxDateTime& dt, const wxTimeSpan& ts) const; @@ -832,67 +813,35 @@ public: /** Adds the given date span to this object. - - @beginWxPythonOnly - This method is named "AddDS" in wxPython. - @endWxPythonOnly */ wxDateTime Add(const wxDateSpan& diff) const; /** Adds the given date span to this object. - - @beginWxPythonOnly - This method is named "AddDS" in wxPython. - @endWxPythonOnly */ wxDateTime Add(const wxDateSpan& diff); /** Adds the given time span to this object. - - @beginWxPythonOnly - This method is named "AddTS" in wxPython. - @endWxPythonOnly */ wxDateTime Add(const wxTimeSpan& diff) const; /** Adds the given time span to this object. - - @beginWxPythonOnly - This method is named "AddTS" in wxPython. - @endWxPythonOnly */ wxDateTime& Add(const wxTimeSpan& diff); /** Subtracts the given time span from this object. - - @beginWxPythonOnly - This method is named "SubtractTS" in wxPython. - @endWxPythonOnly */ wxDateTime Subtract(const wxTimeSpan& diff) const; /** Subtracts the given time span from this object. - - @beginWxPythonOnly - This method is named "SubtractTS" in wxPython. - @endWxPythonOnly */ wxDateTime& Subtract(const wxTimeSpan& diff); /** Subtracts the given date span from this object. - - @beginWxPythonOnly - This method is named "SubtractDS" in wxPython. - @endWxPythonOnly */ wxDateTime Subtract(const wxDateSpan& diff) const; /** Subtracts the given date span from this object. - - @beginWxPythonOnly - This method is named "SubtractDS" in wxPython. - @endWxPythonOnly */ wxDateTime& Subtract(const wxDateSpan& diff); /** @@ -900,11 +849,20 @@ public: them as a wxTimeSpan. */ wxTimeSpan Subtract(const wxDateTime& dt) const; + /** + Returns the difference between this object and @a dt as a wxDateSpan. + + This method allows to find the number of entire years, months, weeks and + days between @a dt and this date. + + @since 2.9.5 + */ + wxDateSpan DiffAsDateSpan(const wxDateTime& dt) const; /** Adds the given date span to this object. */ - wxDateTime operator+=(const wxDateSpan& diff); + wxDateTime& operator+=(const wxDateSpan& diff); /** Subtracts the given date span from this object. */ @@ -1256,7 +1214,7 @@ public: WeekFlags flags = Monday_First); /** - Sets the date to the day number @a yday in the same year (i.e., unlike + Sets the date to the day number @a yday in the same year (i.e.\ unlike the other functions, this one does not use the current year). The day number should be in the range 1-366 for the leap years and 1-365 for the other ones. @@ -1381,7 +1339,7 @@ public: /** - Converts the year in absolute notation (i.e. a number which can be + Converts the year in absolute notation (i.e.\ a number which can be negative, positive or zero) to the year in BC/AD notation. For the positive years, nothing is done, but the year 0 is year 1 BC and so for other years there is a difference of 1. @@ -1423,7 +1381,7 @@ public: Country country = Country_Default); /** - Get the current century, i.e. first two digits of the year, in given + Get the current century, i.e.\ first two digits of the year, in given calendar (only Gregorian is currently supported). */ static int GetCentury(int year); @@ -1504,20 +1462,12 @@ public: /** Returns the number of days in the given year. The only supported value for @a cal currently is @c Gregorian. - - @beginWxPythonOnly - This method is named "GetNumberOfDaysInYear" in wxPython. - @endWxPythonOnly */ static wxDateTime_t GetNumberOfDays(int year, Calendar cal = Gregorian); /** Returns the number of days in the given month of the given year. The only supported value for @a cal currently is @c Gregorian. - - @beginWxPythonOnly - This method is named "GetNumberOfDaysInMonth" in wxPython. - @endWxPythonOnly */ static wxDateTime_t GetNumberOfDays(Month month, int year = Inv_Year, Calendar cal = Gregorian); @@ -1588,9 +1538,8 @@ public: printf("Current time in Paris:\t%s\n", now.Format("%c", wxDateTime::CET).c_str()); @endcode - @note This function is accurate up to seconds. UNow() should be used - for better precision, but it is less efficient and might not be - available on all platforms. + @note This function is accurate up to seconds. UNow() can be used if + better precision is required. @see Today() */ @@ -1618,18 +1567,20 @@ public: /** Returns the object corresponding to the midnight of the current day - (i.e. the same as Now(), but the time part is set to 0). + (i.e.\ the same as Now(), but the time part is set to 0). @see Now() */ static wxDateTime Today(); /** - Returns the object corresponding to the current time including the - milliseconds if a function to get time with such precision is available - on the current platform (supported under most Unices and Win32). + Returns the object corresponding to the current UTC time including the + milliseconds. - @see Now() + Notice that unlike Now(), this method creates a wxDateTime object + corresponding to UTC, not local, time. + + @see Now(), wxGetUTCTimeMillis() */ static wxDateTime UNow(); }; @@ -1755,6 +1706,16 @@ public: */ int GetMonths() const; + /** + Returns the combined number of months in this date span, counting both + years and months. + + @see GetYears(), GetMonths() + + @since 2.9.5 + */ + int GetTotalMonths() const; + /** Returns the combined number of days in this date span, counting both weeks and days. This doesn't take months or years into account. @@ -1912,7 +1873,7 @@ public: /** Returns @true if this date span is different from the other one. */ - bool operator!=(const wxDateSpan&) const; + bool operator!=(const wxDateSpan& other) const; /** Returns @true if this date span is equal to the other one. Two date @@ -1920,7 +1881,7 @@ public: years and months and the same total number of days (counting both days and weeks). */ - bool operator==(const wxDateSpan&) const; + bool operator==(const wxDateSpan& other) const; }; @@ -2002,7 +1963,7 @@ public: specifier of larger unit, only the rest part is taken, otherwise the full value is used. */ - wxString Format(const wxString& = wxDefaultTimeSpanFormat) const; + wxString Format(const wxString& format = wxDefaultTimeSpanFormat) const; /** Returns the difference in number of days. @@ -2055,7 +2016,7 @@ public: bool IsEqualTo(const wxTimeSpan& ts) const; /** - Compares two timespans: works with the absolute values, i.e. -2 hours + Compares two timespans: works with the absolute values, i.e.\ -2 hours is longer than 1 hour. Also, it will return @false if the timespans are equal in absolute value. */ @@ -2077,7 +2038,7 @@ public: bool IsPositive() const; /** - Compares two timespans: works with the absolute values, i.e. 1 hour is + Compares two timespans: works with the absolute values, i.e.\ 1 hour is shorter than -2 hours. Also, it will return @false if the timespans are equal in absolute value. */