diff --git a/M3U8/scrapers/utils/config.py b/M3U8/scrapers/utils/config.py index 859d6c3..0731cf0 100644 --- a/M3U8/scrapers/utils/config.py +++ b/M3U8/scrapers/utils/config.py @@ -15,20 +15,24 @@ class Time(datetime): @classmethod def now(cls) -> "Time": - dt = datetime.now(cls.TZ) - return cls.fromtimestamp(dt.timestamp(), tz=cls.TZ) + return cls.from_ts(datetime.now(cls.TZ).timestamp()) @classmethod def from_ts(cls, ts: int | float) -> "Time": return cls.fromtimestamp(ts, tz=cls.TZ) def delta(self, **kwargs) -> "Time": - new_dt = super().__add__(timedelta(**kwargs)) - return self.__class__.fromtimestamp(new_dt.timestamp(), tz=new_dt.tzinfo) + return self.from_ts((self + timedelta(**kwargs)).timestamp()) def clean(self) -> "Time": - new_dt = super().replace(second=0, microsecond=0) - return self.__class__.fromtimestamp(new_dt.timestamp(), tz=new_dt.tzinfo) + return self.__class__.fromtimestamp( + self.replace(second=0, microsecond=0).timestamp(), + tz=self.TZ, + ) + + def to_tz(self, tzone: str) -> "Time": + dt = self.astimezone(ZONES[tzone]) + return self.__class__.fromtimestamp(dt.timestamp(), tz=ZONES[tzone]) @classmethod def from_str(cls, s: str, fmt: str | None = None) -> "Time": @@ -63,10 +67,6 @@ class Time(datetime): return cls.fromtimestamp(dt.astimezone(cls.TZ).timestamp(), tz=cls.TZ) - def to_tz(self, tzone: str) -> "Time": - dt = self.astimezone(ZONES[tzone]) - return self.__class__.fromtimestamp(dt.timestamp(), tz=ZONES[tzone]) - class Leagues: def __init__(self) -> None: