Contents Up Previous Next

wxTimeSpan

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::Subtract
wxTimeSpan::Weeks
wxTimeSpan::Week
wxTimeSpan::wxTimeSpan


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() 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()

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() const

Returns the difference in number of days.


wxTimeSpan::GetHours

int GetHours() const

Returns the difference in number of hours.


wxTimeSpan::GetMilliseconds

wxLongLong GetMilliseconds() const

Returns the difference in number of milliseconds.


wxTimeSpan::GetMinutes

int GetMinutes() const

Returns the difference in number of minutes.


wxTimeSpan::GetSeconds

wxLongLong GetSeconds() const

Returns the difference in number of seconds.


wxTimeSpan::GetValue

wxLongLong GetValue() const

Returns the internal representation of timespan.


wxTimeSpan::GetWeeks

int GetWeeks() 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()

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() const

Returns true if the timespan is negative.


wxTimeSpan::IsNull

bool IsNull() const

Returns true if the timespan is empty.


wxTimeSpan::IsPositive

bool IsPositive() 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()

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() const

Returns timespan with inverted sign.


wxTimeSpan::Neg

wxTimeSpan& Neg()

wxTimeSpan& operator-()

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()

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()

Returns the timespan for one week.


wxTimeSpan::wxTimeSpan

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.