hebrew_date 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +20 -0
- data/LICENSE +20 -0
- data/README.md +76 -0
- data/doc/HebrewDate.html +2611 -0
- data/doc/HebrewDateSupport.html +117 -0
- data/doc/HebrewDateSupport/Holidays.html +1110 -0
- data/doc/HebrewDateSupport/Parshiot.html +436 -0
- data/doc/JqrHelpers/Rails.html +117 -0
- data/doc/_index.html +137 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +338 -0
- data/doc/file.README.html +84 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +84 -0
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +239 -0
- data/doc/top-level-namespace.html +114 -0
- data/hebrew_date.gemspec +22 -0
- data/lib/hebrew_date.rb +492 -0
- data/lib/support/holidays.rb +256 -0
- data/lib/support/parshiot.rb +317 -0
- data/spec/hebrew_date_spec.rb +50 -0
- metadata +106 -0
@@ -0,0 +1,256 @@
|
|
1
|
+
module HebrewDateSupport
|
2
|
+
module Holidays
|
3
|
+
# Returns a string of the Jewish holiday or fast day for the current day,
|
4
|
+
# or an empty string if there is no holiday for this day.
|
5
|
+
# @param generic [Boolean] whether you want just a generic name
|
6
|
+
# (e.g. "Pesach") or a specific one (e.g. "Chol Hamoed Pesach").
|
7
|
+
# @return [String]
|
8
|
+
def holiday(generic=false)
|
9
|
+
|
10
|
+
# check by month (starts from Nissan)
|
11
|
+
case @hebrew_month
|
12
|
+
when 1
|
13
|
+
return 'Erev Pesach' if @hebrew_date == 14
|
14
|
+
if @hebrew_date == 15 || @hebrew_date == 21 ||
|
15
|
+
(!@israeli && (@hebrew_date == 16 || @hebrew_date == 22))
|
16
|
+
return 'Pesach'
|
17
|
+
end
|
18
|
+
if @hebrew_date >= 17 && @hebrew_date <= 20 ||
|
19
|
+
(@hebrew_date == 16 && @israeli)
|
20
|
+
return generic ? 'Pesach' : 'Chol Hamoed Pesach'
|
21
|
+
end
|
22
|
+
when 2
|
23
|
+
return 'Pesach Sheni' if @hebrew_date == 14
|
24
|
+
if @hebrew_date == 5 && [1, 3, 4, 5].include?(self.day)
|
25
|
+
return "Yom Ha'atzmaut"
|
26
|
+
end
|
27
|
+
return "Yom Ha'atzmaut" if @hebrew_date == 6 && self.day == 3
|
28
|
+
return "Yom Ha'atzmaut" if [3, 4].include?(@hebrew_date) &&
|
29
|
+
self.day == 5
|
30
|
+
if @hebrew_date == 4 && [2, 3, 4, 7].include?(self.day)
|
31
|
+
return 'Yom Hazikaron'
|
32
|
+
end
|
33
|
+
return 'Yom Hazikaron' if @hebrew_date == 5 && self.day == 2
|
34
|
+
return 'Yom Hazikaron' if [2, 3].include?(@hebrew_date) &&
|
35
|
+
self.day == 4
|
36
|
+
return 'Yom Yerushalayim' if @hebrew_date == 28
|
37
|
+
when 3
|
38
|
+
if @hebrew_date == 5
|
39
|
+
return @ashkenaz ? 'Erev Shavuos' : 'Erev Shavuot'
|
40
|
+
end
|
41
|
+
if @hebrew_date == 6 || (@hebrew_date == 7 && !@israeli)
|
42
|
+
return @ashkenaz ? 'Shavuos' : 'Shavuot'
|
43
|
+
end
|
44
|
+
when 4
|
45
|
+
# push off the fast day if it falls on Shabbos
|
46
|
+
if (@hebrew_date == 17 && self.day != 7) ||
|
47
|
+
(@hebrew_date == 18 && self.day == 1)
|
48
|
+
return 'Tzom Tammuz'
|
49
|
+
end
|
50
|
+
when 5
|
51
|
+
# if Tisha B'Av falls on Shabbos, push off until Sunday
|
52
|
+
if (self.day == 1 && @hebrew_date == 10) ||
|
53
|
+
(self.day != 7 && @hebrew_date == 9)
|
54
|
+
return "Tisha B'av"
|
55
|
+
end
|
56
|
+
return "Tu B'Av" if @hebrew_date == 15
|
57
|
+
when 6
|
58
|
+
return 'Erev Rosh Hashanah' if @hebrew_date == 29
|
59
|
+
when 7
|
60
|
+
return 'Rosh Hashanah' if [1, 2].include?(@hebrew_date)
|
61
|
+
# push off Tzom Gedalia if it falls on Shabbos
|
62
|
+
if (@hebrew_date == 3 && self.day != 7) ||
|
63
|
+
(@hebrew_date == 4 && self.day == 1)
|
64
|
+
return 'Tzom Gedalia'
|
65
|
+
end
|
66
|
+
return 'Erev Yom Kippur' if @hebrew_date == 9
|
67
|
+
return 'Yom Kippur' if @hebrew_date == 10
|
68
|
+
if @hebrew_date == 14
|
69
|
+
return @ashkenaz ? 'Erev Sukkos' : 'Erev Sukkot'
|
70
|
+
end
|
71
|
+
if @hebrew_date == 15 || (@hebrew_date == 16 && !@israeli)
|
72
|
+
return @ashkenaz ? 'Sukkos' : 'Sukkot'
|
73
|
+
end
|
74
|
+
if @hebrew_date >= 17 && @hebrew_date <= 20 ||
|
75
|
+
(@hebrew_date == 16 && @israeli)
|
76
|
+
if @ashkenaz
|
77
|
+
return generic ? 'Sukkos' : 'Chol Hamoed Sukkos'
|
78
|
+
else
|
79
|
+
return generic ? 'Sukkot' : 'Chol Hamoed Sukkot'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
return 'Hoshana Rabah' if @hebrew_date == 21
|
83
|
+
if @hebrew_date == 22
|
84
|
+
return @ashkenaz ? 'Shmini Atzeres' : 'Shmini Atzeret'
|
85
|
+
end
|
86
|
+
if @hebrew_date == 23 && !@israeli
|
87
|
+
return @ashkenaz ? 'Simchas Torah' : 'Simchat Torah'
|
88
|
+
end
|
89
|
+
when 9
|
90
|
+
return 'Erev Chanukah' if @hebrew_date == 24
|
91
|
+
return 'Chanukah' if @hebrew_date >= 25
|
92
|
+
when 10
|
93
|
+
if @hebrew_date == 1 || @hebrew_date == 2 ||
|
94
|
+
(@hebrew_date ==3 && _kislev_short?)
|
95
|
+
return 'Chanukah'
|
96
|
+
end
|
97
|
+
if @hebrew_date == 10
|
98
|
+
return @ashkenaz ? 'Tzom Teves' : 'Tzom Tevet'
|
99
|
+
end
|
100
|
+
when 11
|
101
|
+
return "Tu B'Shvat" if @hebrew_date == 15
|
102
|
+
when 12
|
103
|
+
if hebrew_leap_year?
|
104
|
+
return 'Purim Katan' if @hebrew_date == 14
|
105
|
+
else
|
106
|
+
# if 13th Adar falls on Fri or Shabbos, push back to Thursday
|
107
|
+
if ((@hebrew_date == 11 || @hebrew_date == 12) && self.day == 5) ||
|
108
|
+
(@hebrew_date == 13 && ![6, 7].include?(self.day))
|
109
|
+
return @ashkenaz ? "Ta'anis Esther" : "Ta'anit Esther"
|
110
|
+
end
|
111
|
+
return 'Purim' if @hebrew_date == 14
|
112
|
+
return 'Shushan Purim' if @hebrew_date == 15
|
113
|
+
end
|
114
|
+
when 13
|
115
|
+
# if 13th Adar falls on Fri or Shabbos, push back to Thursday
|
116
|
+
if ((@hebrew_date == 11 || @hebrew_date == 12) && self.day == 5) ||
|
117
|
+
(@hebrew_date == 13 && ![6, 7].include?(self.day))
|
118
|
+
return @ashkenaz ? "Ta'anis Esther" : "Ta'anit Esther"
|
119
|
+
end
|
120
|
+
return 'Purim' if @hebrew_date == 14
|
121
|
+
return 'Shushan Purim' if @hebrew_date == 15
|
122
|
+
else
|
123
|
+
# if we get to this stage, then there are no holidays for the given date
|
124
|
+
''
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# Get the number of the Omer for this day, or nil if there isn't one.
|
129
|
+
# @return [Integer]
|
130
|
+
def omer
|
131
|
+
if @hebrew_month == 1 && @hebrew_date >= 16
|
132
|
+
# Nissan, second day of Pesach and on
|
133
|
+
@hebrew_date - 15
|
134
|
+
elsif @hebrew_month == 2 # Iyar
|
135
|
+
@hebrew_date + 15
|
136
|
+
elsif @hebrew_month == 3 && @hebrew_date < 6
|
137
|
+
# Sivan, before Shavuos
|
138
|
+
@hebrew_date + 44
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# Returns the omer day in the form "Omer X" or "Lag B'Omer"
|
143
|
+
# or an empty string if there is no omer this day.
|
144
|
+
# @return [String]
|
145
|
+
def omer_to_s
|
146
|
+
omer = self.omer
|
147
|
+
if omer.nil?
|
148
|
+
''
|
149
|
+
elsif omer == 33
|
150
|
+
"Lag B'Omer"
|
151
|
+
else
|
152
|
+
"Omer #{omer}"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# Is this date Rosh Chodesh?
|
157
|
+
# @return [Boolean]
|
158
|
+
def rosh_chodesh?
|
159
|
+
@hebrew_date == 1 || @hebrew_date == 30
|
160
|
+
end
|
161
|
+
|
162
|
+
# Is this day a first day of Yom Tov? Only should return true if there is
|
163
|
+
# a second day.
|
164
|
+
# @return [Boolean]
|
165
|
+
def first_day_yom_tov?
|
166
|
+
# only second day Yom Tov in Israel is Rosh Hashana
|
167
|
+
if @israeli
|
168
|
+
return @hebrew_month == 7 && @hebrew_date == 1
|
169
|
+
end
|
170
|
+
case @hebrew_month
|
171
|
+
when 7
|
172
|
+
# Rosh Hashana, Sukkos, and Shmini Atzeres
|
173
|
+
return true if [1, 15, 22].include?(@hebrew_date)
|
174
|
+
when 1
|
175
|
+
# 2nd and last days Pesach
|
176
|
+
return true if [15, 21].include?(@hebrew_date)
|
177
|
+
when 3
|
178
|
+
# Shavuos
|
179
|
+
return true if @hebrew_date == 6
|
180
|
+
end
|
181
|
+
false
|
182
|
+
end
|
183
|
+
|
184
|
+
# Whether there is candle lighting today, i.e.it is either Friday, Erev Yom
|
185
|
+
# Tov, or 1st day yom tov when there is a second day.
|
186
|
+
# @return [Boolean]
|
187
|
+
def candle_lighting_day?
|
188
|
+
return true if self.day == 6
|
189
|
+
return true if first_day_yom_tov?
|
190
|
+
case @hebrew_month
|
191
|
+
when 6
|
192
|
+
# Erev Rosh Hashana
|
193
|
+
return true if @hebrew_date == 29
|
194
|
+
when 7
|
195
|
+
# Erev Yom Kippur, Erev Sukkos, Erev Shmini Atzeres
|
196
|
+
return true if [9, 14, 21].include?(@hebrew_date)
|
197
|
+
when 1
|
198
|
+
# Erev Pesach or Erev 7th day Pesach
|
199
|
+
return true if [14, 20].include?(@hebrew_date)
|
200
|
+
when 3
|
201
|
+
# Erev Shavuos
|
202
|
+
return true if @hebrew_date == 5
|
203
|
+
end
|
204
|
+
false
|
205
|
+
end
|
206
|
+
|
207
|
+
# Whether there is Havdala today. This would be Sat. night (except for a
|
208
|
+
# Yom Tov night), or Motzei Yom Tov (except for Fri. night).
|
209
|
+
# @return [Boolean]
|
210
|
+
def havdala_day?
|
211
|
+
# if today is a candlelighting day, then there is no havdala
|
212
|
+
return false if candle_lighting_day?
|
213
|
+
|
214
|
+
# if today is Sat. night, return true unless it is Yom Tov
|
215
|
+
if self.day == 7
|
216
|
+
case @hebrew_month
|
217
|
+
when 7
|
218
|
+
# 1st day Rosh Hashana
|
219
|
+
if @hebrew_date == 1
|
220
|
+
false
|
221
|
+
else
|
222
|
+
# Sukkos 1 and Shmini Atzeres if outside Israel
|
223
|
+
@israeli || ![15, 21].include?(@hebrew_date)
|
224
|
+
end
|
225
|
+
when 1
|
226
|
+
# Pesach 1 or 7
|
227
|
+
@israeli || ![15, 21].include?(@hebrew_date)
|
228
|
+
when 3
|
229
|
+
# Shavos 1
|
230
|
+
@israeli || @hebrew_date != 6
|
231
|
+
else
|
232
|
+
true
|
233
|
+
end
|
234
|
+
else
|
235
|
+
# detect Motzai Yom Tov on non-Sat. night
|
236
|
+
case @hebrew_month
|
237
|
+
when 7
|
238
|
+
# Rosh Hashana 2, Yom Kippur, Sukkos, Shmini Atzeres
|
239
|
+
[2, 10].include?(@hebrew_date) ||
|
240
|
+
(@israeli && [15, 22].include?(@hebrew_date)) ||
|
241
|
+
(!@israeli && [16, 23].include?(@hebrew_date))
|
242
|
+
when 1
|
243
|
+
# Pesach 1/7 or 2/8
|
244
|
+
(@israeli && [15, 21].include?(@hebrew_date)) ||
|
245
|
+
(!@israeli && [16, 22].include?(@hebrew_date))
|
246
|
+
when 3
|
247
|
+
# Shavuos
|
248
|
+
(@israeli && @hebrew_date == 6) || (!@israeli && @hebrew_date == 7)
|
249
|
+
else
|
250
|
+
false
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
256
|
+
end
|
@@ -0,0 +1,317 @@
|
|
1
|
+
module HebrewDateSupport
|
2
|
+
module Parshiot
|
3
|
+
# Parsha names in Ashkenazi and Sephardi pronunciation.
|
4
|
+
# @private
|
5
|
+
PARSHA_NAMES = [
|
6
|
+
['Bereshit', 'Bereishis'],
|
7
|
+
['Noach', 'Noach'],
|
8
|
+
['Lech-Lecha', 'Lech Lecha'],
|
9
|
+
['Vayera', 'Vayeira'],
|
10
|
+
['Chayei Sara', 'Chayei Sarah'],
|
11
|
+
['Toldot', 'Toldos'],
|
12
|
+
['Vayetzei', 'Vayeitzei'],
|
13
|
+
['Vayishlach', 'Vayishlach'],
|
14
|
+
['Vayeshev', 'Vayeishev'],
|
15
|
+
['Miketz', 'Mikeitz'],
|
16
|
+
['Vayigash', 'Vayigash'],
|
17
|
+
['Vayechi', 'Vayechi'],
|
18
|
+
['Shemot', 'Shemos'],
|
19
|
+
['Vaera', "Va'eira"],
|
20
|
+
['Bo', 'Bo'],
|
21
|
+
['Beshalach/Shira', 'Beshalach/Shira'],
|
22
|
+
['Yitro', 'Yisro'],
|
23
|
+
['Mishpatim', 'Mishpatim'],
|
24
|
+
['Terumah', 'Terumah'],
|
25
|
+
['Tetzaveh', 'Tetzaveh'],
|
26
|
+
['Ki Tisa', 'Ki Sisa'],
|
27
|
+
['Vayakhel', 'Vayakhel'],
|
28
|
+
['Pekudei', 'Pekudei'],
|
29
|
+
['Vayikra', 'Vayikra'],
|
30
|
+
['Tzav', 'Tzav'],
|
31
|
+
['Shmini', 'Shemini'],
|
32
|
+
['Tazria', 'Tazria'],
|
33
|
+
['Metzora', 'Metzora'],
|
34
|
+
['Achrei Mot', 'Acharei Mos'],
|
35
|
+
['Kedoshim', 'Kedoshim'],
|
36
|
+
['Emor', 'Emor'],
|
37
|
+
['Behar', 'Behar'],
|
38
|
+
['Bechukotai', 'Bechukosai'],
|
39
|
+
['Bamidbar', 'Bamidbar'],
|
40
|
+
['Nasso', 'Nasso'],
|
41
|
+
["Beha'alotcha", "Beha'aloscha"],
|
42
|
+
["Sh'lach", 'Shelach'],
|
43
|
+
['Korach', 'Korach'],
|
44
|
+
['Chukat', 'Chukas'],
|
45
|
+
['Balak', 'Balak'],
|
46
|
+
['Pinchas', 'Pinchas'],
|
47
|
+
['Matot', 'Mattos'],
|
48
|
+
['Masei', 'Masei'],
|
49
|
+
['Devarim', 'Devarim'],
|
50
|
+
['Vaetchanan', "Va'eschanan"],
|
51
|
+
['Eikev', 'Eikev'],
|
52
|
+
["Re'eh", "Re'eh"],
|
53
|
+
['Shoftim', 'Shoftim'],
|
54
|
+
['Ki Teitzei', 'Ki Seitzei'],
|
55
|
+
['Ki Tavo', 'Ki Savo'],
|
56
|
+
['Nitzavim', 'Nitzavim'],
|
57
|
+
['Vayeilech', 'Vayeilech'],
|
58
|
+
["Ha'Azinu", 'Haazinu'],
|
59
|
+
['Vayakhel-Pekudei', 'Vayakhel-Pekudei'],
|
60
|
+
['Tazria-Metzora', 'Tazria-Metzora'],
|
61
|
+
['Achrei Mot-Kedoshim', 'Acharei Mos-Kedoshim'],
|
62
|
+
['Behar-Bechukotai', 'Behar-Bechukosai'],
|
63
|
+
['Chukat-Balak', 'Chukas-Balak'],
|
64
|
+
['Matot-Masei', 'Mattos-Masei'],
|
65
|
+
['Nitzavim-Vayeilech', 'Nitzavim-Vayeilech']
|
66
|
+
]
|
67
|
+
|
68
|
+
# These indices were originally included in the emacs 19 distribution.
|
69
|
+
# These arrays determine the correct indices into the parsha names
|
70
|
+
# -1 means no parsha that week, values > 52 means it is a double parsha
|
71
|
+
|
72
|
+
# @private
|
73
|
+
SAT_SHORT =
|
74
|
+
[-1, 52, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
75
|
+
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 53, 23, 24, -1, 25,
|
76
|
+
54, 55, 30, 56, 33, 34, 35, 36, 37, 38, 39, 40, 58, 43, 44, 45,
|
77
|
+
46, 47, 48, 49, 50]
|
78
|
+
|
79
|
+
# @private
|
80
|
+
SAT_LONG =
|
81
|
+
[-1, 52, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
82
|
+
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 53, 23, 24, -1, 25,
|
83
|
+
54, 55, 30, 56, 33, 34, 35, 36, 37, 38, 39, 40, 58, 43, 44,
|
84
|
+
45, 46, 47, 48, 49, 59]
|
85
|
+
|
86
|
+
# @private
|
87
|
+
MON_SHORT =
|
88
|
+
[51, 52, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
89
|
+
12, 13, 14, 15, 16, 17, 18, 19, 20, 53, 23, 24, -1, 25, 54,
|
90
|
+
55, 30, 56, 33, 34, 35, 36, 37, 38, 39, 40, 58, 43, 44, 45,
|
91
|
+
46, 47, 48, 49, 59]
|
92
|
+
|
93
|
+
# @private
|
94
|
+
MON_LONG = # split
|
95
|
+
[51, 52, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
96
|
+
12, 13, 14, 15, 16, 17, 18, 19, 20, 53, 23, 24, -1, 25, 54,
|
97
|
+
55, 30, 56, 33, -1, 34, 35, 36, 37, 57, 40, 58, 43, 44, 45,
|
98
|
+
46, 47, 48, 49, 59]
|
99
|
+
|
100
|
+
# @private
|
101
|
+
THU_NORMAL =
|
102
|
+
[52, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
103
|
+
12, 13, 14, 15, 16, 17, 18, 19, 20, 53, 23, 24, -1, -1, 25,
|
104
|
+
54, 55, 30, 56, 33, 34, 35, 36, 37, 38, 39, 40, 58, 43, 44,
|
105
|
+
45, 46, 47, 48, 49, 50]
|
106
|
+
|
107
|
+
# @private
|
108
|
+
THU_NORMAL_ISRAEL =
|
109
|
+
[52, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
110
|
+
12, 13, 14, 15, 16, 17, 18, 19, 20, 53, 23, 24, -1, 25, 54,
|
111
|
+
55, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 58, 43, 44,
|
112
|
+
45, 46, 47, 48, 49, 50]
|
113
|
+
|
114
|
+
# @private
|
115
|
+
THU_LONG =
|
116
|
+
[52, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
117
|
+
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, -1, 25,
|
118
|
+
54, 55, 30, 56, 33, 34, 35, 36, 37, 38, 39, 40, 58, 43, 44,
|
119
|
+
45, 46, 47, 48, 49, 50]
|
120
|
+
|
121
|
+
# @private
|
122
|
+
SAT_SHORT_LEAP =
|
123
|
+
[-1, 52, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
124
|
+
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
|
125
|
+
26, 27, -1, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
|
126
|
+
40, 58, 43, 44, 45, 46, 47, 48, 49, 59]
|
127
|
+
|
128
|
+
# @private
|
129
|
+
SAT_LONG_LEAP =
|
130
|
+
[-1, 52, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
131
|
+
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
|
132
|
+
26, 27, -1, 28, 29, 30, 31, 32, 33, -1, 34, 35, 36, 37, 57,
|
133
|
+
40, 58, 43, 44, 45, 46, 47, 48, 49, 59]
|
134
|
+
|
135
|
+
# @private
|
136
|
+
MON_SHORT_LEAP =
|
137
|
+
[51, 52, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
138
|
+
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
|
139
|
+
27, -1, 28, 29, 30, 31, 32, 33, -1, 34, 35, 36, 37, 57, 40,
|
140
|
+
58, 43, 44, 45, 46, 47, 48, 49, 59]
|
141
|
+
|
142
|
+
# @private
|
143
|
+
MON_SHORT_LEAP_ISRAEL =
|
144
|
+
[51, 52, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
145
|
+
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
|
146
|
+
27, -1, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
147
|
+
58, 43, 44, 45, 46, 47, 48, 49, 59]
|
148
|
+
|
149
|
+
# @private
|
150
|
+
MON_LONG_LEAP =
|
151
|
+
[51, 52, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
152
|
+
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
|
153
|
+
27, -1, -1, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
|
154
|
+
40, 58, 43, 44, 45, 46, 47, 48, 49, 50]
|
155
|
+
# @private
|
156
|
+
MON_LONG_LEAP_ISRAEL =
|
157
|
+
[51, 52, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
158
|
+
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
|
159
|
+
27, -1, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
160
|
+
41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
|
161
|
+
|
162
|
+
# @private
|
163
|
+
THU_SHORT_LEAP =
|
164
|
+
[52, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
165
|
+
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
|
166
|
+
27, 28, -1, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
167
|
+
41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
|
168
|
+
|
169
|
+
# @private
|
170
|
+
THU_LONG_LEAP =
|
171
|
+
[52, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
172
|
+
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
|
173
|
+
27, 28, -1, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
174
|
+
41, 42, 43, 44, 45, 46, 47, 48, 49, 59]
|
175
|
+
|
176
|
+
# Returns today's parsha(ios) or an empty string if there are none.
|
177
|
+
# @param skip_extra [Boolean] if true, do not return "extra" Parsha
|
178
|
+
# names such as Zachor or Hagadol.
|
179
|
+
# @return [String]
|
180
|
+
def parsha(skip_extra=false)
|
181
|
+
# if today is not Shabbos, then there is no normal parsha reading
|
182
|
+
return nil if self.day != 7
|
183
|
+
|
184
|
+
# kvia= whether a Hebrew year is short/regular/long (0/1/2)
|
185
|
+
# rosh_hashana= Rosh Hashana of this Hebrew year
|
186
|
+
# rosh_hashana_day= day of week Rosh Hashana was on this year
|
187
|
+
# week= current week in Hebrew calendar from Rosh Hashana
|
188
|
+
# array= the correct index array for this Hebrew year
|
189
|
+
# index= the index number of the parsha name
|
190
|
+
array = []
|
191
|
+
# create a clone of this date
|
192
|
+
rosh_hashana = HebrewDate.new_from_hebrew(@hebrew_year, 7, 1)
|
193
|
+
|
194
|
+
# get day Rosh Hashana was on
|
195
|
+
rosh_hashana_day = rosh_hashana.day
|
196
|
+
|
197
|
+
# week is the week since the first Shabbos on or after Rosh Hashana
|
198
|
+
week = (((@abs_date - rosh_hashana.abs_date) -
|
199
|
+
(7 - rosh_hashana_day)) / 7.0).to_i
|
200
|
+
|
201
|
+
# get kvia
|
202
|
+
if _cheshvan_long? && !_kislev_short?
|
203
|
+
kvia = 2
|
204
|
+
elsif !_cheshvan_long? && _kislev_short?
|
205
|
+
kvia = 0
|
206
|
+
else
|
207
|
+
kvia = 1
|
208
|
+
end
|
209
|
+
|
210
|
+
# determine appropriate array
|
211
|
+
if hebrew_leap_year?
|
212
|
+
# not leap year
|
213
|
+
case rosh_hashana_day
|
214
|
+
when 7 # RH was on a Sat
|
215
|
+
if kvia == 0
|
216
|
+
array = SAT_SHORT_LEAP
|
217
|
+
elsif kvia == 2
|
218
|
+
array = @israeli ? SAT_SHORT_LEAP : SAT_LONG_LEAP
|
219
|
+
end
|
220
|
+
when 2 # RH was on a Mon
|
221
|
+
if kvia == 0
|
222
|
+
array = @israeli ? MON_SHORT_LEAP_ISRAEL : MON_SHORT_LEAP
|
223
|
+
elsif kvia == 2
|
224
|
+
array = @israeli ? MON_LONG_LEAP_ISRAEL : MON_LONG_LEAP
|
225
|
+
end
|
226
|
+
when 3 # RH was on a Tue
|
227
|
+
if kvia == 1
|
228
|
+
array = @israeli ? MON_LONG_LEAP_ISRAEL : MON_LONG_LEAP
|
229
|
+
end
|
230
|
+
when 5 # RH was on a Thu
|
231
|
+
if kvia == 0
|
232
|
+
array = THU_SHORT_LEAP
|
233
|
+
elsif kvia == 2
|
234
|
+
array = THU_LONG_LEAP
|
235
|
+
end
|
236
|
+
end
|
237
|
+
else
|
238
|
+
case rosh_hashana_day
|
239
|
+
when 7 # RH was on a Saturday
|
240
|
+
if kvia == 0
|
241
|
+
array = SAT_SHORT
|
242
|
+
elsif kvia == 2
|
243
|
+
array = SAT_LONG
|
244
|
+
end
|
245
|
+
when 2 # RH was on a Monday
|
246
|
+
if kvia == 0
|
247
|
+
array = MON_SHORT
|
248
|
+
elsif kvia == 2
|
249
|
+
array = @israeli ? MON_SHORT : MON_LONG
|
250
|
+
end
|
251
|
+
when 3 # RH was on a Tuesday
|
252
|
+
if kvia == 1
|
253
|
+
array = @israeli ? MON_SHORT : MON_LONG
|
254
|
+
end
|
255
|
+
when 5 # RH was on a Thursday
|
256
|
+
if kvia == 1
|
257
|
+
array = @israeli ? THU_NORMAL_ISRAEL : THU_NORMAL
|
258
|
+
elsif kvia == 2
|
259
|
+
array = THU_LONG
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
# if something goes wrong
|
265
|
+
if array.length == 0
|
266
|
+
return 'Was not able to set the index array to any of the known types.'
|
267
|
+
end
|
268
|
+
|
269
|
+
# get index from array
|
270
|
+
index = array[week]
|
271
|
+
|
272
|
+
# If no Parsha this week
|
273
|
+
return nil if index < 0
|
274
|
+
|
275
|
+
# if parsha this week
|
276
|
+
subindex = @ashkenaz ? 1 : 0
|
277
|
+
|
278
|
+
unless skip_extra
|
279
|
+
extra_parsha = _extra_parsha
|
280
|
+
if extra_parsha
|
281
|
+
return "#{PARSHA_NAMES[index][subindex]}/#{extra_parsha}"
|
282
|
+
end
|
283
|
+
end
|
284
|
+
PARSHA_NAMES[index][subindex]
|
285
|
+
end
|
286
|
+
|
287
|
+
private
|
288
|
+
|
289
|
+
# Returns any extra information regarding a Shabbos: in particular
|
290
|
+
# Shabbos Shuva, Hagadol, and the 4 Parshios
|
291
|
+
# (Shekalim, Zachor, Parah, and Hachodesh).
|
292
|
+
# @return [String]
|
293
|
+
def _extra_parsha
|
294
|
+
return if self.day != 7
|
295
|
+
|
296
|
+
adar = last_month_of_hebrew_year
|
297
|
+
|
298
|
+
if @hebrew_month == 1
|
299
|
+
return 'Hagadol' if @hebrew_date > 8 && @hebrew_date < 15
|
300
|
+
return 'Hachodesh' if @hebrew_date == 1
|
301
|
+
end
|
302
|
+
return 'Shuva' if @hebrew_month == 7 && @hebrew_date < 10
|
303
|
+
|
304
|
+
# Shekalim is the week before R.C. Adar,
|
305
|
+
# unless R.C. Adar falls out on Shabbos.
|
306
|
+
return 'Shekalim' if @hebrew_month == adar - 1 && @hebrew_date > 24
|
307
|
+
if @hebrew_month == adar
|
308
|
+
return 'Shekalim' if @hebrew_date == 1
|
309
|
+
return 'Zachor' if @hebrew_date > 7 && @hebrew_date < 14
|
310
|
+
return 'Parah' if @hebrew_date > 17 && @hebrew_date < 24
|
311
|
+
return 'Hachodesh' if @hebrew_date > 24
|
312
|
+
end
|
313
|
+
nil
|
314
|
+
end
|
315
|
+
|
316
|
+
end
|
317
|
+
end
|