Time Conversion

ethioqen.time_conversion.convert_from_ethiopian_time(eth_hour: int, minute: int, is_pm: bool = False) → tuple[int, int][source]

Convert Ethiopian time to 24-hour standard time.

Parameters:
  • eth_hour – Ethiopian hour (1-12).

  • minute – Minutes (0-59).

  • is_pm – Whether the time is PM (night). Defaults to False (day).

Returns:

Tuple (hour in 0-23, minute).

Raises:

InvalidTimeException – If the Ethiopian time is invalid.

Example

>>> convert_from_ethiopian_time(8, 30, is_pm=False)
(14, 30)
ethioqen.time_conversion.convert_to_ethiopian_time(hour: int, minute: int, period: str | None = None) → tuple[int, int, bool][source]

Convert standard time to Ethiopian time.

Parameters:
  • hour – Standard hour. 0-23, or 1-12 when period is given.

  • minute – Minutes (0-59).

  • period – Optional “AM”/”PM” qualifying a 12-hour input hour.

Returns:

00-17:59 standard is day (is_pm False), otherwise night (is_pm True).

Return type:

Tuple (eth_hour in 1-12, minute, is_pm boolean). 06

Raises:

InvalidTimeException – On invalid time, bad period, or a 12-hour period combined with an hour outside 1-12.

Example

>>> convert_to_ethiopian_time(14, 30)
(8, 30, False)
ethioqen.time_conversion.eth_to_24h(eth_hour: int, is_pm: bool) → int[source]

Convert Ethiopian 12-hour time to 24-hour standard time.

The Ethiopian clock runs 6 hours behind the standard clock: 12:00 AM Ethiopian is 6:00 standard, 12:00 PM Ethiopian is 18:00.

Parameters:
  • eth_hour – Ethiopian hour (1-12).

  • is_pm – Whether the time is PM (night) as opposed to AM (day).

Returns:

Hour in 24-hour format (0-23).

Raises:

InvalidTimeException – If eth_hour is outside 1-12.

ethioqen.time_conversion.h24_to_eth(hour_24: int) → tuple[int, bool][source]

Convert 24-hour standard time to Ethiopian 12-hour time.

Parameters:

hour_24 – Standard hour (0-23).

Returns:

Tuple (eth_hour in 1-12, is_pm boolean).

Raises:

InvalidTimeException – If hour_24 is outside 0-23.