wx.TimeSpan¶
wx.TimeSpan class represents a time interval.
See also
Class Hierarchy¶
Methods Summary¶
Default constructor, constructs a zero timespan. |
|
Returns the absolute value of the timespan: does not modify the object. |
|
Adds the given wx.TimeSpan to this wx.TimeSpan and returns a reference to itself. |
|
Returns the timespan for one day. |
|
Returns the timespan for the given number of days. |
|
Returns the string containing the formatted representation of the time span. |
|
Returns the difference in number of days. |
|
Returns the difference in number of hours. |
|
Returns the difference in number of milliseconds. |
|
Returns the difference in number of minutes. |
|
Returns the difference in number of seconds. |
|
Returns the internal representation of timespan. |
|
Returns the difference in number of weeks. |
|
Returns the timespan for one hour. |
|
Returns the timespan for the given number of hours. |
|
Returns |
|
Compares two timespans: works with the absolute values, i.e. -2 hours is longer than 1 hour. |
|
Returns |
|
Returns |
|
Returns |
|
Compares two timespans: works with the absolute values, i.e. 1 hour is shorter than -2 hours. |
|
Returns the timespan for one millisecond. |
|
Returns the timespan for the given number of milliseconds. |
|
Returns the timespan for one minute. |
|
Returns the timespan for the given number of minutes. |
|
Multiplies this time span by n. |
|
Negate the value of the timespan. |
|
Returns timespan with inverted sign. |
|
Returns the timespan for one second. |
|
Returns the timespan for the given number of seconds. |
|
Subtracts the given wx.TimeSpan to this wx.TimeSpan and returns a reference to itself. |
|
Returns the timespan for one week. |
|
Returns the timespan for the given number of weeks. |
Class API¶
- class wx.TimeSpan(object)¶
Possible constructors:
TimeSpan() -> None TimeSpan(hours, min=0, sec=0, msec=0) -> None
TimeSpan class represents a time interval.
Methods¶
- __init__(self, *args, **kw)¶
-
__init__ (self)
Default constructor, constructs a zero timespan.
- Return type:
None
__init__ (self, hours, min=0, sec=0, 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.- Parameters:
hours (long)
min (long)
sec (long)
msec (long)
- Return type:
None
- Abs(self)¶
Returns the absolute value of the timespan: does not modify the object.
- Return type:
- Add(self, diff)¶
Adds the given wx.TimeSpan to this wx.TimeSpan and returns a reference to itself.
- Parameters:
diff (wx.TimeSpan)
- Return type:
- static Day()¶
Returns the timespan for one day.
- Return type:
- static Days(days)¶
Returns the timespan for the given number of days.
- Parameters:
days (long)
- Return type:
- Format(self, format=DefaultTimeSpanFormat)¶
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 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.
wx.TimeSpan resolves this ambiguity in the following way: if there had been, indeed, the
D
format specified preceding theH
, 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.
- Parameters:
format (string)
- Return type:
str
- GetDays(self)¶
Returns the difference in number of days.
- Return type:
int
- GetHours(self)¶
Returns the difference in number of hours.
- Return type:
int
- GetMilliseconds(self)¶
Returns the difference in number of milliseconds.
- Return type:
int
- GetMinutes(self)¶
Returns the difference in number of minutes.
- Return type:
int
- GetSeconds(self)¶
Returns the difference in number of seconds.
- Return type:
int
- GetValue(self)¶
Returns the internal representation of timespan.
- Return type:
int
- GetWeeks(self)¶
Returns the difference in number of weeks.
- Return type:
int
- static Hour()¶
Returns the timespan for one hour.
- Return type:
- static Hours(hours)¶
Returns the timespan for the given number of hours.
- Parameters:
hours (long)
- Return type:
- IsEqualTo(self, ts)¶
Returns
True
if two timespans are equal.- Parameters:
ts (wx.TimeSpan)
- Return type:
bool
- IsLongerThan(self, 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:
ts (wx.TimeSpan)
- Return type:
bool
- IsNegative(self)¶
Returns
True
if the timespan is negative.- Return type:
bool
- IsNull(self)¶
Returns
True
if the timespan is empty.- Return type:
bool
- IsPositive(self)¶
Returns
True
if the timespan is positive.- Return type:
bool
- IsShorterThan(self, 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:
ts (wx.TimeSpan)
- Return type:
bool
- static Millisecond()¶
Returns the timespan for one millisecond.
- Return type:
- static Milliseconds(ms)¶
Returns the timespan for the given number of milliseconds.
- Parameters:
ms (long)
- Return type:
- static Minute()¶
Returns the timespan for one minute.
- Return type:
- static Minutes(min)¶
Returns the timespan for the given number of minutes.
- Parameters:
min (long)
- Return type:
- Multiply(self, n)¶
Multiplies this time span by n.
- Parameters:
n (int)
- Return type:
- Returns:
A reference to this wx.TimeSpan object modified in place.
- Neg(self)¶
Negate the value of the timespan.
- Return type:
See also
- Negate(self)¶
Returns timespan with inverted sign.
- Return type:
See also
- static Second()¶
Returns the timespan for one second.
- Return type:
- static Seconds(sec)¶
Returns the timespan for the given number of seconds.
- Parameters:
sec (long)
- Return type:
- Subtract(self, diff)¶
Subtracts the given wx.TimeSpan to this wx.TimeSpan and returns a reference to itself.
- Parameters:
diff (wx.TimeSpan)
- Return type:
- static Week()¶
Returns the timespan for one week.
- Return type:
- static Weeks(weeks)¶
Returns the timespan for the given number of weeks.
- Parameters:
weeks (long)
- Return type: