FarsiWeb has published Jalali, a Free Software library to convert between the Iranian calendar (Hejri-e Shamsi) and the Gregorian date systems:
Note: These may be out of date.
- Windows executable and sources (ported by Mehrdad Sabetzadeh)
- Palm OS 4.0 executable and sources
- PocketPC executable and sources and its screenshot
Jalali implements the simple 33-year arithmetic calendar, which is not the same as the official Iranian calendar. But this arithmetic calendar has been confirmed to produce the same results as the official Iranian calendar at least from 1925 C.E., when the calendar was officially introduced, to 2088 C.E. This is the same algorithm that is used in Mono and Microsoft's .NET (Microsoft's documentation).
The Iranian law explicitly mentions that the true solar year should be used, which requires astronomical calculations of the March equinox and the solar apparent noon. The exact locale for observation of the apparent noon is not mentioned in the 1925 Iranian law, but the current practice is using the 52.5° E meridian, which is the meridian defining the official timezone of Iran.
Also, please note that implementing the Persian calendar using the 2820-year arithmetic algorithm, as suggested by Ahmad Birashk and others (and mistakenly attributed to Omar Khayyam), is less accurate than the 33-year calendar: first, it fails earlier than the 33-year cycle in matching the official astronomical calendar (first failure is in 2025 C.E.), and second, the 2820-year suggested rule is based on the mean tropical year, not the mean March equinoctial year.