*********** wx.DateSpan *********** Inheritance diagram for `wx.DateSpan`: | .. inheritance-diagram:: wx.DateSpan | Description =========== This class is a "logical time span" and is useful for implementing program logic for such things as "add one month to the date" which, in general, doesn't mean to add 60\*60\*24\*31 seconds to it, but to take the same date the next month (to understand that this is indeed different consider adding one month to Feb, 15 -- we want to get Mar, 15, of course). When adding a month to the date, all lesser components (days, hours, etc...) won't be changed unless the resulting date would be invalid: for example, Jan 31 + 1 month will be Feb 28, not (non-existing) Feb 31. Because of this feature, adding and subtracting back again the same `wx.DateSpan` will **not**, in general give back the original date: Feb 28 - 1 month will be Jan 28, not Jan 31! `wx.DateSpan` objects can be either positive or negative. They may be multiplied by scalars which multiply all deltas by the scalar: i.e. 2\*(1 month and 1 day) is 2 months and 2 days. They can be added together and with `wx.DateTime `_ or `wx.TimeSpan `_, but the type of result is different for each case. .. warning:: Beware about weeks: if you specify both weeks and days, the total number of days added will be 7\*weeks + days! See also `GetTotalDays <#GetTotalDays>`_ function. Equality operators are defined for `wx.DateSpans`. Two datespans are equal if and only if they both give the same target date when added to **every** source date. Thus `Months <#Months>`_ (1) is not equal to `Days <#Days>`_ (30), because they don't give the same date when added to 1 Feb. But `Days <#Days>`_ (14) is equal to `Weeks <#Weeks>`_ (2). .. note:: Finally, notice that for adding hours, minutes and so on you don't need this class at all: `wx.TimeSpan `_ will do the job because there are no subtleties associated with those (we don't support leap seconds). .. seealso:: `wx.DateTime `_ Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `Add <#Add>`_ * `Day <#Day>`_ * `Days <#Days>`_ * `GetDays <#GetDays>`_ * `GetMonths <#GetMonths>`_ * `GetTotalDays <#GetTotalDays>`_ * `GetWeeks <#GetWeeks>`_ * `GetYears <#GetYears>`_ * `Month <#Month>`_ * `Months <#Months>`_ * `Multiply <#Multiply>`_ * `Neg <#Neg>`_ * `SetDays <#SetDays>`_ * `SetMonths <#SetMonths>`_ * `SetWeeks <#SetWeeks>`_ * `SetYears <#SetYears>`_ * `Subtract <#Subtract>`_ * `Week <#Week>`_ * `Weeks <#Weeks>`_ * `Year <#Year>`_ * `Years <#Years>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `days <#days>`_ * `months <#months>`_ * `totalDays <#totalDays>`_ * `weeks <#weeks>`_ * `years <#years>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(years=0, months=0, weeks=0, days=0) Constructor. Constructs the date span object for the given number of years, months, weeks and days. **Parameters:** * `years` (int) * `months` (int) * `weeks` (int) * `days` (int) | **Returns:** `wx.DateSpan `_ .. note:: Note that the weeks and days add together if both are given. -------- .. method:: Add(other) Returns the sum of two date spans. The first version returns a new object, the second and third ones modify this object in place. **Parameters:** * `other` (`wx.DateSpan `_) | **Returns:** `wx.DateSpan `_ -------- .. method:: Day() Returns a date span object corresponding to one day. | **Returns:** `wx.DateSpan `_ .. seealso:: `Days <#Days>`_ -------- .. method:: Days() Returns a date span object corresponding to the given number of days. | **Returns:** `wx.DateSpan `_ .. seealso:: `Day <#Day>`_ -------- .. method:: GetDays() Returns the number of days (only, that it not counting the weeks component!) in this date span. | **Returns:** `int` .. seealso:: `GetTotalDays <#GetTotalDays>`_ -------- .. method:: GetMonths() Returns the number of the months (not counting the years) in this date span. | **Returns:** `int` -------- .. method:: GetTotalDays() Returns the combined number of days in this date span, counting both weeks and days. It still doesn't take neither months nor years into the account. | **Returns:** `int` .. seealso:: `GetWeeks <#GetWeeks>`_, `GetDays <#GetDays>`_ -------- .. method:: GetWeeks() Returns the number of weeks in this date span. | **Returns:** `int` .. seealso:: `GetTotalDays <#GetTotalDays>`_ -------- .. method:: GetYears() Returns the number of years in this date span. | **Returns:** `int` -------- .. method:: Month(mon) Returns a date span object corresponding to one month. **Parameters:** * `mon` (int) | **Returns:** `wx.DateSpan `_ .. seealso:: `Months <#Months>`_ -------- .. method:: Months(mon) Returns a date span object corresponding to the given number of months. **Parameters:** * `mon` (int) | **Returns:** `wx.DateSpan `_ .. seealso:: `Month <#Month>`_ -------- .. method:: Multiply(factor) Returns the product of the date span by the specified `factor`. The product is computed by multiplying each of the components by the factor. The first version returns a new object, the second and third ones modify this object in place. **Parameters:** * `factor` (int) | **Returns:** `wx.DateSpan `_ -------- .. method:: Neg() Changes the sign of this date span. | **Returns:** `wx.DateSpan `_ -------- .. method:: SetDays(n) Sets the number of days (without modifying any other components) in this date span. **Parameters:** * `n` (int) | **Returns:** `wx.DateSpan `_ -------- .. method:: SetMonths(n) Sets the number of months (without modifying any other components) in this date span. **Parameters:** * `n` (int) | **Returns:** `wx.DateSpan `_ -------- .. method:: SetWeeks(n) Sets the number of weeks (without modifying any other components) in this date span. **Parameters:** * `n` (int) | **Returns:** `wx.DateSpan `_ -------- .. method:: SetYears(n) Sets the number of years (without modifying any other components) in this date span. **Parameters:** * `n` (int) | **Returns:** `wx.DateSpan `_ -------- .. method:: Subtract(other) Returns the difference of two date spans. The first version returns a new object, the second and third ones modify this object in place. **Parameters:** * `other` (`wx.DateSpan `_) | **Returns:** `wx.DateSpan `_ -------- .. method:: Week() Returns a date span object corresponding to one week. | **Returns:** `wx.DateSpan `_ .. seealso:: `Weeks <#Weeks>`_ -------- .. method:: Weeks(weeks) Returns a date span object corresponding to the given number of weeks. **Parameters:** * `weeks` (int) | **Returns:** `wx.DateSpan `_ .. seealso:: `Week <#Week>`_ -------- .. method:: Year(n) Returns a date span object corresponding to one year. **Parameters:** * `n` (int) | **Returns:** `wx.DateSpan `_ .. seealso:: `Years <#Years>`_ -------- .. method:: Years(years) Returns a date span object corresponding to the given number of years. **Parameters:** * `years` (int) | **Returns:** `wx.DateSpan `_ .. seealso:: `Year <#Year>`_ -------- Properties ^^^^^^^^^^ .. attribute:: days See `GetDays <#GetDays>`_ and `SetDays <#SetDays>`_ .. attribute:: months See `GetMonths <#GetMonths>`_ and `SetMonths <#SetMonths>`_ .. attribute:: totalDays See `GetTotalDays <#GetTotalDays>`_ .. attribute:: weeks See `GetWeeks <#GetWeeks>`_ and `SetWeeks <#SetWeeks>`_ .. attribute:: years See `GetYears <#GetYears>`_ and `SetYears <#SetYears>`_