A package for Ethiopian date and time conversions
Project description
ethioqen: Ethiopian Calendar, Time, and Unix Timestamp Conversion
⚠️ Warning: This library is in very early stages of development and should not be used in production. Contributions are crucial to make this production-ready.
ethioqen is a Python library that provides accurate and efficient conversions between the Ethiopian calendar, the Gregorian calendar, Ethiopian local time (12-hour format), standard 24-hour local time, and Unix timestamps.
Introduction
The Ethiopian calendar is a solar calendar used in Ethiopia and Eritrea. It differs significantly from the Gregorian calendar, which is the most widely used calendar system today.
Key Differences:
- Year Offset: The Ethiopian calendar is typically 7-8 years behind the Gregorian calendar.
- Months: It has 13 months: 12 months of 30 days each and a 13th month called Pagume, which has 5 days (6 days in a leap year).
- New Year: The Ethiopian New Year (Enkutatash) falls on September 11th (or 12th in a Gregorian leap year).
- Leap Years: Ethiopia follows a simple 4-year leap year cycle without the century exception found in the Gregorian calendar.
Ethiopian Local Time:
Ethiopian time uses a 12-hour clock that starts counting from dawn (around 6:00 AM standard time). This creates a 6-hour offset between Ethiopian and standard time:
- 12:00 AM Ethiopian = 6:00 AM standard time
- 1:00 AM Ethiopian = 7:00 AM standard time
- 12:00 PM Ethiopian = 6:00 PM standard time
- 6:00 PM Ethiopian = 12:00 AM standard time (next day)
Installation
pip install ethioqen
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
Contributing
We welcome contributions! Here's how you can help:
-
Report Bugs
- Open an issue in the GitHub issue tracker
- Include a clear description and steps to reproduce
-
Submit Pull Requests
- Fork the repository
- Create a new branch for your feature (
git checkout -b feature/amazing-feature) - Make your changes
- Write or update tests as needed
- Update documentation if necessary
- Submit a pull request
-
Coding Style
- Follow PEP 8 guidelines
- Include docstrings for new functions/classes
- Add type hints where possible
-
Testing
- Run the test suite:
pytest - Add tests for new features
- Ensure all tests pass before submitting
- Run the test suite:
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ethioqen-0.2.1.tar.gz.
File metadata
- Download URL: ethioqen-0.2.1.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dca2a061d0a26e7d617cd514ad46eb890bbecd58c3352cbf97b50949e6db5ca
|
|
| MD5 |
3341b0b7b8572551873d12139d744447
|
|
| BLAKE2b-256 |
ee0fff90d49a8bdf00b86cab57e2e4c95a002250330ba2a1ef834f265225b4a7
|
Provenance
The following attestation bundles were made for ethioqen-0.2.1.tar.gz:
Publisher:
publish.yml on beabzk/ethioqen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ethioqen-0.2.1.tar.gz -
Subject digest:
6dca2a061d0a26e7d617cd514ad46eb890bbecd58c3352cbf97b50949e6db5ca - Sigstore transparency entry: 159225650
- Sigstore integration time:
-
Permalink:
beabzk/ethioqen@b7a315530eab973a92cb437b8afcfdb83fac2079 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/beabzk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b7a315530eab973a92cb437b8afcfdb83fac2079 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ethioqen-0.2.1-py3-none-any.whl.
File metadata
- Download URL: ethioqen-0.2.1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0f29759ee6dbba47b1c77b1b2ff6031915b97cf96ae3893d149b5c7e3c94a28
|
|
| MD5 |
a52446177cf116f664fb01a39758ee49
|
|
| BLAKE2b-256 |
98ec6c2254dc1ea446aaad2806ea8c00c847b705aba7c7644e37a7dc414c3ae7
|
Provenance
The following attestation bundles were made for ethioqen-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on beabzk/ethioqen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ethioqen-0.2.1-py3-none-any.whl -
Subject digest:
b0f29759ee6dbba47b1c77b1b2ff6031915b97cf96ae3893d149b5c7e3c94a28 - Sigstore transparency entry: 159225651
- Sigstore integration time:
-
Permalink:
beabzk/ethioqen@b7a315530eab973a92cb437b8afcfdb83fac2079 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/beabzk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b7a315530eab973a92cb437b8afcfdb83fac2079 -
Trigger Event:
release
-
Statement type: