Class: Zmanim::HebrewCalendar::JewishCalendar

Inherits:
JewishDate
  • Object
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

#initialize(*args) ⇒ JewishCalendar

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_israelObject

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_holidaysObject

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

Returns:

  • (Boolean)


277
278
279
280
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 277

def al_hanissim?(walled_city=false)
  purim_day = walled_city ? :shushan_purim : :purim
  [:chanukah, purim_day].include?(significant_day)
end

#assur_bemelacha?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 33

def assur_bemelacha?
  day_of_week == 7 || yom_tov_assur_bemelacha?
end

#candle_lighting?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 41

def candle_lighting?
  tomorrow_assur_bemelacha?
end

#chanukah?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 95

def chanukah?
  significant_day == :chanukah
end

#chol_hamoed?Boolean

Returns:

  • (Boolean)


78
79
80
81
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 78

def chol_hamoed?
  sd = significant_day
  sd && (sd.to_s.start_with?('chol_hamoed_') || sd == :hoshana_rabbah)
end

#daf_yomi_bavliObject



156
157
158
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 156

def daf_yomi_bavli
  Zmanim::Limudim::Calculators::DafYomiBavli.new.limud(self)
end

#daf_yomi_yerushalmiObject



160
161
162
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 160

def daf_yomi_yerushalmi
  Zmanim::Limudim::Calculators::DafYomiYerushalmi.new.limud(self)
end

#day_of_chanukahObject



99
100
101
102
103
104
105
106
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 99

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_omerObject



108
109
110
111
112
113
114
115
116
117
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 108

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

#delayed_candle_lighting?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 45

def delayed_candle_lighting?
  day_of_week != 6 && candle_lighting? && assur_bemelacha?
end

#erev_rosh_chodesh?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 91

def erev_rosh_chodesh?
  jewish_day == 29 && jewish_month != 6
end

#erev_yom_tov?Boolean

Returns:

  • (Boolean)


58
59
60
61
62
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 58

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

#erev_yom_tov_sheni?Boolean

Returns:

  • (Boolean)


71
72
73
74
75
76
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 71

def erev_yom_tov_sheni?
  (jewish_month == 7 && jewish_day == 1) ||
      (!in_israel && ((jewish_month == 7 && [15, 22].include?(jewish_day)) ||
                      (jewish_month == 1 && [15, 21].include?(jewish_day)) ||
                      (jewish_month == 3 && jewish_day == 6)))
end

#mashiv_haruach?Boolean

Returns:

  • (Boolean)


238
239
240
241
242
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 238

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

Returns:

  • (Boolean)


234
235
236
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 234

def mashiv_haruach_ends?
  jewish_month == 1 && jewish_day == 15
end

#mashiv_haruach_starts?Boolean

Returns:

  • (Boolean)


230
231
232
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 230

def mashiv_haruach_starts?
  jewish_month == 7 && jewish_day == 22
end

#mishna_yomisObject



172
173
174
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 172

def mishna_yomis
  Zmanim::Limudim::Calculators::MishnaYomis.new.limud(self)
end

#molad_as_datetimeObject

DateTime for molad as UTC



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 120

def molad_as_datetime
  m = molad
  location_name = 'Jerusalem, Israel'
  latitude = 31.778   # Har Habayis latitude
  longitude = 35.2354 # Har Habayis longitude
  tz = TZInfo::Timezone.get('Asia/Jerusalem')

  geo = Zmanim::Util::GeoLocation.new(location_name, latitude, longitude, tz)
  seconds = (m.molad_chalakim * 10) / 3.0
  # molad as local mean time
  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
  # molad as Jerusalem standard time
  time -= offset_hours / 24.0
  # molad as UTC
  time.new_offset(0)
end

#morid_hatal?Boolean

Returns:

  • (Boolean)


244
245
246
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 244

def morid_hatal?
  !mashiv_haruach? || mashiv_haruach_starts? || mashiv_haruach_ends?
end

#parshas_hashavuaObject



