Skip to content

TimeZone

Qt Base Class: QTimeZone

Signature: QTimeZone(self) -> None QTimeZone(self, ianaId: Union[PySide6.QtCore.QByteArray, bytes]) -> None QTimeZone(self, offsetSeconds: int) -> None QTimeZone(self, other: Union[PySide6.QtCore.QTimeZone, PySide6.QtCore.QTimeZone.Initialization]) -> None QTimeZone(self, spec: PySide6.QtCore.QTimeZone.Initialization) -> None QTimeZone(self, zoneId: Union[PySide6.QtCore.QByteArray, bytes], offsetSeconds: int, name: str, abbreviation: str, territory: PySide6.QtCore.QLocale.Country = Instance(QLocale.AnyTerritory), comment: str = '') -> None

Base classes

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

⋔ Inheritance diagram

graph TD
  1473299803312["core.TimeZone"]
  1473243590000["QtCore.QTimeZone"]
  1473291690208["Shiboken.Object"]
  140713234304496["builtins.object"]
  1473243590000 --> 1473299803312
  1473291690208 --> 1473243590000
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: QTimeZone

Identifies how a time representation relates to UTC.

Source code in prettyqt\core\timezone.py
class TimeZone(core.QTimeZone):
    """Identifies how a time representation relates to UTC."""

    def __init__(self, *args):
        match args:
            case (str() as string, *rest):
                super().__init__(core.QByteArray(string.encode()), *rest)
            case _:
                super().__init__(*args)

    def __repr__(self):
        return get_repr(self, self.get_id())

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

    def __reduce__(self):
        return type(self), (self.get_id(),)

    def get_id(self) -> str:
        return self.id().data().decode()

    def get_display_name(
        self,
        date_time: datatypes.DateTimeType | TimeTypeStr,
        name_type: NameTypeStr | core.QTimeZone.NameType = "default",
        locale: core.QLocale | None = None,
    ) -> str:
        if date_time in list(TIME_TYPE) + list(TIME_TYPE.inverse):  # needs rework
            dt = TIME_TYPE.get_enum_value(date_time)
        else:
            dt = datatypes.to_datetime(date_time)
        return self.displayName(
            dt,
            NAME_TYPE.get_enum_value(name_type),
            locale or core.QLocale(),
        )

    def get_time_spec(self) -> constants.TimeSpecStr:
        return constants.TIME_SPEC.inverse[self.timeSpec()]