Download mathly2/clock.py from wzender/mathly: direct link, hf CLI and curl.
- Browser
- Download file 617 Bytes
-
https://huggingface.co/spaces/wzender/mathly/resolve/main/mathly2/clock.py
- Command line
-
hf download hf://spaces/wzender/mathly/mathly2/clock.py
-
curl -L -o clock.py https://huggingface.co/spaces/wzender/mathly/resolve/main/mathly2/clock.py
617 Bytes
| """Server time. Every rule that depends on days (mastery, the days left to a test) uses this, | |
| never the device's clock.""" | |
| from __future__ import annotations | |
| from datetime import date, datetime, timezone | |
| from zoneinfo import ZoneInfo | |
| ISRAEL = ZoneInfo("Asia/Jerusalem") | |
| def now() -> datetime: | |
| return datetime.now(timezone.utc) | |
| def school_day(moment: datetime | None = None) -> date: | |
| """The calendar day in Israel at `moment` (default: now).""" | |
| moment = moment or now() | |
| if moment.tzinfo is None: | |
| raise ValueError("moment must have a timezone") | |
| return moment.astimezone(ISRAEL).date() | |