.. wxPython Phoenix documentation This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. Copyright: (c) 2011-2020 by Total Control Software License: wxWindows License .. include:: headings.inc .. _wx.TimeSpan: ========================================================================================================================================== |phoenix_title| **wx.TimeSpan** ========================================================================================================================================== :ref:`wx.TimeSpan` class represents a time interval. .. seealso:: :ref:`Date and Time `, :ref:`wx.DateTime` | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class TimeSpan:
| |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.TimeSpan.__init__` Default constructor, constructs a zero timespan. :meth:`~wx.TimeSpan.Abs` Returns the absolute value of the timespan: does not modify the object. :meth:`~wx.TimeSpan.Add` Adds the given :ref:`wx.TimeSpan` to this :ref:`wx.TimeSpan` and returns a reference to itself. :meth:`~wx.TimeSpan.Day` Returns the timespan for one day. :meth:`~wx.TimeSpan.Days` Returns the timespan for the given number of days. :meth:`~wx.TimeSpan.Format` Returns the string containing the formatted representation of the time span. :meth:`~wx.TimeSpan.GetDays` Returns the difference in number of days. :meth:`~wx.TimeSpan.GetHours` Returns the difference in number of hours. :meth:`~wx.TimeSpan.GetMilliseconds` Returns the difference in number of milliseconds. :meth:`~wx.TimeSpan.GetMinutes` Returns the difference in number of minutes. :meth:`~wx.TimeSpan.GetSeconds` Returns the difference in number of seconds. :meth:`~wx.TimeSpan.GetValue` Returns the internal representation of timespan. :meth:`~wx.TimeSpan.GetWeeks` Returns the difference in number of weeks. :meth:`~wx.TimeSpan.Hour` Returns the timespan for one hour. :meth:`~wx.TimeSpan.Hours` Returns the timespan for the given number of hours. :meth:`~wx.TimeSpan.IsEqualTo` Returns ``True`` if two timespans are equal. :meth:`~wx.TimeSpan.IsLongerThan` Compares two timespans: works with the absolute values, i.e. -2 hours is longer than 1 hour. :meth:`~wx.TimeSpan.IsNegative` Returns ``True`` if the timespan is negative. :meth:`~wx.TimeSpan.IsNull` Returns ``True`` if the timespan is empty. :meth:`~wx.TimeSpan.IsPositive` Returns ``True`` if the timespan is positive. :meth:`~wx.TimeSpan.IsShorterThan` Compares two timespans: works with the absolute values, i.e. 1 hour is shorter than -2 hours. :meth:`~wx.TimeSpan.Millisecond` Returns the timespan for one millisecond. :meth:`~wx.TimeSpan.Milliseconds` Returns the timespan for the given number of milliseconds. :meth:`~wx.TimeSpan.Minute` Returns the timespan for one minute. :meth:`~wx.TimeSpan.Minutes` Returns the timespan for the given number of minutes. :meth:`~wx.TimeSpan.Multiply` Multiplies this time span by `n`. :meth:`~wx.TimeSpan.Neg` Negate the value of the timespan. :meth:`~wx.TimeSpan.Negate` Returns timespan with inverted sign. :meth:`~wx.TimeSpan.Second` Returns the timespan for one second. :meth:`~wx.TimeSpan.Seconds` Returns the timespan for the given number of seconds. :meth:`~wx.TimeSpan.Subtract` Subtracts the given :ref:`wx.TimeSpan` to this :ref:`wx.TimeSpan` and returns a reference to itself. :meth:`~wx.TimeSpan.Week` Returns the timespan for one week. :meth:`~wx.TimeSpan.Weeks` Returns the timespan for the given number of weeks. ================================================================================ ================================================================================ | |api| Class API =============== .. class:: wx.TimeSpan(object) **Possible constructors**:: TimeSpan() TimeSpan(hours, min=0, sec=0, msec=0) TimeSpan class represents a time interval. .. method:: __init__(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **__init__** `(self)` Default constructor, constructs a zero timespan. :html:`

` **__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. :param `hours`: :type `hours`: long :param `min`: :type `min`: long :param `sec`: :type `sec`: long :param `msec`: :type `msec`: long :html:`

` .. method:: Abs(self) Returns the absolute value of the timespan: does not modify the object. :rtype: :ref:`wx.TimeSpan` .. method:: Add(self, diff) Adds the given :ref:`wx.TimeSpan` to this :ref:`wx.TimeSpan` and returns a reference to itself. :param `diff`: :type `diff`: wx.TimeSpan :rtype: :ref:`wx.TimeSpan` .. staticmethod:: Day() Returns the timespan for one day. :rtype: :ref:`wx.TimeSpan` .. staticmethod:: Days(days) Returns the timespan for the given number of days. :param `days`: :type `days`: long :rtype: :ref:`wx.TimeSpan` .. method:: 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 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. :ref:`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. :param `format`: :type `format`: string :rtype: `string` .. method:: GetDays(self) Returns the difference in number of days. :rtype: `int` .. method:: GetHours(self) Returns the difference in number of hours. :rtype: `int` .. method:: GetMilliseconds(self) Returns the difference in number of milliseconds. :rtype: `long` .. method:: GetMinutes(self) Returns the difference in number of minutes. :rtype: `int` .. method:: GetSeconds(self) Returns the difference in number of seconds. :rtype: `long` .. method:: GetValue(self) Returns the internal representation of timespan. :rtype: `long` .. method:: GetWeeks(self) Returns the difference in number of weeks. :rtype: `int` .. staticmethod:: Hour() Returns the timespan for one hour. :rtype: :ref:`wx.TimeSpan` .. staticmethod:: Hours(hours) Returns the timespan for the given number of hours. :param `hours`: :type `hours`: long :rtype: :ref:`wx.TimeSpan` .. method:: IsEqualTo(self, ts) Returns ``True`` if two timespans are equal. :param `ts`: :type `ts`: wx.TimeSpan :rtype: `bool` .. method:: 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. :param `ts`: :type `ts`: wx.TimeSpan :rtype: `bool` .. method:: IsNegative(self) Returns ``True`` if the timespan is negative. :rtype: `bool` .. method:: IsNull(self) Returns ``True`` if the timespan is empty. :rtype: `bool` .. method:: IsPositive(self) Returns ``True`` if the timespan is positive. :rtype: `bool` .. method:: 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. :param `ts`: :type `ts`: wx.TimeSpan :rtype: `bool` .. staticmethod:: Millisecond() Returns the timespan for one millisecond. :rtype: :ref:`wx.TimeSpan` .. staticmethod:: Milliseconds(ms) Returns the timespan for the given number of milliseconds. :param `ms`: :type `ms`: long :rtype: :ref:`wx.TimeSpan` .. staticmethod:: Minute() Returns the timespan for one minute. :rtype: :ref:`wx.TimeSpan` .. staticmethod:: Minutes(min) Returns the timespan for the given number of minutes. :param `min`: :type `min`: long :rtype: :ref:`wx.TimeSpan` .. method:: Multiply(self, n) Multiplies this time span by `n`. :param `n`: :type `n`: int :rtype: :ref:`wx.TimeSpan` :returns: A reference to this :ref:`wx.TimeSpan` object modified in place. .. method:: Neg(self) Negate the value of the timespan. :rtype: :ref:`wx.TimeSpan` .. seealso:: :meth:`Negate` .. method:: Negate(self) Returns timespan with inverted sign. :rtype: :ref:`wx.TimeSpan` .. seealso:: :meth:`Neg` .. staticmethod:: Second() Returns the timespan for one second. :rtype: :ref:`wx.TimeSpan` .. staticmethod:: Seconds(sec) Returns the timespan for the given number of seconds. :param `sec`: :type `sec`: long :rtype: :ref:`wx.TimeSpan` .. method:: Subtract(self, diff) Subtracts the given :ref:`wx.TimeSpan` to this :ref:`wx.TimeSpan` and returns a reference to itself. :param `diff`: :type `diff`: wx.TimeSpan :rtype: :ref:`wx.TimeSpan` .. staticmethod:: Week() Returns the timespan for one week. :rtype: :ref:`wx.TimeSpan` .. staticmethod:: Weeks(weeks) Returns the timespan for the given number of weeks. :param `weeks`: :type `weeks`: long :rtype: :ref:`wx.TimeSpan`