Skip to content

Persian ↔ Gregorian Conversion Precision & Bug Fixes

Latest

Choose a tag to compare

@shahabfar shahabfar released this 04 May 23:20
0e1d4e1

Fixed off-by-one epoch error
The Persian-to-Julian-Day routine now correctly uses the civil epoch (midnight starting 1 Farvardin 1 → JDN 1948319.5) and removes any inadvertent “±1 day” shifts.

Accurate 33-year leap-year cycle
We replaced the previous arithmetic shortcut with the exact civil pattern (leap years at remainders 1, 5, 9, 13, 17, 22, 26, 30 mod 33). This restores the correct Nowruz dates.

Robust Gregorian conversion
The Julian-Day-to-Gregorian algorithm now uses Z = floor(JDN + 0.5) for proper civil-day alignment and the classic Meeus formulation, eliminating earlier “+ 1 day” rounding errors.