This commit is contained in:
doms9 2025-11-14 19:27:54 -05:00
parent 3cad8619e7
commit 00000d9842
3 changed files with 285 additions and 2 deletions

View file

@ -1,6 +1,6 @@
import json
import re
from datetime import datetime, timedelta, timezone
from datetime import date, datetime, timedelta, timezone
from pathlib import Path
import pytz
@ -52,6 +52,25 @@ class Time(datetime):
dt = dt.astimezone(cls.TZ)
return cls.fromtimestamp(dt.timestamp(), tz=cls.TZ)
@classmethod
def from_only_time(cls, s: str, d: date, timezone: str) -> "Time":
hour, minute = map(int, s.split(":"))
dt = datetime(
2000,
1,
1,
hour,
minute,
tzinfo=cls.ZONES.get(timezone, cls.TZ),
)
dt = dt.astimezone(cls.TZ)
dt = datetime.combine(d, dt.timetz())
return cls.fromtimestamp(dt.timestamp(), tz=cls.TZ)
@classmethod
def from_str(
cls,
@ -140,7 +159,7 @@ class Leagues:
league: str,
) -> bool:
pattern = re.compile(r"\s+(?:-|vs\.?|at)\s+", flags=re.IGNORECASE)
pattern = re.compile(r"\s+(?:-|vs\.?|at|@)\s+", flags=re.IGNORECASE)
if pattern.search(event):
t1, t2 = re.split(pattern, event)