e
This commit is contained in:
parent
b110aee1e8
commit
00000d9ba6
11 changed files with 121 additions and 135 deletions
|
|
@ -21,6 +21,14 @@ class Time(datetime):
|
|||
def from_ts(cls, ts: int | float) -> "Time":
|
||||
return cls.fromtimestamp(ts, tz=cls.TZ)
|
||||
|
||||
@classmethod
|
||||
def default_8(cls) -> float:
|
||||
return (
|
||||
cls.now()
|
||||
.replace(hour=8, minute=0, second=0, microsecond=0, tzinfo=cls.TZ)
|
||||
.timestamp()
|
||||
)
|
||||
|
||||
def delta(self, **kwargs) -> "Time":
|
||||
return self.from_ts((self + timedelta(**kwargs)).timestamp())
|
||||
|
||||
|
|
@ -66,7 +74,7 @@ class Time(datetime):
|
|||
except ValueError:
|
||||
continue
|
||||
else:
|
||||
return cls.from_ts(31496400)
|
||||
return cls.from_ts(Time.default_8())
|
||||
|
||||
if not dt.tzinfo:
|
||||
dt = tz.localize(dt) if hasattr(tz, "localize") else dt.replace(tzinfo=tz)
|
||||
|
|
@ -75,13 +83,13 @@ class Time(datetime):
|
|||
|
||||
|
||||
class Leagues:
|
||||
live_img = "https://i.gyazo.com/978f2eb4a199ca5b56b447aded0cb9e3.png"
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.data = json.loads(
|
||||
(Path(__file__).parent / "leagues.json").read_text(encoding="utf-8")
|
||||
)
|
||||
|
||||
self.live_img = "https://i.gyazo.com/978f2eb4a199ca5b56b447aded0cb9e3.png"
|
||||
|
||||
def teams(self, league: str) -> list[str]:
|
||||
return self.data["teams"].get(league, [])
|
||||
|
||||
|
|
@ -145,16 +153,12 @@ class Leagues:
|
|||
else:
|
||||
return self.info("Basketball")
|
||||
|
||||
case "Hockey":
|
||||
case "Ice Hockey" | "Hockey":
|
||||
return self.info("NHL")
|
||||
|
||||
case _:
|
||||
return self.info(sport)
|
||||
|
||||
@property
|
||||
def league_names(self) -> list[str]:
|
||||
return self.data["teams"].keys()
|
||||
|
||||
|
||||
leagues = Leagues()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue