Skip to content

Latest commit

 

History

History
92 lines (67 loc) · 2.25 KB

Readme.md

File metadata and controls

92 lines (67 loc) · 2.25 KB

Jalaali Swift

A few Swift functions for converting Jalaali (Jalali, Persian, Khayyami, Khorshidi, Shamsi) and Gregorian calendar systems to each other.

About

Jalali calendar is a solar calendar that was used in Persia, variants of which today are still in use in Iran as well as Afghanistan. Read more on Wikipedia or see Calendar Converter.

Calendar conversion is based on the algorithm provided by Kazimierz M. Borkowski and has a very good performance.

Install

Use Carthage to build and install.

API

Converts a Gregorian date to Jalaali

func toJalaali(gy: GregorianYear, _ gm: GregorianMonth, _ gd: GregorianDay) -> JalaaliDate

Converts a Jalaali date to Gregorian

func toGregorian(jy: JalaaliYear, _ jm: JalaaliMonth, _ jd: JalaaliDay) -> GregorianDate

Checks whether a Jalaali date is valid or not

func isValidJalaaliDate(jy: JalaaliYear, _ jm: JalaaliMonth, _ jd: JalaaliDay) -> Bool

Is this a leap year or not?

func isLeapJalaaliYear(jy: JalaaliYear) -> Bool {

Number of days in a given month in a Jalaali year

func lastDayOfJalaaliMonth(jy: JalaaliYear, _ jm: JalaaliMonth) -> JalaaliDay

A tuple for a Jalaali date

typealias JalaaliDate = (year: JalaaliYear, month: JalaaliMonth, day: JalaaliDay)

A tuple for a Gregorian date

typealias GregorianDate = (year: GregorianYear, month: GregorianMonth, day: GregorianDay)

An Int representing a Jalaali year

typealias JalaaliYear = Int

An Int representing a Jalaali month (1-based)

typealias JalaaliMonth = Int

An Int representing a Jalaali day

typealias JalaaliDay = Int

An Int representing a Gregorian year

typealias GregorianYear = Int

An Int representing a Gregorian month (1-based)

typealias GregorianMonth = Int

An Int representing a Gregorian day

typealias GregorianDay = Int

An Int representing a Julian Day Number

typealias JulianDayNumber = Int

License

MIT