wxTimeSpan class represents a time interval.
Derived from
No base class
Include files
<wx/datetime.h>
See also
Date classes overview, wxDateTime
Function groups
Static functions
Constructors
Accessors
Operations
Tests
Formatting time spans
wxTimeSpan::Abs
wxTimeSpan::Add
wxTimeSpan::Days
wxTimeSpan::Day
wxTimeSpan::Format
wxTimeSpan::GetDays
wxTimeSpan::GetHours
wxTimeSpan::GetMilliseconds
wxTimeSpan::GetMinutes
wxTimeSpan::GetSeconds
wxTimeSpan::GetValue
wxTimeSpan::GetWeeks
wxTimeSpan::Hours
wxTimeSpan::Hour
wxTimeSpan::IsEqualTo
wxTimeSpan::IsLongerThan
wxTimeSpan::IsNegative
wxTimeSpan::IsNull
wxTimeSpan::IsPositive
wxTimeSpan::IsShorterThan
wxTimeSpan::Minutes
wxTimeSpan::Minute
wxTimeSpan::Multiply
wxTimeSpan::Negate
wxTimeSpan::Neg
wxTimeSpan::Seconds
wxTimeSpan::Second
wxTimeSpan::Substract
wxTimeSpan::Weeks
wxTimeSpan::Week
wxTimeSpan::wxTimeSpan
Seconds
Second
Minutes
Minute
Hours
Hour
Days
Day
Weeks
Week
GetSeconds
GetMinutes
GetHours
GetDays
GetWeeks
GetValue
Add
Substract
Multiply
Negate
Neg
Abs
IsNull
IsPositive
IsNegative
IsEqualTo
IsLongerThan
IsShorterThan
wxTimeSpan Abs() const
Returns the absolute value of the timespan: does not modify the object.
wxTimeSpan Add(const wxTimeSpan& diff) const
wxTimeSpan& Add(const wxTimeSpan& diff)
wxTimeSpan& operator+=(const wxTimeSpan&diff)
Returns the sum of two timespans.
static wxTimespan Days(long days)
Returns the timespan for the given number of days.
static wxTimespan Day()
Returns the timespan for one day.
wxString Format(const wxChar * format = "%H:%M:%S")
Returns the string containing the formatted representation of the time span. The following format specifiers are allowed after %:
H | number of Hours |
M | number of Minutes |
S | number of Seconds |
l | number of milliseconds |
D | number of Days |
E | number of wEeks |
% | the percent character |
Note 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 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.
static wxTimespan Hours(long hours)
Returns the timespan for the given number of hours.
static wxTimespan Hour()
Returns the timespan for one hour.
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. Also, it will return false if the timespans are equal in absolute value.
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. Also, it will return false if the timespans are equal in absolute value.
static wxTimespan Minutes(long min)
Returns the timespan for the given number of minutes.
static wxTimespan Minute()
Returns the timespan for one minute.
wxTimeSpan Multiply(int n) const
wxTimeSpan& Multiply(int n)
wxTimeSpan& operator*=(int n)
Multiplies timespan by a scalar.
wxTimeSpan Negate() const
Returns timespan with inversed sign.
wxTimeSpan& Neg()
wxTimeSpan& operator-()
Negate the value of the timespan.
static wxTimespan Seconds(long sec)
Returns the timespan for the given number of seconds.
static wxTimespan Second()
Returns the timespan for one second.
wxTimeSpan Substract(const wxTimeSpan&diff) const
wxTimeSpan& Substract(const wxTimeSpan& diff)
wxTimeSpan& operator-=(const wxTimeSpan&diff)
Returns the difference of two timespans.
static wxTimespan Weeks(long weeks)
Returns the timespan for the given number of weeks.
static wxTimespan Week()
Returns the timespan for one week.
wxTimeSpan()
Default constructor, constructs a zero timespan.
wxTimeSpan(long hours, long min, long sec, long msec)
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.