Module shahanshahi

Module shahanshahi 

Source
Expand description

Shahanshahi (Imperial Persian) to Gregorian date conversion. Shahanshahi (Imperial Persian) calendar conversion.

The Shahanshahi calendar uses the same months and leap year rules as the Solar Hijri (Jalali) calendar, but counts years from the founding of the Persian Empire by Cyrus the Great. The year offset is +1180 relative to Jalali (e.g. Jalali 1404 = Shahanshahi 2584).

Internally, conversion to/from Gregorian uses the Jalali algorithm with the offset applied at the public API boundary.

Functions§

days_in_month
Get the number of days in a given Shahanshahi month.
gregorian_to_shahanshahi
Convert a Gregorian date to Shahanshahi date. Returns (year, month, day) where month is 1-based.
is_leap
Check if a Shahanshahi year is a leap year. Uses the 33-year sub-cycle on the underlying Jalali year.
shahanshahi_to_gregorian
Convert a Shahanshahi date to Gregorian. Returns (year, month, day).
today
Get today’s date in the Shahanshahi calendar.
weekday_of_first
Get the weekday of the first day of a Shahanshahi month. Returns 0=Saturday, 1=Sunday, …, 6=Friday (Iranian week).