wx.TimeSpan

Inheritance diagram for wx.TimeSpan:



Class API

Methods

__init__(hours=0, minutes=0, seconds=0, milliseconds=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.

Parameters:

  • hours (long)
  • minutes (long)
  • seconds (long)
  • milliseconds (long)

Returns:

wx.TimeSpan


Abs()

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


Returns:

wx.TimeSpan


Add(diff)

Returns the sum of two timespans.

Parameters:


Returns:

wx.TimeSpan


Day()

Returns the timespan for one day.


Returns:

wx.TimeSpan


Days(days)

Returns the timespan for the given number of days.

Parameters:

  • days (long)

Returns:

wx.TimeSpan


Format(format=wx.DefaultTimeSpanFormat)

Returns the string containing the formatted representation of the time span.

The following format specifiers are allowed after %:

TimeSpan Format Description
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

Parameters:

  • format (string)

Returns:

string

Note

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. wx.TimeSpan 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.


GetDays()

Returns the difference in number of days.


Returns:

int


GetHours()

Returns the difference in number of hours.


Returns:

int


GetMilliseconds()

Returns the difference in number of milliseconds.


Returns:

int


GetMinutes()

Returns the difference in number of minutes.


Returns:

int


GetSeconds()

Returns the difference in number of seconds.


Returns:

int


GetWeeks()

Returns the difference in number of weeks.


Returns:

int


Hour()

Returns the timespan for one hour.


Returns:

wx.TimeSpan


Hours(hours)

Returns the timespan for the given number of hours.

Parameters:

  • hours (long)

Returns:

wx.TimeSpan


IsEqualTo(ts)

Returns True if two timespans are equal.

Parameters:


Returns:

bool


IsLongerThan(ts)

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.

Parameters:


Returns:

bool


IsNegative()

Returns True if the timespan is negative.


Returns:

bool


IsNull()

Returns True if the timespan is empty.


Returns:

bool


IsPositive()

Returns True if the timespan is positive.


Returns:

bool


IsShorterThan(ts)

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.

Parameters:


Returns:

bool


Millisecond()

Returns the timespan for one millisecond.


Returns:

wx.TimeSpan


Milliseconds(ms)

Returns the timespan for the given number of milliseconds.

Parameters:

  • ms (long)

Returns:

wx.TimeSpan


Minute()

Returns the timespan for one minute.


Returns:

wx.TimeSpan


Minutes(min)

Returns the timespan for the given number of minutes.

Parameters:

  • min (long)

Returns:

wx.TimeSpan


Multiply(n)

Multiplies timespan by a scalar.

Parameters:

  • n (int)

Returns:

wx.TimeSpan


Neg()

Negate the value of the timespan.


Returns:

wx.TimeSpan


Second()

Returns the timespan for one second.


Returns:

wx.TimeSpan


Seconds(sec)

Returns the timespan for the given number of seconds.

Parameters:

  • sec (long)

Returns:

wx.TimeSpan


Subtract(diff)

Returns the difference of two timespans.

Parameters:


Returns:

wx.TimeSpan


Week()

Returns the timespan for one week.


Returns:

wx.TimeSpan


Weeks(weeks)

Returns the timespan for the given number of weeks.

Parameters:

  • weeks (long)

Returns:

wx.TimeSpan


Properties

days
See GetDays
hours
See GetHours
milliseconds
See GetMilliseconds
minutes
See GetMinutes
seconds
See GetSeconds
weeks
See GetWeeks