Module: HebrewDateSupport::Holidays

Included in:
HebrewDate
Defined in:
lib/support/holidays.rb

Instance Method Summary collapse

Instance Method Details

#candle_lighting_day?Boolean

Whether there is candle lighting today, i.e.it is either Friday, Erev Yom Tov, or 1st day yom tov when there is a second day.

Returns:

  • (Boolean)


187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/support/holidays.rb', line 187

def candle_lighting_day?
  return true if self.day == 6
  return true if first_day_yom_tov?
  case @hebrew_month
    when 6
      # Erev Rosh Hashana
      return true if @hebrew_date == 29
    when 7
      # Erev Yom Kippur, Erev Sukkos, Erev Shmini Atzeres
      return true if [9, 14, 21].include?(@hebrew_date)
    when 1
      # Erev Pesach or Erev 7th day Pesach
      return true if [14, 20].include?(@hebrew_date)
    when 3
      # Erev Shavuos
      return true if @hebrew_date == 5
  end
  false
end

#first_day_yom_tov?Boolean

Is this day a first day of Yom Tov? Only should return true if there is a second day.

Returns:

  • (Boolean)


165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/support/holidays.rb', line 165

def first_day_yom_tov?
  # only second day Yom Tov in Israel is Rosh Hashana
  if @israeli
    return @hebrew_month == 7 && @hebrew_date == 1
  end
  case @hebrew_month
    when 7
      # Rosh Hashana, Sukkos, and Shmini Atzeres
      return true if [1, 15, 22].include?(@hebrew_date)
    when 1
      # 2nd and last days Pesach
      return true if [15, 21].include?(@hebrew_date)
    when 3
      # Shavuos
      return true if @hebrew_date == 6
  end
  false
end

#havdala_day?Boolean

Whether there is Havdala today. This would be Sat. night (except for a Yom Tov night), or Motzei Yom Tov (except for Fri. night).

Returns:

  • (Boolean)


210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/support/holidays.rb', line 210

def havdala_day?
  # if today is a candlelighting day, then there is no havdala
  return false if candle_lighting_day?

  # if today is Sat. night, return true unless it is Yom Tov
  if self.day == 7
    case @hebrew_month
      when 7
        # 1st day Rosh Hashana
        if @hebrew_date == 1
          false
        else
          # Sukkos 1 and Shmini Atzeres if outside Israel
          @israeli || ![15, 21].include?(@hebrew_date)
        end
      when 1
        # Pesach 1 or 7
        @israeli || ![15, 21].include?(@hebrew_date)
      when 3
        # Shavos 1
        @israeli || @hebrew_date != 6
      else
        true
    end
  else
    # detect Motzai Yom Tov on non-Sat. night
    case @hebrew_month
      when 7
        # Rosh Hashana 2, Yom Kippur, Sukkos, Shmini Atzeres
        [2, 10].include?(@hebrew_date) ||
          (@israeli && [15, 22].include?(@hebrew_date)) ||
          (!@israeli && [16, 23].include?(@hebrew_date))
      when 1
        # Pesach 1/7 or 2/8
        (@israeli && [15, 21].include?(@hebrew_date)) ||
          (!@israeli && [16, 22].include?(@hebrew_date))
      when 3
        # Shavuos
        (@israeli && @hebrew_date == 6) || (!@israeli && @hebrew_date == 7)
      else
        false
    end
  end
end

#holiday(generic = false) ⇒ String

Returns a string of the Jewish holiday or fast day for the current day, or an empty string if there is no holiday for this day. (e.g. “Pesach”) or a specific one (e.g. “Chol Hamoed Pesach”).

Parameters:

  • generic (Boolean) (defaults to: false)

    whether you want just a generic name

Returns:

  • (String)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
# File 'lib/support/holidays.rb', line 8

