Module: HebCal::Holidays
- Defined in:
- lib/hebcal/holidays.rb
Instance Method Summary collapse
- #Is10Tevet(date) ⇒ Object
- #Is17Tammuz(date) ⇒ Object
- #Is17Tamuz(date) ⇒ Object
- #Is9Ab(date) ⇒ Object
- #Is9Av(date) ⇒ Object
- #IsChanuka(date) ⇒ Object
- #IsChanukah(date) ⇒ Object
- #IsChanukka(date) ⇒ Object
- #IsChanukkah(date) ⇒ Object
- #IsFastOfGedalia(date) ⇒ Object
- #IsFastOfGedaliah(date) ⇒ Object
- #IsFastWithSundayPostponement(date, distance) ⇒ Object
- #IsHanuka(date) ⇒ Object
- #IsHanukah(date) ⇒ Object
- #IsHanukka(date) ⇒ Object
- #IsHanukkah(date) ⇒ Object
- #IsMoed(date) ⇒ Object
- #IsPesach(date) ⇒ Object
- #IsPurim(date) ⇒ Object
- #IsRegel(date) ⇒ Object
- #IsRoshChodesh(date) ⇒ Object
- #IsRoshHaShanah(date) ⇒ Object
- #IsRoshHashanah(date) ⇒ Object
- #IsRoshHodesh(date) ⇒ Object
- #IsShavuot(date) ⇒ Object
- #IsSukkot(date) ⇒ Object
- #IsTaanit(date) ⇒ Object
- #IsTaanitEster(date) ⇒ Object
- #IsTaanitEsther(date) ⇒ Object
- #IsTzomGedalia(date) ⇒ Object
- #IsTzomGedaliah(date) ⇒ Object
- #IsYomKippur(date) ⇒ Object
- #IsYomTov(date) ⇒ Object
Instance Method Details
#Is10Tevet(date) ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/hebcal/holidays.rb', line 87 def Is10Tevet date hash = H.PesachAndYearLength date distance = HolidayConstants::STANDARD_10_TEVET_DISTANCE distance = distance - 1 if [353, 383].include?(hash[:length]) distance = distance + 1 if [355, 385].include?(hash[:length]) H.InRange(H.Distance(hash[:pesach], date), distance, 1) end |
#Is17Tammuz(date) ⇒ Object
115 116 117 |
# File 'lib/hebcal/holidays.rb', line 115 def Is17Tammuz date IsFastWithSundayPostponement date, HolidayConstants::FAST_AB_DISTANCE - 21 end |
#Is17Tamuz(date) ⇒ Object
119 120 121 |
# File 'lib/hebcal/holidays.rb', line 119 def Is17Tamuz date Is17Tammuz date end |
#Is9Ab(date) ⇒ Object
107 108 109 |
# File 'lib/hebcal/holidays.rb', line 107 def Is9Ab date IsFastWithSundayPostponement date, HolidayConstants::FAST_AB_DISTANCE end |
#Is9Av(date) ⇒ Object
111 112 113 |
# File 'lib/hebcal/holidays.rb', line 111 def Is9Av date Is9Ab date end |
#IsChanuka(date) ⇒ Object
79 80 81 |
# File 'lib/hebcal/holidays.rb', line 79 def IsChanuka date IsHanukah date end |
#IsChanukah(date) ⇒ Object
71 72 73 |
# File 'lib/hebcal/holidays.rb', line 71 def IsChanukah date IsHanukah date end |
#IsChanukka(date) ⇒ Object
83 84 85 |
# File 'lib/hebcal/holidays.rb', line 83 def IsChanukka date IsHanukah date end |
#IsChanukkah(date) ⇒ Object
75 76 77 |
# File 'lib/hebcal/holidays.rb', line 75 def IsChanukkah date IsHanukah date end |
#IsFastOfGedalia(date) ⇒ Object
123 124 125 |
# File 'lib/hebcal/holidays.rb', line 123 def IsFastOfGedalia date IsFastWithSundayPostponement date, HolidayConstants::SUKKOT_DISTANCE - 12 end |
#IsFastOfGedaliah(date) ⇒ Object
127 128 129 |
# File 'lib/hebcal/holidays.rb', line 127 def IsFastOfGedaliah date IsFastOfGedalia date end |
#IsFastWithSundayPostponement(date, distance) ⇒ Object
103 104 105 |
# File 'lib/hebcal/holidays.rb', line 103 def IsFastWithSundayPostponement date, distance (6 != date.wday && H.InRange(H.DistanceToPassover(date), distance, 1)) || (0 == date.wday && H.InRange(H.DistanceToPassover(date), distance + 1, 1)) end |
#IsHanuka(date) ⇒ Object
63 64 65 |
# File 'lib/hebcal/holidays.rb', line 63 def IsHanuka date IsHanukah date end |
#IsHanukah(date) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/hebcal/holidays.rb', line 52 def IsHanukah date hash = H.PesachAndYearLength date distance = HolidayConstants::STANDARD_HANUKAH_DISTANCE distance = distance + 1 if [355, 385].include?(hash[:length]) H.InRange(H.Distance(hash[:pesach], date), distance, 8) end |
#IsHanukka(date) ⇒ Object
67 68 69 |
# File 'lib/hebcal/holidays.rb', line 67 def IsHanukka date IsHanukah date end |
#IsHanukkah(date) ⇒ Object
59 60 61 |
# File 'lib/hebcal/holidays.rb', line 59 def IsHanukkah date IsHanukah date end |
#IsMoed(date) ⇒ Object
32 33 34 35 |
# File 'lib/hebcal/holidays.rb', line 32 def IsMoed date distance = H.DistanceToPassover(date) H.InRange(distance, 2, 4) || H.InRange(distance, HolidayConstants::SUKKOT_DISTANCE + 2, 5) end |
#IsPesach(date) ⇒ Object
8 9 10 |
# File 'lib/hebcal/holidays.rb', line 8 def IsPesach date H.InRange(H.DistanceToPassover(date), 0, 8) end |
#IsPurim(date) ⇒ Object
48 49 50 |
# File 'lib/hebcal/holidays.rb', line 48 def IsPurim date H.InRange(H.DistanceToPassover(date), HolidayConstants::PURIM_DISTANCE, 1) end |
#IsRegel(date) ⇒ Object
37 38 39 40 |
# File 'lib/hebcal/holidays.rb', line 37 def IsRegel date distance = H.DistanceToPassover(date) H.InRange(distance, 0, 8) || H.InRange(distance, HolidayConstants::SHAVUOT_DISTANCE, 2) || H.InRange(distance, HolidayConstants::SUKKOT_DISTANCE, 9) end |
#IsRoshChodesh(date) ⇒ Object
171 172 173 |
# File 'lib/hebcal/holidays.rb', line 171 def IsRoshChodesh date IsRoshHodesh date end |
#IsRoshHaShanah(date) ⇒ Object
20 21 22 |
# File 'lib/hebcal/holidays.rb', line 20 def IsRoshHaShanah date IsRoshHashanah date end |
#IsRoshHashanah(date) ⇒ Object
16 17 18 |
# File 'lib/hebcal/holidays.rb', line 16 def IsRoshHashanah date H.InRange(H.DistanceToPassover(date), HolidayConstants::SUKKOT_DISTANCE - 14, 2) end |
#IsRoshHodesh(date) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/hebcal/holidays.rb', line 145 def IsRoshHodesh date hash = H.PesachAndYearLength date distance = H.Distance(hash[:pesach], date) length = hash[:length] distances = [ -59 + 15, -59 + 16, -59 + 30 + 15] # Adar(2) Nisan distances.concat [ 15, 16, 30 + 15] # Iyar Sivan distances.concat [ 59 + 15, 59 + 16, 59 + 30 + 15] # Tamuz Ab distances.concat [2 * 59 + 15, 2 * 59 + 16] # Elul distances.concat [3 * 59 + 15, 3 * 59 + 16, 3 * 59 + 30 + 15] # Heshvan, 1st day Kislev if [353, 383].include? length then distances.concat [4 * 59 + 15] # Tevet distances.concat [4 * 59 + 30 + 14] # Shevat distances.concat [5 * 59 + 14, 5 * 59 + 15] if 383 == length # Adar1 elsif [354, 384].include? length then distances.concat [4 * 59 + 15, 4 * 59 + 16] # Tevet distances.concat [4 * 59 + 30 + 15] # Shevat distances.concat [5 * 59 + 15, 5 * 59 + 16] if 384 == length # Adar1 elsif [355, 385].include? length then distances.concat [3 * 59 + 30 + 16] # 2nd day Kislev distances.concat [4 * 59 + 16, 4 * 59 + 17] # Tevet distances.concat [4 * 59 + 30 + 16] # Shevat distances.concat [5 * 59 + 16, 5 * 59 + 17] if 385 == length # Adar1 end distances.include? distance end |
#IsShavuot(date) ⇒ Object
12 13 14 |
# File 'lib/hebcal/holidays.rb', line 12 def IsShavuot date H.InRange(H.DistanceToPassover(date), HolidayConstants::SHAVUOT_DISTANCE, 2) end |
#IsSukkot(date) ⇒ Object
28 29 30 |
# File 'lib/hebcal/holidays.rb', line 28 def IsSukkot date H.InRange(H.DistanceToPassover(date), HolidayConstants::SUKKOT_DISTANCE, 9) end |
#IsTaanit(date) ⇒ Object
139 140 141 142 143 |
# File 'lib/hebcal/holidays.rb', line 139 def IsTaanit date return false if 6 == date.wday distance = H.DistanceToPassover(date) H.InRange(distance, HolidayConstants::FAST_AB_DISTANCE, 1) || H.InRange(distance, HolidayConstants::FAST_AB_DISTANCE - 21, 1) || H.InRange(distance, HolidayConstants::SUKKOT_DISTANCE - 12, 1) || H.InRange(distance, HolidayConstants::PURIM_DISTANCE - 1, 1) || (0 == date.wday && (H.InRange(distance, HolidayConstants::FAST_AB_DISTANCE + 1, 1) || H.InRange(distance, HolidayConstants::FAST_AB_DISTANCE - 21 + 1, 1) || H.InRange(distance, HolidayConstants::SUKKOT_DISTANCE - 12 + 1, 1))) || (4 == date.wday && H.InRange(distance, HolidayConstants::PURIM_DISTANCE - 3, 1)) || Is10Tevet(date) end |
#IsTaanitEster(date) ⇒ Object
95 96 97 |
# File 'lib/hebcal/holidays.rb', line 95 def IsTaanitEster date (6 != date.wday && H.InRange(H.DistanceToPassover(date), HolidayConstants::PURIM_DISTANCE - 1, 1)) || (4 == date.wday && H.InRange(H.DistanceToPassover(date), HolidayConstants::PURIM_DISTANCE - 3, 1)) end |
#IsTaanitEsther(date) ⇒ Object
99 100 101 |
# File 'lib/hebcal/holidays.rb', line 99 def IsTaanitEsther date IsTaanitEster date end |
#IsTzomGedalia(date) ⇒ Object
131 132 133 |
# File 'lib/hebcal/holidays.rb', line 131 def IsTzomGedalia date IsFastOfGedalia date end |
#IsTzomGedaliah(date) ⇒ Object
135 136 137 |
# File 'lib/hebcal/holidays.rb', line 135 def IsTzomGedaliah date IsFastOfGedalia date end |
#IsYomKippur(date) ⇒ Object
24 25 26 |
# File 'lib/hebcal/holidays.rb', line 24 def IsYomKippur date H.InRange(H.DistanceToPassover(date), HolidayConstants::SUKKOT_DISTANCE - 5, 1) end |
#IsYomTov(date) ⇒ Object
42 43 44 45 46 |
# File 'lib/hebcal/holidays.rb', line 42 def IsYomTov date # Note that Yom Kippur is not a Yom Tov distance = H.DistanceToPassover(date) result = H.InRange(distance, 0, 2) || H.InRange(distance, 6, 2) || H.InRange(distance, HolidayConstants::SHAVUOT_DISTANCE, 2) || H.InRange(distance, HolidayConstants::SUKKOT_DISTANCE - 14, 2) || H.InRange(distance, HolidayConstants::SUKKOT_DISTANCE, 2) || H.InRange(distance, HolidayConstants::SUKKOT_DISTANCE + 7, 2) end |