Unix Time Conversion
- ethioqen.unix_time_conversion.ethiopian_to_unix(eth_year: int, eth_month: int, eth_day: int, eth_hour: int = 12, minute: int = 0, is_pm: bool = False, tz_offset: float = 0, second: int = 0) int[source]
Convert Ethiopian date/time to Unix timestamp.
- Parameters:
eth_year – Ethiopian year.
eth_month – Ethiopian month (1-13).
eth_day – Ethiopian day.
eth_hour – Hour in Ethiopian 12-hour time (1-12). Defaults to 12.
minute – Minutes (0-59). Defaults to 0.
is_pm – Whether the time is PM. Defaults to False.
tz_offset – Timezone offset in hours, may be fractional (e.g. 5.5, 5.75). Defaults to 0 (UTC). Named zones (e.g. Africa/Addis_Ababa) are future work.
second – Seconds (0-59). Defaults to 0.
- Returns:
Unix timestamp (seconds since the Unix epoch).
- Raises:
InvalidDateException – If the Ethiopian date is invalid.
InvalidTimeException – If the time components are invalid.
Example
>>> ethiopian_to_unix(2015, 1, 1, 12, 0, False) 1662876000
- ethioqen.unix_time_conversion.unix_to_ethiopian(timestamp: int | float, tz_offset: float = 0) tuple[int, int, int, int, int, int, bool][source]
Convert Unix timestamp to Ethiopian date/time.
- Parameters:
timestamp – Unix timestamp (seconds since the Unix epoch).
tz_offset – Timezone offset in hours, may be fractional. Defaults to 0 (UTC).
- Returns:
Tuple (year, month, day, eth_hour, minute, second, is_pm) with eth_hour in 12-hour format (1-12).
- Raises:
InvalidDateException – If the timestamp is not representable as a datetime on this platform.