Converting dates between the Shamsi (Solar Hijri/Persian) and Miladi (Gregorian) calendars is simple once you understand the fixed offsets and month lengths. 1. Key Conversion Formula
year = self.year month = self.month day = self.dayTarikh Miladi – Advantages
✅ Global standard – passports, visas, airline tickets, UN documents, SWIFT banking, scientific publications.
✅ Simple leap year rule (divisible by 4, except centuries not divisible by 400).
✅ Week structure (7-day week) and month boundaries consistent across cultures.
This pattern is more mathematically consistent than Miladi’s arbitrary 28–31 day variation.
# Calculate Gregorian leap years passed up to g_year # (Using standard Gregorian leap year logic) g_leaps = (g_year - 1) // 4 - (g_year - 1) // 100 + (g_year - 1) // 400