#include <wx/datetime.h>
wxTimeSpan class represents a time interval.
Public Member Functions | |
wxTimeSpan () | |
Default constructor, constructs a zero timespan. More... | |
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. More... | |
wxTimeSpan | Abs () const |
Returns the absolute value of the timespan: does not modify the object. More... | |
wxTimeSpan | Add (const wxTimeSpan &diff) const |
Returns the sum of two time spans. More... | |
wxTimeSpan & | Add (const wxTimeSpan &diff) |
Adds the given wxTimeSpan to this wxTimeSpan and returns a reference to itself. More... | |
wxString | Format (const wxString &format=wxDefaultTimeSpanFormat) const |
Returns the string containing the formatted representation of the time span. More... | |
int | GetDays () const |
Returns the difference in number of days. More... | |
int | GetHours () const |
Returns the difference in number of hours. More... | |
wxLongLong | GetMilliseconds () const |
Returns the difference in number of milliseconds. More... | |
int | GetMinutes () const |
Returns the difference in number of minutes. More... | |
wxLongLong | GetSeconds () const |
Returns the difference in number of seconds. More... | |
wxLongLong | GetValue () const |
Returns the internal representation of timespan. More... | |
int | GetWeeks () const |
Returns the difference in number of weeks. More... | |
bool | IsEqualTo (const wxTimeSpan &ts) const |
Returns true if two timespans are equal. More... | |
bool | IsLongerThan (const wxTimeSpan &ts) const |
Compares two timespans: works with the absolute values, i.e. -2 hours is longer than 1 hour. More... | |
bool | IsNegative () const |
Returns true if the timespan is negative. More... | |
bool | IsNull () const |
Returns true if the timespan is empty. More... | |
bool | IsPositive () const |
Returns true if the timespan is positive. More... | |
bool | IsShorterThan (const wxTimeSpan &ts) const |
Compares two timespans: works with the absolute values, i.e. 1 hour is shorter than -2 hours. More... | |
wxTimeSpan | Multiply (int n) const |
Returns the product of this time span by n. More... | |
wxTimeSpan & | Multiply (int n) |
Multiplies this time span by n. More... | |
wxTimeSpan & | Neg () |
Negate the value of the timespan. More... | |
wxTimeSpan | Negate () const |
Returns timespan with inverted sign. More... | |
wxTimeSpan | Subtract (const wxTimeSpan &diff) const |
Returns the difference of two time spans. More... | |
wxTimeSpan & | Subtract (const wxTimeSpan &diff) |
Subtracts the given wxTimeSpan to this wxTimeSpan and returns a reference to itself. More... | |
wxTimeSpan & | operator+= (const wxTimeSpan &diff) |
Adds the given wxTimeSpan to this wxTimeSpan and returns the result. More... | |
wxTimeSpan & | operator*= (int n) |
Multiplies this time span by n. More... | |
wxTimeSpan & | operator- () |
Negate the value of the timespan. More... | |
wxTimeSpan & | operator-= (const wxTimeSpan &diff) |
Subtracts the given wxTimeSpan to this wxTimeSpan and returns the result. More... | |
Static Public Member Functions | |
static wxTimeSpan | Day () |
Returns the timespan for one day. More... | |
static wxTimeSpan | Days (long days) |
Returns the timespan for the given number of days. More... | |
static wxTimeSpan | Hour () |
Returns the timespan for one hour. More... | |
static wxTimeSpan | Hours (long hours) |
Returns the timespan for the given number of hours. More... | |
static wxTimeSpan | Millisecond () |
Returns the timespan for one millisecond. More... | |
static wxTimeSpan | Milliseconds (wxLongLong ms) |
Returns the timespan for the given number of milliseconds. More... | |
static wxTimeSpan | Minute () |
Returns the timespan for one minute. More... | |
static wxTimeSpan | Minutes (long min) |
Returns the timespan for the given number of minutes. More... | |
static wxTimeSpan | Second () |
Returns the timespan for one second. More... | |
static wxTimeSpan | Seconds (wxLongLong sec) |
Returns the timespan for the given number of seconds. More... | |
static wxTimeSpan | Week () |
Returns the timespan for one week. More... | |
static wxTimeSpan | Weeks (long weeks) |
Returns the timespan for the given number of weeks. More... | |
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.