Django jalali leap year is wrong for 1403

In my django app. Im using django-jalali-date package with version 1.0.1 but 1403 leap year is wrong and it detect 1404 as a leap year.

So I did found the problem with the method that package uses for detecting the leap year. its using two methods:

  • algorithmic

  • astronomical

in which algorithmic was detecting leap year wrong and astronomical detect it correctly. So in min.js file related to javaScripts of the package i just change one variable which get leapYear method from argument to hard coded "astronomical" and the issue gone away.

The issue occurs because the django-jalali-date package incorrectly detects 1404 instead of 1403 as a leap year because it is using the algorithmic method.

The package provides two methods for leap year calculation:

  1. Algorithmic: Based on a fixed rule, which can sometimes be inaccurate.

  2. Astronomical: More precise, following actual Jalali calendar rules.

To fix this, locate the JavaScript file of the package and modify the leap year calculation: and change the method from algorithmic to astronomical.

Вернуться на верх