Registry / serialization / jalali-core

jalali-core

JSON →
library1.0.0pypypi✓ verified 84d ago

A Python library for converting between Gregorian and Jalali (Persian/Solar Hijri) dates, targeting Python 3.8+. Version 1.0.0 is the first stable release, with a focus on simplicity and correctness. The library provides a single core function for conversion and is designed to be lightweight with no external dependencies. Release cadence is not yet established.

pip install jalali-core
INSTALL
IMPORT
SIG · JALALI-CORE
J
jalali-core
serializationpythonv1.0.0
Install
1.7s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GregorianToJalali
from jalali_core import GregorianToJalali
import jalali_core
Wrong: module not imported correctly. Use from import.
JalaliToGregorian
from jalali_core import JalaliToGregorian

Basic conversion between Gregorian and Jalali dates.

from jalali_core import GregorianToJalali, JalaliToGregorian import datetime g2j = GregorianToJalali() gregorian_date = datetime.date(2025, 4, 27) jalali_date = g2j(gregorian_date) print(f"Gregorian {gregorian_date} -> Jalali {jalali_date}") j2g = JalaliToGregorian() jalali_date = (1404, 2, 7) gregorian_date = j2g(jalali_date) print(f"Jalali {jalali_date} -> Gregorian {gregorian_date}")
Debug
Known issues
gotchaJalali year zero does not exist. The library expects years in the usual Jalali calendar with 1-based years (e.g., 1404). Do not pass year 0.
fix
Ensure Jalali years are positive (>= 1).
affects: 1.0.0
gotchaInput dates must be valid. The library does not validate Jalali dates; passing invalid dates (e.g., month 13) may produce incorrect results or raise exceptions.
fix
Validate Jalali dates yourself before conversion (e.g., month 1-12, day according to month).
affects: 1.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'jalali_core'
Wrong import path: some may try 'import jalali' or 'import jalali_core' but the package name is 'jalali-core' (with hyphen) and module is 'jalali_core'.
fix
Install with `pip install jalali-core`, then import as `from jalali_core import ...`.
TypeError: cannot unpack non-iterable datetime.date object
Passing a single datetime.date object to JalaliToGregorian instead of a tuple (year, month, day).
fix
Use `JalaliToGregorian()( (year, month, day) )` with a tuple argument.
Upgrade
Version history
1.0.0latest on PyPI · released Mar 25, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
jalali-core — pip install jalali-core · libregistry