Class: Zmanim::HebrewCalendar::JewishCalendar
- Inherits:
-
JewishDate
- Object
- JewishDate
- Zmanim::HebrewCalendar::JewishCalendar
show all
- Defined in:
- lib/zmanim/hebrew_calendar/jewish_calendar.rb
Constant Summary
collapse
- SIGNIFICANT_DAYS =
%i(erev_rosh_hashana rosh_hashana tzom_gedalyah erev_yom_kippur yom_kippur
erev_succos succos chol_hamoed_succos hoshana_rabbah shemini_atzeres simchas_torah
chanukah tenth_of_teves tu_beshvat
taanis_esther purim shushan_purim purim_katan shushan_purim_katan
erev_pesach pesach chol_hamoed_pesach pesach_sheni erev_shavuos shavuos
seventeen_of_tammuz tisha_beav tu_beav
yom_hashoah yom_hazikaron yom_haatzmaut yom_yerushalayim)
- SIGNIFICANT_TEFILOS =
%i(yaaleh_veyavo al_hanissim begin_mashiv_haruach end_mashiv_haruach mashiv_haruach begin_morid_hatal morid_hatal vesein_tal_umatar vesein_beracha atah_yatzarta borchi_nafshi)
- SIGNIFICANT_SHABBOS =
%i(parshas_shekalim parshas_zachor parshas_parah parshas_hachodesh shabbos_hagadol shabbos_shuva)
Constants inherited
from JewishDate
Zmanim::HebrewCalendar::JewishDate::CHALAKIM_MOLAD_TOHU, Zmanim::HebrewCalendar::JewishDate::CHALAKIM_PER_DAY, Zmanim::HebrewCalendar::JewishDate::CHALAKIM_PER_HOUR, Zmanim::HebrewCalendar::JewishDate::CHALAKIM_PER_MINUTE, Zmanim::HebrewCalendar::JewishDate::CHALAKIM_PER_MONTH, Zmanim::HebrewCalendar::JewishDate::CHESHVAN_KISLEV_KEVIAH, Zmanim::HebrewCalendar::JewishDate::JEWISH_EPOCH, Zmanim::HebrewCalendar::JewishDate::MONTHS, Zmanim::HebrewCalendar::JewishDate::RD
Instance Attribute Summary collapse
Attributes inherited from JewishDate
#day_of_week, #gregorian_date, #jewish_day, #jewish_month, #jewish_year, #molad_chalakim, #molad_hours, #molad_minutes
Instance Method Summary
collapse
Methods inherited from JewishDate
#+, #-, #<=>, #back!, #cheshvan_kislev_kviah, #cheshvan_long?, #cheshvan_short?, #date=, #day_number_of_jewish_year, #days_in_gregorian_month, #days_in_gregorian_year, #days_in_jewish_month, #days_in_jewish_year, #forward!, from_date, from_jewish_date, from_molad, #gregorian_day, #gregorian_day=, #gregorian_leap_year?, #gregorian_month, #gregorian_month=, #gregorian_year, #gregorian_year=, #jewish_leap_year?, #jewish_month_from_name, #jewish_month_name, #kislev_long?, #kislev_short?, #molad, #months_in_jewish_year, #reset_date!, #set_gregorian_date, #set_jewish_date, #sorted_days_in_jewish_year, #sorted_months_in_jewish_year
Constructor Details
Returns a new instance of JewishCalendar.
19
20
21
22
23
24
25
26
27
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 19
def initialize(*args)
if args.count == 4
super(*args[0..2])
else
super
end
@in_israel = !!args[3]
@use_modern_holidays = false
end
|
Instance Attribute Details
#in_israel ⇒ Object
Returns the value of attribute in_israel.
5
6
7
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 5
def in_israel
@in_israel
end
|
#use_modern_holidays ⇒ Object
Returns the value of attribute use_modern_holidays.
5
6
7
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 5
def use_modern_holidays
@use_modern_holidays
end
|
Instance Method Details
#al_hanissim?(walled_city = false) ⇒ Boolean
231
232
233
234
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 231
def al_hanissim?(walled_city=false)
purim_day = walled_city ? :shushan_purim : :purim
[:chanukah, purim_day].include?(significant_day)
end
|
#chanukah? ⇒ Boolean
65
66
67
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 65
def chanukah?
significant_day == :chanukah
end
|
#chol_hamoed? ⇒ Boolean
42
43
44
45
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 42
def chol_hamoed?
sd = significant_day
sd && (sd.to_s.start_with?('chol_hamoed_') || sd == :hoshana_rabbah)
end
|
#daf_yomi_yerushalmi ⇒ Object
#day_of_chanukah ⇒ Object
69
70
71
72
73
74
75
76
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 69
def day_of_chanukah
return unless chanukah?
if jewish_month_name == :kislev
jewish_day - 24
else
(kislev_short? ? 5 : 6) + jewish_day
end
end
|
#day_of_omer ⇒ Object
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 78
def day_of_omer
case jewish_month_name
when :nissan
return (jewish_day - 15 if jewish_day > 15)
when :iyar
return jewish_day + 15
when :sivan
return (jewish_day + 44) if jewish_day < 6
end
end
|
#erev_rosh_chodesh? ⇒ Boolean
61
62
63
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 61
def erev_rosh_chodesh?
jewish_day == 29 && jewish_month != 6
end
|
#erev_yom_tov? ⇒ Boolean
47
48
49
50
51
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 47
def erev_yom_tov?
return false unless sd = significant_day
sd.to_s.start_with?('erev_') || sd == :hoshana_rabbah ||
(sd == :chol_hamoed_pesach && jewish_day == 20)
end
|
#mashiv_haruach? ⇒ Boolean
198
199
200
201
202
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 198
def mashiv_haruach?
start_date = JewishDate.new(jewish_year, 7, 22)
end_date = JewishDate.new(jewish_year, 1, 15)
self.between?(start_date, end_date)
end
|
#mashiv_haruach_ends? ⇒ Boolean
194
195
196
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 194
def mashiv_haruach_ends?
jewish_month == 1 && jewish_day == 15
end
|
#mashiv_haruach_starts? ⇒ Boolean
190
191
192
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 190
def mashiv_haruach_starts?
jewish_month == 7 && jewish_day == 22
end
|
#molad_as_datetime ⇒ Object
DateTime for molad as UTC
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 90
def molad_as_datetime
m = molad
location_name = 'Jerusalem, Israel'
latitude = 31.778 longitude = 35.2354 tz = TZInfo::Timezone.get('Asia/Jerusalem')
geo = Zmanim::Util::GeoLocation.new(location_name, latitude, longitude, tz)
seconds = (m.molad_chalakim * 10) / 3.0
time = DateTime.new(m.gregorian_year, m.gregorian_month, m.gregorian_day,
m.molad_hours, m.molad_minutes, seconds, '+2')
offset_hours = geo.local_mean_time_offset / Zmanim::AstronomicalCalendar::HOUR_MILLIS.to_f
time -= offset_hours / 24.0
time.new_offset(0)
end
|
#morid_hatal? ⇒ Boolean
204
205
206
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 204
def morid_hatal?
!mashiv_haruach? || mashiv_haruach_starts? || mashiv_haruach_ends?
end
|
#parshas_hashavua ⇒ Object
#rosh_chodesh? ⇒ Boolean
57
58
59
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 57
def rosh_chodesh?
jewish_day == 30 || (jewish_day == 1 && jewish_month != 7)
end
|
#significant_day ⇒ Object
29
30
31
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 29
def significant_day
send("#{jewish_month_name}_significant_day")
end
|
#significant_shabbos ⇒ Object
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 165
def significant_shabbos
return nil unless day_of_week == 7
if jewish_month == 1
if jewish_day == 1
:parshas_hachodesh
elsif jewish_day.between?(8,14)
:shabbos_hagadol
end
elsif jewish_month == 7 && jewish_day.between?(3,9)
:shabbos_shuva
elsif jewish_month == months_in_jewish_year - 1 && jewish_day.between?(25,30)
:parshas_shekalim
elsif jewish_month == months_in_jewish_year
if jewish_day == 1
:parshas_shekalim
elsif jewish_day.between?(7, 13)
:parshas_zachor
elsif jewish_day.between?(17,23)
:parshas_parah
elsif jewish_day.between?(24,29)
:parshas_hachodesh
end
end
end
|
#sof_zman_kiddush_levana_15_days ⇒ Object
122
123
124
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 122
def sof_zman_kiddush_levana_15_days
molad_as_datetime + 15
end
|
#sof_zman_kiddush_levana_between_moldos ⇒ Object
117
118
119
120
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 117
def sof_zman_kiddush_levana_between_moldos
half_molad_in_days = CHALAKIM_PER_MONTH.to_f / (1080 * 24 * 2)
molad_as_datetime + half_molad_in_days
end
|
#taanis? ⇒ Boolean
53
54
55
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 53
def taanis?
%i(seventeen_of_tammuz tisha_beav tzom_gedalyah yom_kippur tenth_of_teves taanis_esther).include?(significant_day)
end
|
#techilas_zman_kiddush_levana_3_days ⇒ Object
109
110
111
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 109
def techilas_zman_kiddush_levana_3_days
molad_as_datetime + 3
end
|
#techilas_zman_kiddush_levana_7_days ⇒ Object
113
114
115
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 113
def techilas_zman_kiddush_levana_7_days
molad_as_datetime + 7
end
|
#tefilah_additions(walled_city: false, nusach: :ashkenaz) ⇒ Object
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 146
def tefilah_additions(walled_city: false, nusach: :ashkenaz)
additions = []
if mashiv_haruach_starts?
additions << :begin_mashiv_haruach
elsif mashiv_haruach_ends?
additions << (nusach == :sefard ? :begin_morid_hatal : :end_mashiv_haruach)
else
additions << :mashiv_haruach if mashiv_haruach?
additions << :morid_hatal if nusach == :sefard && morid_hatal?
end
additions << :vesein_beracha if vesein_beracha?
additions << :vesein_tal_umatar if vesein_tal_umatar?
additions << :atah_yatzarta if day_of_week == 7 && rosh_chodesh?
additions << :yaaleh_veyavo if yaaleh_veyavo?
additions << :al_hanissim if al_hanissim?(walled_city)
additions << :borchi_nafshi if rosh_chodesh?
additions
end
|
#tehillim_portion ⇒ Object
#vesein_beracha? ⇒ Boolean
222
223
224
225
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 222
def vesein_beracha?
return false if day_of_week == 7 || yom_tov_assur_bemelacha?
!vesein_tal_umatar?
end
|
#vesein_tal_umatar? ⇒ Boolean
This presumes the evenings of December 4/5 are always the initial start date outside of Israel Because the jewish date does not auto-increment in the evening, we use December 5/6 as the start date and rely on the user to increment the jewish date after nightfall. Note that according to many, the date for Vesein Tal Umatar is tied to the Julian calendar and has historically moved over time as the deviance from the Gregorian calendar increases. The date of December 4/5 is to be used for the 20th and 21st century.
214
215
216
217
218
219
220
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 214
def vesein_tal_umatar?
return false if day_of_week == 7 || yom_tov_assur_bemelacha?
start_date = JewishDate.new(jewish_year, 8, 7)
start_date.set_gregorian_date(start_date.gregorian_year, 12, gregorian_leap_year?(start_date.gregorian_year+1) ? 6 : 5) unless in_israel
end_date = JewishDate.new(jewish_year, 1, 15)
self.between?(start_date, end_date)
end
|
#yaaleh_veyavo? ⇒ Boolean
227
228
229
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 227
def yaaleh_veyavo?
rosh_chodesh? || chol_hamoed? || yom_tov_assur_bemelacha?
end
|
#yom_tov? ⇒ Boolean
33
34
35
36
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 33
def yom_tov?
sd = significant_day
sd && !sd.to_s.start_with?('erev_') && (!taanis? || sd == :yom_kippur)
end
|
#yom_tov_assur_bemelacha? ⇒ Boolean
38
39
40
|
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 38
def yom_tov_assur_bemelacha?
%i(pesach shavuos rosh_hashana yom_kippur succos shemini_atzeres simchas_torah).include?(significant_day)
end
|