Documentation
¶
Overview ¶
Hijri is package for converting Gregorian date into Hijri date and vice versa. Hijri or Islamic calendar system itself is a lunar calendar used in many Muslim countries, with a year has 12 months and 354 days or 355 days in a leap year.
Hijri calendar only recognizes one era: A.H. (Latin "Anno Hegirae", which means "the year of the migration," in reference to the migration of Muhammad (PBUH) from Mecca). With that said, Hijri calendar is not proleptic, so there are no negative Hijri year.
This package supports two kind of Hijri calendar, the arithmetic calendar and Umm al-Qura calendar.
The arithmetic or tabular Hijri calendar (or simply Hijri) is a rule-based variation of the Islamic calendar, in which months are worked out by arithmetic rules rather than by observation or astronomical calculation. It is introduced by Muslim astronomers in the 8th century CE to predict the approximate beginning of the months in the Islamic lunar calendar.
It has a 30-year cycle with 11 leap years of 355 days and 19 years of 354 days. In the long term, it is accurate to one day in about 2,500 solar years or 2,570 lunar years. It also deviates up to about one or two days in the short term. However, there are several patterns of leap years to decide which years within the 30 are leap.
The Umm al-Qura calendar is astronomical-based calendar that used and created by Saudi Arabia. It is also used by several neighbouring states on the Arabian Peninsula such as Bahrain and Qatar. For this calendar, each month has either 29 or 30 days, but usually in no discernible order.
The implementation of Umm al-Qura calendar in this package is based on Javascript code by R.H. van Gent from Utrecht University. The date must be between 14 March 1937 (1 Muharram 1356 H) and 16 November 2077 (29 Dhu al-Hijjah 1500 H).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HijriDate ¶
type HijriDate struct {
Day int64
Month int64
Year int64
Pattern LeapYearsPattern
}
HijriDate is date that uses arithmetic Islamic calendar system.
func CreateHijriDate ¶
func CreateHijriDate(date time.Time, leapPattern LeapYearsPattern) (HijriDate, error)
CreateHijriDate converts normal Gregorian date to Hijri date. Since Hijri calendar is not proleptic any date before 16 July 622 CE (1 Muharram 1 H) will make this method throws error.
func (HijriDate) ToGregorian ¶
ToGregorian convert Hijri date to Gregorian date using Golang standard time.
type LeapYearsPattern ¶
type LeapYearsPattern uint8
LeapYearsPattern is patterns of leap years in the 30 year cycle.
const ( // Default is the most commonly used leap years pattern. In this pattern, leap year happened // on years 2, 5, 7, 10, 13, 16, 18, 21, 24, 26 & 29. Default LeapYearsPattern = iota // Base15 is leap years pattern that used by Microsoft, and they named it as "Kuwaiti algorithm". // In this pattern, leap year happened on years 2, 5, 7, 10, 13, 15, 18, 21, 24, 26 & 29. Base15 // Fattimid is leap years pattern that used in Fattimid empire. In this pattern, leap year // happened on years 2, 5, 8, 10, 13, 16, 19, 21, 24, 27 & 29. Fattimid // HabashAlHasib is leap years pattern that created using research from Habash al-Hasib, // an astronomer from Abbasid empire (766-869 in Iraq). In this pattern, leap year happened on // years 2, 5, 8, 11, 13, 16, 19, 21, 24, 27 & 30. HabashAlHasib )
type UmmAlQuraDate ¶
UmmAlQuraDate is a date that uses astronomical-based Islamic calendar system that used in Saudi Arabia.
func CreateUmmAlQuraDate ¶
func CreateUmmAlQuraDate(date time.Time) (UmmAlQuraDate, error)
CreateUmmAlQuraDate converts Gregorian date to Umm al-Qura date.
func (UmmAlQuraDate) ToGregorian ¶
func (uq UmmAlQuraDate) ToGregorian() time.Time
ToGregorian convert Umm al-Qura date to Gregorian date using Golang standard time.