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.
[ :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, :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.
43 44 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 |
# File 'lib/support/holidays.rb', line 43 def from_holiday(holiday, year=nil) year ||= HebrewDate.new.hebrew_year case holiday when :EREV_PESACH HebrewDate.new_from_hebrew(year, 1, 14) when :PESACH HebrewDate.new_from_hebrew(year, 1, 15) when :PESACH_2 HebrewDate.new_from_hebrew(year, 1, 21) when :PESACH_SHENI HebrewDate.new_from_hebrew(year, 2, 15) when :YOM_HAZIKARON HebrewDate.from_holiday(:YOM_HAATZMAUT).back when :YOM_HAATZMAUT date = HebrewDate.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 HebrewDate.new_from_hebrew(year, 2, 18) when :YOM_YERUSHALAYIM HebrewDate.new_from_hebrew(year, 2, 28) when :TZOM_TAMMUZ date = HebrewDate.new_from_hebrew(year, 4, 17) date.forward if date.day == 7 date when :EREV_SHAVUOT HebrewDate.new_from_hebrew(year, 3, 5) when :SHAVUOT HebrewDate.new_from_hebrew(year, 3, 6) when :TISHA_BAV date = HebrewDate.new_from_hebrew(year, 5, 9) date.forward if date.day == 7 date when :TU_BAV HebrewDate.new_from_hebrew(year, 15, 9) when :EREV_ROSH_HASHANA HebrewDate.new_from_hebrew(year, 6, 29) when :ROSH_HASHANA HebrewDate.new_from_hebrew(year, 7, 1) when :TZOM_GEDALIA date = HebrewDate.new_from_hebrew(year, 7, 3) date.forward if date.day == 7 date when :EREV_YOM_KIPPUR HebrewDate.new_from_hebrew(year, 7, 9) when :YOM_KIPPUR HebrewDate.new_from_hebrew(year, 7, 10) when :EREV_SUKKOT HebrewDate.new_from_hebrew(year, 7, 14) when :SUKKOT HebrewDate.new_from_hebrew(year, 7, 15) when :SHMINI_ATZERET HebrewDate.new_from_hebrew(year, 7, 22) when :EREV_CHANUKAH HebrewDate.new_from_hebrew(year, 9, 24) when :CHANUKAH HebrewDate.new_from_hebrew(year, 9, 25) when :TZOM_TEVET HebrewDate.new_from_hebrew(year, 10, 10) when :TU_BISHVAT HebrewDate.new_from_hebrew(year, 11, 15) when :PURIM_KATAN if HebrewDate.hebrew_leap_year?(year) HebrewDate.new_from_hebrew(year, 12, 14) end when :TAANIT_ESTHER date = HebrewDate.new_from_hebrew(year, HebrewDate.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 HebrewDate.new_from_hebrew(year, HebrewDate.last_month_of_hebrew_year(year), 14) when :SHUSHAN_PURIM HebrewDate.new_from_hebrew(year, HebrewDate.last_month_of_hebrew_year(year), 15) end end |