def holiday(generic=false)

  # check by month (starts from Nissan)
  case @hebrew_month
    when 1
      return 'Erev Pesach' if @hebrew_date == 14
      if @hebrew_date == 15 || @hebrew_date == 21 ||
        (!@israeli && (@hebrew_date == 16 || @hebrew_date == 22))
        return 'Pesach'
      end
      if @hebrew_date >= 17 && @hebrew_date <= 20 ||
        (@hebrew_date == 16 && @israeli)
        return generic ? 'Pesach' : 'Chol Hamoed Pesach'
      end
    when 2
      return 'Pesach Sheni' if @hebrew_date == 14
      if @hebrew_date == 5 && [1, 3, 4, 5].include?(self.day)
        return "Yom Ha'atzmaut"
      end
      return "Yom Ha'atzmaut" if @hebrew_date == 6 && self.day == 3
      return "Yom Ha'atzmaut" if [3, 4].include?(@hebrew_date) &&
        self.day == 5
      if @hebrew_date == 4 && [2, 3, 4, 7].include?(self.day)
        return 'Yom Hazikaron'
      end
      return 'Yom Hazikaron' if @hebrew_date == 5 && self.day == 2
      return 'Yom Hazikaron' if [2, 3].include?(@hebrew_date) &&
        self.day == 4
      return 'Yom Yerushalayim' if @hebrew_date == 28
    when 3
      if @hebrew_date == 5
        return @ashkenaz ? 'Erev Shavuos' : 'Erev Shavuot'
      end
      if @hebrew_date == 6 || (@hebrew_date == 7 && !@israeli)
        return @ashkenaz ? 'Shavuos' : 'Shavuot'
      end
    when 4
      # push off the fast day if it falls on Shabbos
      if (@hebrew_date == 17 && self.day != 7) ||
        (@hebrew_date == 18 && self.day == 1)
        return 'Tzom Tammuz'
      end
    when 5
      # if Tisha B'Av falls on Shabbos, push off until Sunday
      if (self.day == 1 && @hebrew_date == 10) ||
        (self.day != 7 && @hebrew_date == 9)
        return "Tisha B'av"
      end
      return "Tu B'Av" if @hebrew_date == 15
    when 6
      return 'Erev Rosh Hashanah' if @hebrew_date == 29
    when 7
      return 'Rosh Hashanah' if [1, 2].include?(@hebrew_date)
      # push off Tzom Gedalia if it falls on Shabbos
      if (@hebrew_date == 3 && self.day != 7) ||
        (@hebrew_date == 4 && self.day == 1)
        return 'Tzom Gedalia'
      end
      return 'Erev Yom Kippur' if @hebrew_date == 9
      return 'Yom Kippur' if @hebrew_date == 10
      if @hebrew_date == 14
        return @ashkenaz ? 'Erev Sukkos' : 'Erev Sukkot'
      end
      if @hebrew_date == 15 || (@hebrew_date == 16 && !@israeli)
        return @ashkenaz ? 'Sukkos' : 'Sukkot'
      end
      if @hebrew_date >= 17 && @hebrew_date <= 20 ||
        (@hebrew_date == 16 && @israeli)
        if @ashkenaz
          return generic ? 'Sukkos' : 'Chol Hamoed Sukkos'
        else
          return generic ? 'Sukkot' : 'Chol Hamoed Sukkot'
        end
      end
      return 'Hoshana Rabah' if @hebrew_date == 21
      if @hebrew_date == 22
        return @ashkenaz ? 'Shmini Atzeres' : 'Shmini Atzeret'
      end
      if @hebrew_date == 23 && !@israeli
        return @ashkenaz ? 'Simchas Torah' : 'Simchat Torah'
      end
    when 9
      return 'Erev Chanukah' if @hebrew_date == 24
      return 'Chanukah' if @hebrew_date >= 25
    when 10
      if @hebrew_date == 1 || @hebrew_date == 2 ||
        (@hebrew_date ==3 && _kislev_short?)
        return 'Chanukah'
      end
      if @hebrew_date == 10
        return @ashkenaz ? 'Tzom Teves' : 'Tzom Tevet'
      end
    when 11
      return "Tu B'Shvat" if @hebrew_date == 15
    when 12
      if hebrew_leap_year?
        return 'Purim Katan' if @hebrew_date == 14
      else
        # if 13th Adar falls on Fri or Shabbos, push back to Thursday
        if ((@hebrew_date == 11 || @hebrew_date == 12) && self.day == 5) ||
          (@hebrew_date == 13 && ![6, 7].include?(self.day))
          return @ashkenaz ? "Ta'anis Esther" : "Ta'anit Esther"
        end
        return 'Purim' if @hebrew_date == 14
        return 'Shushan Purim' if @hebrew_date == 15
      end
    when 13
      # if 13th Adar falls on Fri or Shabbos, push back to Thursday
      if ((@hebrew_date == 11 || @hebrew_date == 12) && self.day == 5) ||
        (@hebrew_date == 13 && ![6, 7].include?(self.day))
        return @ashkenaz ? "Ta'anis Esther" : "Ta'anit Esther"
      end
      return 'Purim' if @hebrew_date == 14
      return 'Shushan Purim' if @hebrew_date == 15
    else
      # if we get to this stage, then there are no holidays for the given date
      ''
  end
end

#omerInteger

Get the number of the Omer for this day, or nil if there isn’t one.

Returns:

  • (Integer)


130
131
132
133
134
135
136
137
138
139
140
# File 'lib/support/holidays.rb', line 130

def omer
  if @hebrew_month == 1 && @hebrew_date >= 16
    # Nissan, second day of Pesach and on
    @hebrew_date - 15
  elsif @hebrew_month == 2 # Iyar
    @hebrew_date + 15
  elsif @hebrew_month == 3 && @hebrew_date < 6
    # Sivan, before Shavuos
    @hebrew_date + 44
  end
end

#omer_to_sString

Returns the omer day in the form “Omer X” or “Lag B’Omer” or an empty string if there is no omer this day.

Returns:

  • (String)


145
146
147
148
149
150
151
152
153
154
# File 'lib/support/holidays.rb', line 145

def omer_to_s
  omer = self.omer
  if omer.nil?
    ''
  elsif omer == 33
    "Lag B'Omer"
  else
    "Omer #{omer}"
  end
end

#rosh_chodesh?Boolean

Is this date Rosh Chodesh?

Returns:

  • (Boolean)


158
159
160
# File 'lib/support/holidays.rb', line 158

def rosh_chodesh?
  @hebrew_date == 1 || @hebrew_date == 30
end