wxTimeSpan

wxTimeSpan class represents a time interval.

Derived from

No base class

Include files

<wx/datetime.h>

See also

Date classes overview, wxDateTime



Static functions

Seconds
Second
Minutes
Minute
Hours
Hour
Days
Day
Weeks
Week



Constructors

wxTimeSpan



Accessors

GetSeconds
GetMinutes
GetHours
GetDays
GetWeeks
GetValue



Operations

Add
Subtract
Multiply
Negate
Neg
Abs



Tests

IsNull
IsPositive
IsNegative
IsEqualTo
IsLongerThan
IsShorterThan



Formatting time spans

Format



wxTimeSpan::Abs

wxTimeSpan Abs(void) const

Returns the absolute value of the timespan: does not modify the object.



wxTimeSpan::Add

wxTimeSpan Add(const wxTimeSpan& diff) const



wxTimeSpan& Add(const wxTimeSpan& diff)



wxTimeSpan& operator$+=$(const wxTimeSpan& diff)

Returns the sum of two timespans.



wxTimeSpan::Days



static wxTimespan Days(long days)

Returns the timespan for the given number of days.



wxTimeSpan::Day



static wxTimespan Day(void)

Returns the timespan for one day.



wxTimeSpan::Format



wxString Format(const wxChar * format = wxDefaultTimeSpanFormat)

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.



wxTimeSpan::GetDays

int GetDays(void) const

Returns the difference in number of days.



wxTimeSpan::GetHours

int GetHours(void) const

Returns the difference in number of hours.



wxTimeSpan::GetMilliseconds

wxLongLong GetMilliseconds(void) const

Returns the difference in number of milliseconds.



wxTimeSpan::GetMinutes

int GetMinutes(void) const

Returns the difference in number of minutes.



wxTimeSpan::GetSeconds

wxLongLong GetSeconds(void) const

Returns the difference in number of seconds.



wxTimeSpan::GetValue

wxLongLong GetValue(void) const

Returns the internal representation of timespan.



wxTimeSpan::GetWeeks

int GetWeeks(void) const

Returns the difference in number of weeks.



wxTimeSpan::Hours



static wxTimespan Hours(long hours)

Returns the timespan for the given number of hours.



wxTimeSpan::Hour



static wxTimespan Hour(void)

Returns the timespan for one hour.



wxTimeSpan::IsEqualTo

bool IsEqualTo(const wxTimeSpan& ts) const

Returns true if two timespans are equal.



wxTimeSpan::IsLongerThan

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.



wxTimeSpan::IsNegative

bool IsNegative(void) const

Returns true if the timespan is negative.



wxTimeSpan::IsNull

bool IsNull(void) const

Returns true if the timespan is empty.



wxTimeSpan::IsPositive

bool IsPositive(void) const

Returns true if the timespan is positive.



wxTimeSpan::IsShorterThan

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.



wxTimeSpan::Minutes



static wxTimespan Minutes(long min)

Returns the timespan for the given number of minutes.



wxTimeSpan::Minute



static wxTimespan Minute(void)

Returns the timespan for one minute.



wxTimeSpan::Multiply

wxTimeSpan Multiply(int n) const



wxTimeSpan& Multiply(int n)



wxTimeSpan& operator$*=$(int n)

Multiplies timespan by a scalar.



wxTimeSpan::Negate

wxTimeSpan Negate(void) const

Returns timespan with inverted sign.



wxTimeSpan::Neg



wxTimeSpan& Neg(void)



wxTimeSpan& operator$-$(void)

Negate the value of the timespan.



wxTimeSpan::Seconds



static wxTimespan Seconds(long sec)

Returns the timespan for the given number of seconds.



wxTimeSpan::Second



static wxTimespan Second(void)

Returns the timespan for one second.



wxTimeSpan::Subtract

wxTimeSpan Subtract(const wxTimeSpan& diff) const



wxTimeSpan& Subtract(const wxTimeSpan& diff)



wxTimeSpan& operator$-=$(const wxTimeSpan& diff)

Returns the difference of two timespans.



wxTimeSpan::Weeks



static wxTimespan Weeks(long weeks)

Returns the timespan for the given number of weeks.



wxTimeSpan::Week



static wxTimespan Week(void)

Returns the timespan for one week.



wxTimeSpan::wxTimeSpan



wxTimeSpan(void)

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.

ymasuda 平成17年11月19日