164
165
166
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 164

def parshas_hashavua
  Zmanim::Limudim::Calculators::Parsha.new(in_israel: in_israel).limud(self)
end

#pirkei_avosObject



176
177
178
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 176

def pirkei_avos
  Zmanim::Limudim::Calculators::PirkeiAvos.new(in_israel: in_israel).limud(self)
end

#rosh_chodesh?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 87

def rosh_chodesh?
  jewish_day == 30 || (jewish_day == 1 && jewish_month != 7)
end

#shabbos_mevorchim?Boolean

Returns:

  • (Boolean)


224
225
226
227
228
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 224

def shabbos_mevorchim?
  day_of_week == 7 &&
      jewish_month != 6 &&
      (23..29).include?(jewish_day)
end

#significant_dayObject



29
30
31
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 29

def significant_day
  send("#{jewish_month_name}_significant_day")
end

#significant_shabbosObject



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 199

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_daysObject



152
153
154
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 152

def sof_zman_kiddush_levana_15_days
  molad_as_datetime + 15
end

#sof_zman_kiddush_levana_between_moldosObject



147
148
149
150
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 147

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

Returns:

  • (Boolean)


83
84
85
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 83

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_daysObject



139
140
141
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 139

def techilas_zman_kiddush_levana_3_days
  molad_as_datetime + 3
end

#techilas_zman_kiddush_levana_7_daysObject



143
144
145
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 143

def techilas_zman_kiddush_levana_7_days
  molad_as_datetime + 7
end

#tefilah_additions(walled_city: false, nusach: :ashkenaz) ⇒ Object



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 180

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_portionObject



168
169
170
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 168

def tehillim_portion
  Zmanim::Limudim::Calculators::TehillimMonthly.new.limud(self)
end

#tomorrow_assur_bemelacha?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 37

def tomorrow_assur_bemelacha?
  day_of_week == 6 || erev_yom_tov? || erev_yom_tov_sheni?
end

#vesein_beracha?Boolean

Returns:

  • (Boolean)


268
269
270
271
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 268

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.

Returns:

  • (Boolean)


254
255
256
257
258
259
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 254

def vesein_tal_umatar?
  return false if day_of_week == 7 || yom_tov_assur_bemelacha?
  start_date = gregorian_vesein_tal_umatar_start
  end_date = JewishDate.new(jewish_year, 1, 15)
  self.between?(start_date, end_date)
end

#vesein_tal_umatar_starts_tonight?Boolean

Returns:

  • (Boolean)


261
262
263
264
265
266
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 261

def vesein_tal_umatar_starts_tonight?
  return false if day_of_week == 6
  start_date = gregorian_vesein_tal_umatar_start
  (day_of_week == 7 && self == start_date) ||
      self == (start_date - 1)
end

#yaaleh_veyavo?Boolean

Returns:

  • (Boolean)


273
274
275
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 273

def yaaleh_veyavo?
  rosh_chodesh? || chol_hamoed? || yom_tov_assur_bemelacha?
end

#yom_tov?Boolean

Returns:

  • (Boolean)


49
50
51
52
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 49

def yom_tov?
  sd = significant_day
  sd && !sd.to_s.start_with?('erev_') && (!taanis? || sd == :yom_kippur)
end

#yom_tov_assur_bemelacha?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 54

def yom_tov_assur_bemelacha?
  %i(pesach shavuos rosh_hashana yom_kippur succos shemini_atzeres simchas_torah).include?(significant_day)
end

#yom_tov_sheni?Boolean

Returns:

  • (Boolean)


64
65
66
67
68
69
# File 'lib/zmanim/hebrew_calendar/jewish_calendar.rb', line 64

def yom_tov_sheni?
  (jewish_month == 7 && jewish_day == 2) ||
      (!in_israel && ((jewish_month == 7 && [16, 23].include?(jewish_day)) ||
                      (jewish_month == 1 && [16, 22].include?(jewish_day)) ||
                      (jewish_month == 3 && jewish_day == 7)))
end