ranczo-energy-usage-scrapers/utils/time_helpers.py
Bartosz Wieczorek 166d64d51e init
2025-09-02 18:14:05 +02:00

16 lines
488 B
Python

from __future__ import annotations
from datetime import time
from typing import Tuple
import zoneinfo
WARSAW_TZ = zoneinfo.ZoneInfo("Europe/Warsaw")
UTC = zoneinfo.ZoneInfo("UTC")
TimeRange = Tuple[time, time]
def in_range_local(t_local: time, rng: TimeRange) -> bool:
"""[start, end) in local time, supports ranges crossing midnight."""
start, end = rng
if start <= end:
return start <= t_local < end
return (t_local >= start) or (t_local < end)