Kurdish solar calendar and conversions (Gregorian, Persian/Jalali, tabular Islamic) using the Python standard library only.
Project description
pyroj (Kurdish Calendar)
pyroj is the definitive Python library for the Kurdish solar calendar. It allows for highly accurate date conversions to and from Gregorian, Persian (Jalali), and Tabular Islamic dates.
Built exclusively under the Python standard library, it inherits natively from Python's own datetime ecosystem, serving as a dynamic, robust drop-in replacement for any application. Runtime dependencies: none.
- Python: 3.10+
- Dependency/tool workflow:
uv+pyproject.toml - Supported year range:
1..9999(aligned with Pythondatetime.date)
[Research Reference & Calculation Details]
For academics, developers, and researchers seeking the complete historical methodology, epoch derivations, and algorithmic calculations used to yield accurate Kurdish dates, please refer to the detailed Kurdish Date Calculation Research.
Quick Start
KurdishDate and KurdishDateTime inherit natively from python's built-in datetime.date and datetime.datetime. Any standard operation you perform on Python dates can be seamlessly performed on Kurdish dates!
uv pip install pyroj
# or
pip install pyroj
Basic Creation and Conversions
from datetime import date
from pyroj.kurdish import KurdishDate
# 1. Start from a Gregorian Date
d = date(2026, 3, 23)
kd = KurdishDate.from_gregorian(d)
print(kd.year, kd.month, kd.day) # Output: 2726 1 3
# 2. Or initialize natively in Kurdish
kd_native = KurdishDate(2726, 1, 3)
# 3. Effortless Conversions to other systems
print(kd.to_gregorian()) # Output: 2026-03-23
print(kd.to_persian()) # Output: (1405, 1, 3)
print(kd.to_islamic()) # Output: (1447, 10, 4)
Advanced Date Mathematics
Because pyroj extends standard lib classes natively, you can rely on robust Python implementations for adding/subtracting ranges without worrying about leap years or skipped months!
from datetime import timedelta
from pyroj.kurdish import KurdishDateTime
# Adding 5 days over month boundaries calculates correctly
kd = KurdishDate(2726, 1, 30)
kd_new = kd + timedelta(days=5)
print(kd_new) # Output: 2726-02-04
# Full Time/Datetime wrappers exist
kdt = KurdishDateTime(2726, 1, 3, hour=15, minute=30, second=0)
kdt_shuffled = kdt - timedelta(hours=36)
print(kdt_shuffled) # Output: 2726-01-02 03:30:00
Beautiful Native Formatting (strftime)
Formatting strings out of the box matches Python's % standard exactly. Furthermore, pyroj natively maps out month and weekday translations depending on your selected locale.
Supported LocaleId dialects include KU (Sorani / Kurdish-Arabic script), AR (Arabic), FA (Persian), TR (Turkish), and EN (English).
from pyroj.kurdish import KurdishDate
from pyroj.locales import LocaleId
kd = KurdishDate(2726, 1, 25)
# Standard English representation
print(kd.strftime("%A, %d %B %Y", locale=LocaleId.EN))
# Output: Tuesday, 25 Xakelêwe 2726
# Sorani execution
print(kd.strftime("%A, %d %B %Y", locale=LocaleId.KU))
# Output: سێشەممە, 25 خاکەلێوە 2726
# Persian representation
print(kd.strftime("%A, %d %B %Y", locale=LocaleId.FA))
# Output: سهشنبه, 25 خاکِلِیوَه 2726
# Available formats:
# %Y (4-digit Year), %y (2-digit Year)
# %B (Full Month), %b (Short Month), %m (2-digit Month), %-m (1-digit Month)
# %A (Full Weekday), %a (Short Weekday), %w (1-7 Index), %-w (1-7 Number)
# %d (2-digit Day), %-d (1-digit Day)
# %H:%M:%S etc. for KurdishDateTime.
Historical Eras
Historically, different subsets of researchers align Year 1 of the Kurdish Calendar differently. pyroj accommodates this dynamically via the KurdishEra Enum:
- Median Empire Baseline
SOLAR_PERSIAN_OFFSET(Default): Evaluates the standard Kurdipedia offset whereKurdish Year = Jalali Year + 1321. (Anchored near 700 BC). - Fall of Nineveh Epoch
FALL_OF_NINEVEH: Tracks the exact 612 BC battle of Nineveh whereKurdish Year = Jalali Year + 1233.
from pyroj.kurdish import KurdishDate, KurdishEra
# Calculates the year offset depending on standard
kd_nineveh = KurdishDate(2638, 1, 3, era=KurdishEra.FALL_OF_NINEVEH)
print(kd_nineveh.to_gregorian()) # Extrapolates out correctly
Native Tooling (JDN Helpers & Timestamps)
You can convert any Gregorian or Julian representation efficiently down into int / float structs.
from pyroj._core.convert import gregorian_datetime_to_jdn, jdn_to_gregorian_datetime
from pyroj.kurdish import KurdishDate
# Extract absolute Julian Day Number directly
kd = KurdishDate(2726, 1, 1)
print(kd.to_jdn()) # Returns Absolute JDN float
# Restore from JDN
kd_restored = KurdishDate.from_jdn(2461122.5)
Development setup (uv + ruff)
uv sync --extra dev
uv run pytest -q
uv run ruff check pyroj tests
uv run mypy pyroj
Install the package locally for development:
uv pip install -e .
Continuous integration
GitHub Actions runs pytest, ruff, and mypy on Python 3.10–3.13 (see .github/workflows/ci.yml).
License
GPL.
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 pyroj-1.2.1.tar.gz.
File metadata
- Download URL: pyroj-1.2.1.tar.gz
- Upload date:
- Size: 34.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29adc00dc5043308c54635112567f2e11391fa6155b9f45c2041aa9e60d7d5af
|
|
| MD5 |
684873d427a064342a5b788bdd22aab8
|
|
| BLAKE2b-256 |
11a01a061de5edc4924839870fd9c4e2882b1d5a492b2ce8d008e763a50605e7
|
File details
Details for the file pyroj-1.2.1-py3-none-any.whl.
File metadata
- Download URL: pyroj-1.2.1-py3-none-any.whl
- Upload date:
- Size: 32.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cc4c1d3a25e2649d885da18c849351b20439af5df1ea6a2433434a8b64a7532
|
|
| MD5 |
9c5d091d9f153fc79a35d72e7bd1681b
|
|
| BLAKE2b-256 |
9c1d0f73e853004d93898bd3f70c3d2e2e61961dd9ff59f307e08f516e5fe22a
|