Class: Holidays::DateCalculator::HijriDate
- Inherits:
-
Object
- Object
- Holidays::DateCalculator::HijriDate
- Defined in:
- lib/holidays/date_calculator/hijri_date.rb
Overview
Arithmetic ("tabular", a.k.a. Kuwaiti) Islamic calendar.
Months alternate 30 and 29 days; leap years add a day to the twelfth month on a fixed 11-of-30 cycle. This is a purely arithmetic calendar, so it can land a day (occasionally two) either side of a locally proclaimed date. Callers that need the proclaimed date layer their own override table on top of this (see Holidays::Definition::CustomMethods::TR).
Constant Summary collapse
- EPOCH_JDN =
Julian day number of 1 Muharram 1 AH minus one day, chosen so that to_jd's month/day terms are added directly. Corresponds to the civil epoch (Friday, 16 July 622 CE proleptic Julian).
1948439
Instance Method Summary collapse
-
#gregorian_year_occurrence(gregorian_year, hijri_month, hijri_day) ⇒ Object
Given a Gregorian year and a fixed Hijri month/day, return the occurrence that falls within that Gregorian year, or nil if none does.
- #to_gregorian(hijri_year, hijri_month, hijri_day) ⇒ Object
Instance Method Details
#gregorian_year_occurrence(gregorian_year, hijri_month, hijri_day) ⇒ Object
Given a Gregorian year and a fixed Hijri month/day, return the occurrence that falls within that Gregorian year, or nil if none does.
A fixed Hijri date drifts ~11 days earlier each Gregorian year, so roughly once every 33 years it falls twice in the same Gregorian year (once in early January, once in late December). Only the earlier occurrence is returned.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/holidays/date_calculator/hijri_date.rb', line 30 def gregorian_year_occurrence(gregorian_year, hijri_month, hijri_day) candidate_hijri_year = gregorian_year - 579 (candidate_hijri_year - 1..candidate_hijri_year + 1).each do |hijri_year| date = to_gregorian(hijri_year, hijri_month, hijri_day) return date if date.year == gregorian_year end nil end |
#to_gregorian(hijri_year, hijri_month, hijri_day) ⇒ Object
19 20 21 |
# File 'lib/holidays/date_calculator/hijri_date.rb', line 19 def to_gregorian(hijri_year, hijri_month, hijri_day) Date.jd(to_jd(hijri_year, hijri_month, hijri_day)) end |