#include <wx/datetime.h>
wxTimeSpan class represents a time interval.
Public Member Functions | |
| wxTimeSpan () | |
| Default constructor, constructs a zero timespan. | |
| wxTimeSpan (long hours, long min=0, wxLongLong sec=0, wxLongLong msec=0) | |
| Constructs timespan from separate values for each component, with the date set to 0. | |
| wxTimeSpan | Abs () const |
| Returns the absolute value of the timespan: does not modify the object. | |
| wxTimeSpan | Add (const wxTimeSpan &diff) const |
| Returns the sum of two time spans. | |
| wxTimeSpan & | Add (const wxTimeSpan &diff) |
| Adds the given wxTimeSpan to this wxTimeSpan and returns a reference to itself. | |
| wxString | Format (const wxString &format=wxDefaultTimeSpanFormat) const |
| Returns the string containing the formatted representation of the time span. | |
| int | GetDays () const |
| Returns the difference in number of days. | |
| int | GetHours () const |
| Returns the difference in number of hours. | |
| wxLongLong | GetMilliseconds () const |
| Returns the difference in number of milliseconds. | |
| int | GetMinutes () const |
| Returns the difference in number of minutes. | |
| wxLongLong | GetSeconds () const |
| Returns the difference in number of seconds. | |
| wxLongLong | GetValue () const |
| Returns the internal representation of timespan. | |
| int | GetWeeks () const |
| Returns the difference in number of weeks. | |
| bool | IsEqualTo (const wxTimeSpan &ts) const |
| Returns true if two timespans are equal. | |
| bool | IsLongerThan (const wxTimeSpan &ts) const |
| Compares two timespans: works with the absolute values, i.e. -2 hours is longer than 1 hour. | |
| bool | IsNegative () const |
| Returns true if the timespan is negative. | |
| bool | IsNull () const |
| Returns true if the timespan is empty. | |
| bool | IsPositive () const |
| Returns true if the timespan is positive. | |
| bool | IsShorterThan (const wxTimeSpan &ts) const |
| Compares two timespans: works with the absolute values, i.e. 1 hour is shorter than -2 hours. | |
| wxTimeSpan | Multiply (int n) const |
| Returns the product of this time span by n. | |
| wxTimeSpan & | Multiply (int n) |
| Multiplies this time span by n. | |
| wxTimeSpan & | Neg () |
| Negate the value of the timespan. | |
| wxTimeSpan | Negate () const |
| Returns timespan with inverted sign. | |
| wxTimeSpan | Subtract (const wxTimeSpan &diff) const |
| Returns the difference of two time spans. | |
| wxTimeSpan & | Subtract (const wxTimeSpan &diff) |
| Subtracts the given wxTimeSpan to this wxTimeSpan and returns a reference to itself. | |
| wxTimeSpan & | operator+= (const wxTimeSpan &diff) |
| Adds the given wxTimeSpan to this wxTimeSpan and returns the result. | |
| wxTimeSpan & | operator*= (int n) |
| Multiplies this time span by n. | |
| wxTimeSpan & | operator- () |
| Negate the value of the timespan. | |
| wxTimeSpan & | operator-= (const wxTimeSpan &diff) |
| Subtracts the given wxTimeSpan to this wxTimeSpan and returns the result. | |
Static Public Member Functions | |
| static wxTimeSpan | Day () |
| Returns the timespan for one day. | |
| static wxTimeSpan | Days (long days) |
| Returns the timespan for the given number of days. | |
| static wxTimeSpan | Hour () |
| Returns the timespan for one hour. | |
| static wxTimeSpan | Hours (long hours) |
| Returns the timespan for the given number of hours. | |
| static wxTimeSpan | Millisecond () |
| Returns the timespan for one millisecond. | |
| static wxTimeSpan | Milliseconds (wxLongLong ms) |
| Returns the timespan for the given number of milliseconds. | |
| static wxTimeSpan | Minute () |
| Returns the timespan for one minute. | |
| static wxTimeSpan | Minutes (long min) |
| Returns the timespan for the given number of minutes. | |
| static wxTimeSpan | Second () |
| Returns the timespan for one second. | |
| static wxTimeSpan | Seconds (wxLongLong sec) |
| Returns the timespan for the given number of seconds. | |
| static wxTimeSpan | Week () |
| Returns the timespan for one week. | |
| static wxTimeSpan | Weeks (long weeks) |
| Returns the timespan for the given number of weeks. | |
| wxTimeSpan::wxTimeSpan | ( | ) |
Default constructor, constructs a zero timespan.
| wxTimeSpan::wxTimeSpan | ( | long | hours, |
| long | min = 0, |
||
| wxLongLong | sec = 0, |
||
| wxLongLong | msec = 0 |
||
| ) |
Constructs timespan from separate values for each component, with the date set to 0.
Hours are not restricted to 0-24 range, neither are minutes, seconds or milliseconds.
| wxTimeSpan wxTimeSpan::Abs | ( | ) | const |
Returns the absolute value of the timespan: does not modify the object.
| wxTimeSpan wxTimeSpan::Add | ( | const wxTimeSpan & | diff | ) | const |
Returns the sum of two time spans.
| wxTimeSpan& wxTimeSpan::Add | ( | const wxTimeSpan & | diff | ) |
Adds the given wxTimeSpan to this wxTimeSpan and returns a reference to itself.
|
static |
Returns the timespan for one day.
|
static |
Returns the timespan for the given number of days.
Returns the string containing the formatted representation of the time span.
The following format specifiers are allowed after %:
H - Number of HoursM - Number of MinutesS - Number of Secondsl - Number of MillisecondsD - Number of DaysE - Number of Weeks% - The percent characterNote that, for example, the number of hours in the description above is not well defined: it can be either the total number of hours (for example, for a time span of 50 hours this would be 50) or just the hour part of the time span, which would be 2 in this case as 50 hours is equal to 2 days and 2 hours.
wxTimeSpan resolves this ambiguity in the following way: if there had been, indeed, the D format specified preceding the H, then it is interpreted as 2. Otherwise, it is 50.
The same applies to all other format specifiers: if they follow a specifier of larger unit, only the rest part is taken, otherwise the full value is used.
| int wxTimeSpan::GetDays | ( | ) | const |
Returns the difference in number of days.
| int wxTimeSpan::GetHours | ( | ) | const |
Returns the difference in number of hours.
| wxLongLong wxTimeSpan::GetMilliseconds | ( | ) | const |
Returns the difference in number of milliseconds.
| int wxTimeSpan::GetMinutes | ( | ) | const |
Returns the difference in number of minutes.
| wxLongLong wxTimeSpan::GetSeconds | ( | ) | const |
Returns the difference in number of seconds.
| wxLongLong wxTimeSpan::GetValue | ( | ) | const |
Returns the internal representation of timespan.
| int wxTimeSpan::GetWeeks | ( | ) | const |
Returns the difference in number of weeks.
|
static |
Returns the timespan for one hour.
|
static |
Returns the timespan for the given number of hours.
| bool wxTimeSpan::IsEqualTo | ( | const wxTimeSpan & | ts | ) | const |
Returns true if two timespans are equal.
| bool wxTimeSpan::IsLongerThan | ( | const wxTimeSpan & | ts | ) | const |
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.
| bool wxTimeSpan::IsNegative | ( | ) | const |
Returns true if the timespan is negative.
| bool wxTimeSpan::IsNull | ( | ) | const |
Returns true if the timespan is empty.
| bool wxTimeSpan::IsPositive | ( | ) | const |
Returns true if the timespan is positive.
| bool wxTimeSpan::IsShorterThan | ( | const wxTimeSpan & | ts | ) | const |
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.
|
static |
Returns the timespan for one millisecond.
|
static |
Returns the timespan for the given number of milliseconds.
|
static |
Returns the timespan for one minute.
|
static |
Returns the timespan for the given number of minutes.
| wxTimeSpan wxTimeSpan::Multiply | ( | int | n | ) | const |
Returns the product of this time span by n.
| wxTimeSpan& wxTimeSpan::Multiply | ( | int | n | ) |
Multiplies this time span by n.
| wxTimeSpan& wxTimeSpan::Neg | ( | ) |
Negate the value of the timespan.
| wxTimeSpan wxTimeSpan::Negate | ( | ) | const |
Returns timespan with inverted sign.
| wxTimeSpan& wxTimeSpan::operator*= | ( | int | n | ) |
Multiplies this time span by n.
| wxTimeSpan& wxTimeSpan::operator+= | ( | const wxTimeSpan & | diff | ) |
Adds the given wxTimeSpan to this wxTimeSpan and returns the result.
| wxTimeSpan& wxTimeSpan::operator- | ( | ) |
Negate the value of the timespan.
| wxTimeSpan& wxTimeSpan::operator-= | ( | const wxTimeSpan & | diff | ) |
Subtracts the given wxTimeSpan to this wxTimeSpan and returns the result.
|
static |
Returns the timespan for one second.
|
static |
Returns the timespan for the given number of seconds.
| wxTimeSpan wxTimeSpan::Subtract | ( | const wxTimeSpan & | diff | ) | const |
Returns the difference of two time spans.
| wxTimeSpan& wxTimeSpan::Subtract | ( | const wxTimeSpan & | diff | ) |
Subtracts the given wxTimeSpan to this wxTimeSpan and returns a reference to itself.
|
static |
Returns the timespan for one week.
|
static |
Returns the timespan for the given number of weeks.