Persian Calendar

This book meant to collect data about Jalali/Persian Calendar, which is currently used by Iranian. I wish others help me to complete the historical information, but what I want to share is some functions about how to calculate the leap years of this calendar.

Leap Years
The year was computed from the vernal equinox, which is take 365.24219 days (The actual value is 365.2422464 days). In order to evaluate the length of one year, Khayyam made a 2820-year cycle rule to find the leap years. Leap years have 366 days and others have 365 days. Here we explain the rule and write its algorithm. The 2820-year cycle is divided into 21 subcycles of 128 years each, and a 132-year subcycle at the end of each 2820-year cycle. A 128-year subcycle consists of a 29-year sub-subcycle, followed by 3 sub-subcycles of 33 years each. Finally, the 132-year subcycle consists of one sub-subcycle of 29 years, followed by two 33-year sub-subcycles and a final sub-subcycle of 37 years. The years are numbered within each cycle. Writing n for the number of a year within a cycle, this year is a leap year if n > 1 and n mod 4 = 1. This algorithm in python3 programming language is

where 38 represents the years separating the beginning of the 2820-year cycle from Hejira - the year of Mohammed's flight from Mecca to Medina, corresponding to 621-622 AD, which the Jalali panel of scientists chose as the first year of the Iranian calendar. As you can see this algorithm is too long and slow. To improve the calculation here is an extrapolation of above function

where a and b are two parameters, which are tuned. Another function that is so useful in programming is how to extrapolate the days that passed from the epoch (FARVARDIN 1, 1) to the first day of each year (FARVARDIN 1, year).

There is no limitation for these functions as long as Kayyam rules are correct. To become convinced anyone can use this test function.