Skip to content
/ jdate Public

A free software for Jalali and shamsi date to get current date in jalali calendar.

License

Notifications You must be signed in to change notification settings

BaseMax/jdate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

jdate

A free software for Jalali and shamsi date to get current date in jalali calendar.

Features

  • Convert date to jalali, shamsi calendar and getting current date
  • Getting name of days (day of week)
  • Getting name of months

Using

$ jdate --auto

1399/1/3 - فروردين - يکشنبه

$ jdate 2020 03 22

1399/1/3 - فروردين - يکشنبه

Compiling

$ cd src/
$ gcc jdate.c -o jdate -O3
$ move jdate /usr/bin/

Dependencies

It will use $ date if you pass --auto argument.

Jalali calendar help

The Persian Calendar

The Persian calendar is a solar calendar with a starting point that matches that of the Islamic calendar. Apart from that, the two calendars are not related. The origin of the Persian calendar can be traced back to the 11th century when a group of astronomers (including the well-known poet Omar Khayyam, pictured above) created what is known as the Jalaali calendar. However, a number of changes have been made to the calendar since then.

The current calendar has been used in Iran since 1925 and in Afghanistan since 1957. However, Afghanistan used the Islamic calendar in the years 1999-2002.

The names and lengths of the 12 months that comprise the Persian year are:

1. Farvardin (31 days) 7. Mehr (30 days)
2. Ordibehesht (31 days) 8. Aban (30 days)
3. Khordad (31 days) 9. Azar (30 days)
4. Tir (31 days) 10. Day (30 days)
5. Mordad (31 days) 11. Bahman (30 days)
6. Shahrivar (31 days) 12. Esfand (29/30 days)

(Due to different transliterations of the Persian alphabet, other spellings of the months are possible.) In Afghanistan the months are named differently.

The month of Esfand has 29 days in an ordinary year, 30 days in a leap year.

The Persian year starts at vernal equinox. If the astronomical vernal equinox falls before noon (Tehran true time) on a particular day, then that day is the first day of the year. If the astronomical vernal equinox falls after noon, the following day is the first day of the year.

As in the Islamic calendar, years are counted since Mohammed’s emigration to Medina in AD 622. At vernal equinox of that year, AP 1 started (AP = Anno Persico/Anno Persarum = Persian year).

Note that contrary to the Islamic calendar, the Persian calendar counts solar years. In the year AD 2011 we have therefore witnessed the start of Persian year 1390, but the start of Islamic year 1432.

Since the Persian year is defined by the astronomical vernal equinox, the answer is simply: Leap years are years in which there are 366 days between two Persian new year’s days.

However, basing the Persian calendar purely on an astronomical observation of the vernal equinox is rejected by many, and a few mathematical rules for determining the length of the year have been suggested.

The most popular (and complex) of these is probably the following:

The calendar is divided into periods of 2820 years. These periods are then divided into 88 cycles whose lengths follow this pattern:

29, 33, 33, 33, 29, 33, 33, 33, 29, 33, 33, 33, ...

This gives 2816 years. The total of 2820 years is achieved by extending the last cycle by 4 years (for a total of 37 years).

If you number the years within each cycle starting with 0, then leap years are the years that are divisible by 4, except that the year 0 is not a leap year.

So within, say, a 29 year cycle, this is the leap year pattern:

Year Type Year Type Year Type Year Type
0 Ordinary 8 Leap 16 Leap 24 Leap
1 Ordinary 9 Ordinary 17 Ordinary 25 Ordinary
2 Ordinary 10 Ordinary 18 Ordinary 26 Ordinary
3 Ordinary 11 Ordinary 19 Ordinary 27 Ordinary
4 Leap 12 Leap 20 Leap 28 Leap
5 Ordinary 13 Ordinary 21 Ordinary
6 Ordinary 14 Ordinary 22 Ordinary
7 Ordinary 15 Ordinary 23 Ordinary

This gives a total of 683 leap years every 2820 years, which corresponds to an average year length of 365 683/2820 = 365.24220 days. This is a better approximation to the tropical year than the 365.2425 days of the Gregorian calendar.

The current 2820 year period started in the year AP 475 (AD 1096).

This “mathematical” calendar currently coincides closely with the purely astronomical calendar. In the years between AP 1244 and 1531 (AD 1865 and 2152) a discrepancy of one day is seen twice, namely in AP 1404 and 1437 (starting at vernal equinox of AD 2025 and 2058). However, outside this period, discrepancies are more frequent.


Max Base

My nickname is Max, Programming language developer, Full-stack programmer. I love computer scientists, researchers, and compilers. (Max Base)

Asrez Team

A team includes some programmer, developer, designer, researcher(s) especially Max Base.

Asrez Team