import datetime
import zoneinfo


def time_now() -> datetime.datetime:
    return datetime.datetime.now(zoneinfo.ZoneInfo("UTC"))


def time_utc_now() -> datetime.datetime:
    return _time_in_timezone()


def _time_in_timezone(
    dt: datetime.datetime | None = None, zone_info: str | zoneinfo.ZoneInfo = "UTC"
) -> datetime.datetime:
    if dt is None:
        dt = datetime.datetime.now(zoneinfo.ZoneInfo("UTC"))
    if isinstance(zone_info, str):
        zone_info = zoneinfo.ZoneInfo(zone_info)
    return dt.astimezone(zone_info)
