from datetime import datetime, time, timedelta, timezone


def utcnow() -> datetime:
    """Current UTC time, naive (no tzinfo).

    All timestamps in this app are stored and compared as naive UTC by
    convention, so they behave the same against Postgres and against the
    SQLite engine used in tests (which has no native tz-aware datetime type).
    """
    return datetime.now(timezone.utc).replace(tzinfo=None)


# Ethiopia has a single timezone (Africa/Addis_Ababa, UTC+3) with no DST,
# so a fixed offset is correct and doesn't need the zoneinfo database —
# shared by app.services.dispatch (courier shift windows) and
# app.services.branch_hours (branch operating hours), which both compare
# a wall-clock local time-of-day against a stored schedule.
def addis_local_time(now_utc: datetime) -> time:
    return (now_utc + timedelta(hours=3)).time()


def addis_local_weekday(now_utc: datetime) -> int:
    return (now_utc + timedelta(hours=3)).weekday()
