This commit is contained in:
doms9 2025-10-01 14:56:15 -04:00
parent 7cabebb529
commit 00000d940b
4 changed files with 13 additions and 13 deletions

View file

@ -11,7 +11,7 @@ ZONES["EDT"] = ZONES["EST"] = ZONES["ET"]
class Time(datetime):
TZ = timezone.utc
TZ = ZONES["ET"]
@classmethod
def now(cls) -> "Time":
@ -42,6 +42,7 @@ class Time(datetime):
formats = [
"%Y-%m-%d %H:%M",
"%Y-%m-%d %H:%M:%S",
"%a, %d %b %Y %H:%M:%S %z",
]
for frmt in formats:
@ -53,7 +54,8 @@ class Time(datetime):
else:
return cls.from_ts(31496400)
dt = tz.localize(dt) if hasattr(tz, "localize") else dt.replace(tzinfo=tz)
if not dt.tzinfo:
dt = tz.localize(dt) if hasattr(tz, "localize") else dt.replace(tzinfo=tz)
return cls.fromtimestamp(dt.astimezone(cls.TZ).timestamp(), tz=cls.TZ)