Skip to content

Time

Qt Base Class: QTime

Signature: QTime(self) -> None QTime(self, QTime: PySide6.QtCore.QTime) -> None QTime(self, h: int, m: int, s: int = 0, ms: int = 0) -> None

Base classes

Name Children Inherits
QTime
PySide6.QtCore
QTime(self) -> None

⋔ Inheritance diagram

graph TD
  1473299809168["core.Time"]
  1473243743232["QtCore.QTime"]
  1473291690208["Shiboken.Object"]
  140713234304496["builtins.object"]
  1473243743232 --> 1473299809168
  1473291690208 --> 1473243743232
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: QTime

Clock time functions.

Source code in prettyqt\core\_time.py
class Time(core.QTime):
    """Clock time functions."""

    def __repr__(self):
        template = super().__repr__().split("(")[1]  # type: ignore
        return f"{type(self).__name__}({template}"

    def __str__(self):
        return self.toString()

    def __reduce__(self):
        return type(self), (self.hour(), self.minute(), self.second(), self.msec())

    def __format__(self, format_spec: str):
        return self.toString(format_spec)

    @property
    def _hour(self) -> int:
        return self.hour()

    @property
    def _minute(self) -> int:
        return self.minute()

    @property
    def _second(self) -> int:
        return self.second()

    @property
    def _msec(self) -> int:
        return self.msec()

    __match_args__ = ("_hour", "_minute", "_second", "_msec")

    def add_msecs(self, msecs: int) -> Self:
        return type(self)(self.addMSecs(msecs))

    def add_secs(self, secs: int) -> Self:
        return type(self)(self.addSecs(secs))

    @classmethod
    def get_current_time(cls) -> Self:
        return cls(cls.currentTime())

    @classmethod
    def from_string(cls, *args, **kwargs) -> Self:
        return cls(cls.fromString(*args, **kwargs))