Module: HebrewDateSupport::HolidayMethods::ClassMethods
- Included in:
- HebrewDate
- Defined in:
- lib/support/holidays.rb
Constant Summary collapse
- HOLIDAYS =
A list of holidays which can be passed into the from_holiday method.
[ :TAANIT_BECHORIM, :EREV_PESACH, :PESACH, :PESACH_2, :PESACH_SHENI, :YOM_HAATZMAUT, :YOM_HAZIKARON, :YOM_YERUSHALAYIM, :LAG_BAOMER, :EREV_SHAVUOT, :SHAVUOT, :TZOM_TAMMUZ, :TISHA_BAV, :TU_BAV, :EREV_ROSH_HASHANA, :ROSH_HASHANA, :TZOM_GEDALIA, :EREV_YOM_KIPPUR, :YOM_KIPPUR, :EREV_SUKKOT, :SUKKOT, :SHMINI_ATZERET, :SIMCHAT_TORAH, :EREV_CHANUKAH, :CHANUKAH, :TZOM_TEVET, :TU_BISHVAT, :PURIM_KATAN, :TAANIT_ESTHER, :PURIM, :SHUSHAN_PURIM ]
Instance Method Summary collapse
-
#from_holiday(holiday, year = nil) ⇒ Object
Given a holiday name, return a HebrewDate representing that holiday.
Instance Method Details
#from_holiday(holiday, year = nil) ⇒ Object
Given a holiday name, return a HebrewDate representing that holiday.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/support/holidays.rb', line 45 def from_holiday(holiday, year=nil) year ||= self.new.hebrew_year case holiday when :TAANIT_BECHORIM date = self.from_holiday(:EREV_PESACH, year) date.shabbos? ? date - 2 : date when :EREV_PESACH self.new_from_hebrew(year, 1, 14) when :PESACH self.new_from_hebrew(year, 1, 15) when :PESACH_2 self.new_from_hebrew(year, 1, 21) when :PESACH_SHENI self.new_from_hebrew(year, 2, 15) when :YOM_HAZIKARON self.from_holiday(:YOM_HAATZMAUT, year).back when :YOM_HAATZMAUT date = self.new_from_hebrew(year, 2, 5) # Friday or Shabbat - move back to Thursday # Monday - move forward to Tuesday if date.day == 6 date.back elsif date.day == 2 date.forward elsif date.day == 7 date.set_hebrew_date(year, 2, 3) end when :LAG_BAOMER self.new_from_hebrew(year, 2, 18) when :YOM_YERUSHALAYIM self.new_from_hebrew(year, 2, 28) when :TZOM_TAMMUZ date = self.new_from_hebrew(year, 4, 17) date.forward if date.day == 7 date when :EREV_SHAVUOT self.new_from_hebrew(year, 3, 5) when :SHAVUOT self.new_from_hebrew(year, 3, 6) when :TISHA_BAV date = self.new_from_hebrew(year, 5, 9) date.forward if date.day == 7 date when :TU_BAV self.new_from_hebrew(year, 15, 9) when :EREV_ROSH_HASHANA self.new_from_hebrew(year, 6, 29) when :ROSH_HASHANA self.new_from_hebrew(year, 7, 1) when :TZOM_GEDALIA date = self.new_from_hebrew(year, 7, 3) date.forward if date.day == 7 date when :EREV_YOM_KIPPUR self.new_from_hebrew(year, 7, 9) when :YOM_KIPPUR self.new_from_hebrew(year, 7, 10) when :EREV_SUKKOT self.new_from_hebrew(year, 7, 14) when :SUKKOT self.new_from_hebrew(year, 7, 15) when :SHMINI_ATZERET self.new_from_hebrew(year, 7, 22) when :SIMCHAT_TORAH self.new_from_hebrew(year, 7, 23) when :EREV_CHANUKAH self.new_from_hebrew(year, 9, 24) when :CHANUKAH self.new_from_hebrew(year, 9, 25) when :TZOM_TEVET self.new_from_hebrew(year, 10, 10) when :TU_BISHVAT self.new_from_hebrew(year, 11, 15) when :PURIM_KATAN if self.hebrew_leap_year?(year) self.new_from_hebrew(year, 12, 14) end when :TAANIT_ESTHER date = self.new_from_hebrew(year, self.last_month_of_hebrew_year(year), 13) if date.day == 7 date.set_hebrew_date(year, date.hebrew_month, 11) elsif date.day == 6 date.back end date when :PURIM self.new_from_hebrew(year, self.last_month_of_hebrew_year(year), 14) when :SHUSHAN_PURIM self.new_from_hebrew(year, self.last_month_of_hebrew_year(year), 15) end end |