#include <wx/datetime.h>
When adding a month to the date, all lesser components (days, hours, ...) 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 wxDateSpan will not, in general, give back the original date: Feb 28 - 1 month will be Jan 28, not Jan 31!
wxDateSpan 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 with wxDateTime or wxTimeSpan, but the type of result is different for each case.
Finally, notice that for adding hours, minutes and so on you don't need this class at all: wxTimeSpan will do the job because there are no subtleties associated with those (we don't support leap seconds).
Public Member Functions | |
| wxDateSpan (int years=0, int months=0, int weeks=0, int days=0) | |
| wxDateSpan | Add (const wxDateSpan &other) const |
| wxDateSpan & | Add (const wxDateSpan &other) |
| int | GetDays () const |
| int | GetMonths () const |
| int | GetTotalDays () const |
| int | GetWeeks () const |
| int | GetYears () const |
| wxDateSpan | Multiply (int factor) const |
| wxDateSpan & | Multiply (int factor) |
| wxDateSpan & | Neg () |
| wxDateSpan | Negate () const |
| wxDateSpan & | SetDays (int n) |
| wxDateSpan & | SetMonths (int n) |
| wxDateSpan & | SetWeeks (int n) |
| wxDateSpan & | SetYears (int n) |
| wxDateSpan | Subtract (const wxDateSpan &other) const |
| wxDateSpan & | Subtract (const wxDateSpan &other) |
| wxDateSpan & | operator+= (const wxDateSpan &other) |
| wxDateSpan & | operator-= (const wxDateSpan &other) |
| wxDateSpan & | operator- () |
| wxDateSpan & | operator*= (int factor) |
| bool | operator!= (const wxDateSpan &) const |
| bool | operator== (const wxDateSpan &) const |
Static Public Member Functions | |
| static wxDateSpan | Day () |
| static wxDateSpan | Days (int days) |
| static wxDateSpan | Month () |
| static wxDateSpan | Months (int mon) |
| static wxDateSpan | Week () |
| static wxDateSpan | Weeks (int weeks) |
| static wxDateSpan | Year () |
| static wxDateSpan | Years (int years) |
| wxDateSpan::wxDateSpan | ( | int | years = 0, |
|
| int | months = 0, |
|||
| int | weeks = 0, |
|||
| int | days = 0 | |||
| ) |
Constructs the date span object for the given number of years, months, weeks and days. Note that the weeks and days add together if both are given.
| wxDateSpan wxDateSpan::Add | ( | const wxDateSpan & | other | ) | const |
| wxDateSpan& wxDateSpan::Add | ( | const wxDateSpan & | other | ) |
Adds the given wxDateSpan to this wxDateSpan and returns a reference to itself.
| static wxDateSpan wxDateSpan::Day | ( | ) | [static] |
| static wxDateSpan wxDateSpan::Days | ( | int | days | ) | [static] |
| int wxDateSpan::GetDays | ( | ) | const |
Returns the number of days (not counting the weeks component) in this date span.
| int wxDateSpan::GetMonths | ( | ) | const |
Returns the number of the months (not counting the years) in this date span.
| int wxDateSpan::GetTotalDays | ( | ) | 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.
| int wxDateSpan::GetWeeks | ( | ) | const |
| int wxDateSpan::GetYears | ( | ) | const |
Returns the number of years in this date span.
| static wxDateSpan wxDateSpan::Month | ( | ) | [static] |
| static wxDateSpan wxDateSpan::Months | ( | int | mon | ) | [static] |
| wxDateSpan wxDateSpan::Multiply | ( | int | factor | ) | const |
Returns the product of the date span by the specified factor. The product is computed by multiplying each of the components by the factor.
| wxDateSpan& wxDateSpan::Multiply | ( | int | factor | ) |
Multiplies this date span by the specified factor. The product is computed by multiplying each of the components by the factor.
| wxDateSpan& wxDateSpan::Neg | ( | ) |
| wxDateSpan wxDateSpan::Negate | ( | ) | const |
| wxDateSpan& wxDateSpan::SetDays | ( | int | n | ) |
Sets the number of days (without modifying any other components) in this date span.
| wxDateSpan& wxDateSpan::SetMonths | ( | int | n | ) |
Sets the number of months (without modifying any other components) in this date span.
| wxDateSpan& wxDateSpan::SetWeeks | ( | int | n | ) |
Sets the number of weeks (without modifying any other components) in this date span.
| wxDateSpan& wxDateSpan::SetYears | ( | int | n | ) |
Sets the number of years (without modifying any other components) in this date span.
| wxDateSpan wxDateSpan::Subtract | ( | const wxDateSpan & | other | ) | const |
| wxDateSpan& wxDateSpan::Subtract | ( | const wxDateSpan & | other | ) |
Subtracts the given wxDateSpan to this wxDateSpan and returns a reference to itself.
| static wxDateSpan wxDateSpan::Week | ( | ) | [static] |
| static wxDateSpan wxDateSpan::Weeks | ( | int | weeks | ) | [static] |
| static wxDateSpan wxDateSpan::Year | ( | ) | [static] |
| static wxDateSpan wxDateSpan::Years | ( | int | years | ) | [static] |
| wxDateSpan& wxDateSpan::operator+= | ( | const wxDateSpan & | other | ) |
Adds the given wxDateSpan to this wxDateSpan and returns the result.
| wxDateSpan& wxDateSpan::operator-= | ( | const wxDateSpan & | other | ) |
Subtracts the given wxDateSpan to this wxDateSpan and returns the result.
| wxDateSpan& wxDateSpan::operator- | ( | ) |
| wxDateSpan& wxDateSpan::operator*= | ( | int | factor | ) |
Multiplies this date span by the specified factor. The product is computed by multiplying each of the components by the factor.
| bool wxDateSpan::operator!= | ( | const wxDateSpan & | ) | const |
Returns true if this date span is different from the other one.
| bool wxDateSpan::operator== | ( | const wxDateSpan & | ) | const |
Returns true if this date span is equal to the other one. Two date spans are considered equal if and only if they have the same number of years and months and the same total number of days (counting both days and weeks).
|
[ top ] |