Back to Projects
January 3, 2025
Python Library

ethioqen

A Python library for accurate and efficient conversions between Ethiopian and Gregorian calendars.

ethioqen provides comprehensive conversion capabilities between the Ethiopian calendar, Gregorian calendar, Ethiopian local time, standard 24-hour time, and Unix timestamps. Features timezone support, leap year handling, and extensive documentation with examples. Available on PyPI with comprehensive test coverage.

Usage Examples

Calendar Conversions

from ethioqen.calendar_conversion import convert_ethiopian_to_gregorian, convert_gregorian_to_ethiopian 
 
# Convert from Ethiopian to Gregorian 
greg_year, greg_month, greg_day = convert_ethiopian_to_gregorian(2016, 7, 6) 
print(f"{greg_year}-{greg_month}-{greg_day}") 
# Output: 2024-3-15 
 
# Convert from Gregorian to Ethiopian 
eth_year, eth_month, eth_day = convert_gregorian_to_ethiopian(2024, 3, 15) 
print(f"{eth_year}-{eth_month}-{eth_day}") 
# Output: 2016-7-6

Time Conversions

from ethioqen.time_conversion import convert_to_ethiopian_time, convert_from_ethiopian_time 
 
# Convert standard time (14:30 / 2:30 PM) to Ethiopian time 
eth_hour, eth_minute, is_day = convert_to_ethiopian_time(14, 30) 
print(f"{eth_hour}:{eth_minute} {'AM' if is_day else 'PM'}") 
# Output: 8:30 PM 
 
# Convert Ethiopian time (8:30 PM) to standard time 
std_hour, std_minute = convert_from_ethiopian_time(8, 30, is_am=False) 
print(f"{std_hour:02d}:{std_minute:02d}") 
# Output: 14:30

Unix Timestamp Conversions

from ethioqen.unix_time_conversion import ethiopian_to_unix, unix_to_ethiopian 
 
# Convert Ethiopian date/time to Unix timestamp (UTC) 
# 1:30 PM Ethiopian time 
timestamp = ethiopian_to_unix(2016, 7, 6, eth_hour=1, minute=30, is_pm=True) 
print(timestamp) 
# Output: Unix timestamp 
 
# Convert Unix timestamp to Ethiopian date/time (UTC) 
eth_year, eth_month, eth_day, hour, minute, is_pm = unix_to_ethiopian(timestamp) 
print(f"{eth_year}-{eth_month}-{eth_day} {hour}:{minute:02d} {'PM' if is_pm else 'AM'}") 
# Output: 2016-7-6 1:30 PM

Timezone Support

from ethioqen.unix_time_conversion import ethiopian_to_unix, unix_to_ethiopian 
 
# Convert with timezone offset (UTC+3 for Ethiopia) 
# 8:30 AM Ethiopian time 
timestamp = ethiopian_to_unix(2016, 7, 6, eth_hour=8, minute=30, is_pm=False, tz_offset=3) 
print(timestamp) 
# Output: Unix timestamp adjusted for UTC+3 
 
# Convert back with timezone offset 
eth_date = unix_to_ethiopian(timestamp, tz_offset=3) 
print(f"{eth_date[0]}-{eth_date[1]}-{eth_date[2]} {eth_date[3]}:{eth_date[4]:02d} {'PM' if eth_date[5] else 'AM'}") 
# Output: Ethiopian date/time in UTC+3