zmanim 0.1.0 → 0.4.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 +5 -5
- data/CHANGELOG.md +53 -0
- data/lib/zmanim.rb +4 -4
- data/lib/zmanim/hebrew_calendar/hebrew_date_formatter.rb +10 -8
- data/lib/zmanim/hebrew_calendar/jewish_calendar.rb +76 -10
- data/lib/zmanim/hebrew_calendar/jewish_date.rb +45 -0
- data/lib/zmanim/limudim/calculators/daf_hashavua_bavli.rb +23 -0
- data/lib/zmanim/limudim/calculators/daf_yomi_yerushalmi.rb +2 -6
- data/lib/zmanim/limudim/calculators/mishna_yomis.rb +1 -1
- data/lib/zmanim/limudim/calculators/parsha.rb +31 -31
- data/lib/zmanim/limudim/calculators/pirkei_avos.rb +54 -0
- data/lib/zmanim/limudim/cycle.rb +0 -4
- data/lib/zmanim/limudim/limud.rb +4 -0
- data/lib/zmanim/limudim/limud_calculator.rb +12 -6
- data/lib/zmanim/limudim/limudim_formatter.rb +12 -2
- data/lib/zmanim/version.rb +1 -1
- data/lib/zmanim/zmanim_calendar.rb +56 -13
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 60f1ce1f598d2bb45067fadbb609dca84e62e94da2144d6815c04a14083eeeb9
|
4
|
+
data.tar.gz: e83e26224f23d21216258f3e31ad65bafc18af91f250c09ab9e0a5941061aa34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0868fb13463bc643a818c5faa9aad148659ea8597eceadbafbc4a544d8cc88f7b8ec069361939f860eb6c76c4c07b70f7e0100ab3b4e4ff2e19a73fb2dec9908'
|
7
|
+
data.tar.gz: 946ccd345d2fcb4612ff4b2b2782de1c78a822e97fd70b12b4c48569c51d98907aeb05dd9b97894fa0cc4a9397167e5af75e53492e625c9b2f425282ae9d8e08
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [0.4.0] - 2020-10-13
|
8
|
+
### Added
|
9
|
+
- `JewishCalendar#end_of_week` returns Shabbos for this week
|
10
|
+
- Parshas Hashavua modifier to return blank Limud if the standard Parsha is not read this Shabbos
|
11
|
+
- Daf Hashavua calculator
|
12
|
+
### Changed
|
13
|
+
- Refactor kviah calculation logic to JewishDate
|
14
|
+
- Remove formatter dependency for Parsha calculator
|
15
|
+
### Fixed
|
16
|
+
- Added Lag B'Omer as significant day / yom tov
|
17
|
+
- Fixed Lag B'Omer spelling for english formatted omer
|
18
|
+
|
19
|
+
## [0.3.0] - 2018-09-17
|
20
|
+
### Added
|
21
|
+
- Elevations used in shaos zmanios calculations if use_elevation property is set
|
22
|
+
- Hanetz and Shkia methods will use the appropriate calculation based on use_elevation setting
|
23
|
+
- Support Alos and Tzais offset using temporal minutes
|
24
|
+
- Various Assur Bemelacha related methods for calendar dates using JewishCalendar,
|
25
|
+
as well as point-in-time using ZmanimCalendar.
|
26
|
+
- Methods to determine Shabbos Mevorchim, first night of Vesein Tal Umatar,
|
27
|
+
and delayed candle lighting
|
28
|
+
|
29
|
+
## [0.2.2] - 2018-08-31
|
30
|
+
### Fixed
|
31
|
+
- Typo in formatted Masechtos
|
32
|
+
- Additional load sequence issues
|
33
|
+
|
34
|
+
## [0.2.1] - 2018-04-30
|
35
|
+
### Fixed
|
36
|
+
- Additional load sequence issues
|
37
|
+
|
38
|
+
## [0.2.0] - 2018-04-22
|
39
|
+
### Added
|
40
|
+
- Pirkei Avos limudim calculation
|
41
|
+
- Support for explicit skip_unit (used by DafYomiYerushalmi)
|
42
|
+
- CHANGELOG (this file :) )
|
43
|
+
### Changed
|
44
|
+
- Refactored skip_interval to generic limud detection
|
45
|
+
### Fixed
|
46
|
+
- Cycle detection falsely identifies dates between cycle windows as belonging to a prior cycle
|
47
|
+
- Load sequence can't find Zmanim module when loaded externally
|
48
|
+
|
49
|
+
## [0.1.0] - 2018-01-09 (Original release)
|
50
|
+
### Added
|
51
|
+
- Port of KosherJava/zmanim library, primary functionality
|
52
|
+
- Limudim calculation framework
|
53
|
+
- Weekly Parsha, Tehillim (Month cycle), Mishna Yomis limudim calculation
|
data/lib/zmanim.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'tzinfo'
|
2
|
-
Dir[File.dirname(__FILE__) + "/**/*.rb"].each {|file| require file }
|
3
2
|
|
4
|
-
module Zmanim
|
5
|
-
|
6
|
-
|
3
|
+
module Zmanim; end
|
4
|
+
module Zmanim::Limudim; end
|
5
|
+
|
6
|
+
Dir[File.dirname(__FILE__) + "/**/*.rb"].each {|file| require file }
|
@@ -1,4 +1,8 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
+
require 'zmanim/util/text_helper'
|
3
|
+
require 'zmanim/util/hebrew_numeric_formatter'
|
4
|
+
require_relative 'jewish_calendar'
|
5
|
+
|
2
6
|
module Zmanim::HebrewCalendar
|
3
7
|
class HebrewDateFormatter
|
4
8
|
extend Zmanim::Util::TextHelper
|
@@ -42,7 +46,7 @@ module Zmanim::HebrewCalendar
|
|
42
46
|
transliterated: Zmanim::HebrewCalendar::JewishCalendar::SIGNIFICANT_DAYS.each_with_object({}){|d, h|
|
43
47
|
h[d] = titleize(d)
|
44
48
|
}.merge(tzom_gedalyah: 'Fast of Gedalyah', tenth_of_teves: 'Tenth of Teves', tu_beshvat: "Tu B'Shvat",
|
45
|
-
taanis_esther: 'Fast of Esther', seventeen_of_tammuz: 'Seventeenth of Tammuz',
|
49
|
+
taanis_esther: 'Fast of Esther', lag_baomer: "Lag B'Omer", seventeen_of_tammuz: 'Seventeenth of Tammuz',
|
46
50
|
tisha_beav: "Tisha B'Av", tu_beav: "Tu B'Av", yom_hashoah: 'Yom HaShoah', yom_haatzmaut: "Yom Ha'atzmaut"),
|
47
51
|
hebrew: {
|
48
52
|
erev_rosh_hashana: 'ערב ראש השנה',
|
@@ -68,6 +72,7 @@ module Zmanim::HebrewCalendar
|
|
68
72
|
pesach: 'פסח',
|
69
73
|
chol_hamoed_pesach: 'חול המועד פסח',
|
70
74
|
pesach_sheni: 'פסח שני',
|
75
|
+
lag_baomer: 'ל״ג בעומר',
|
71
76
|
erev_shavuos: 'ערב שבועות',
|
72
77
|
shavuos: 'שבועות',
|
73
78
|
seventeen_of_tammuz: 'שבעה עשר בתמוז',
|
@@ -175,18 +180,15 @@ module Zmanim::HebrewCalendar
|
|
175
180
|
if hebrew_format
|
176
181
|
format_hebrew_number(number) + ' ' + hebrew_omer_prefix + 'עומר'
|
177
182
|
else
|
178
|
-
number == 33 ?
|
183
|
+
number == 33 ? "Lag B'Omer" : "Omer #{number}"
|
179
184
|
end
|
180
185
|
end
|
181
186
|
|
182
187
|
def format_kviah(year)
|
183
188
|
date = year.is_a?(Numeric) ? Zmanim::HebrewCalendar::JewishDate.new(year, 7, 1) : year
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
date.jewish_month = 1
|
188
|
-
pesach_day = date.day_of_week
|
189
|
-
"#{format_hebrew_number(rosh_hashana_day)}#{kviah_glyph}#{format_hebrew_number(pesach_day)}".delete(GERESH)
|
189
|
+
kviah_values = date.kviah
|
190
|
+
kviah_glyph = {chaseirim: 'ח', kesidran: 'כ', shelaimim: 'ש'}[kviah_values[:kviah]]
|
191
|
+
"#{format_hebrew_number(kviah_values[:rosh_hashana])}#{kviah_glyph}#{format_hebrew_number(kviah_values[:pesach])}".delete(GERESH)
|
190
192
|
end
|
191
193
|
|
192
194
|
def format_tefilah_additions(calendar, customs={walled_city: false, nusach: :ashkenaz})
|
@@ -8,7 +8,7 @@ module Zmanim::HebrewCalendar
|
|
8
8
|
erev_succos succos chol_hamoed_succos hoshana_rabbah shemini_atzeres simchas_torah
|
9
9
|
chanukah tenth_of_teves tu_beshvat
|
10
10
|
taanis_esther purim shushan_purim purim_katan shushan_purim_katan
|
11
|
-
erev_pesach pesach chol_hamoed_pesach pesach_sheni erev_shavuos shavuos
|
11
|
+
erev_pesach pesach chol_hamoed_pesach pesach_sheni lag_baomer erev_shavuos shavuos
|
12
12
|
seventeen_of_tammuz tisha_beav tu_beav
|
13
13
|
yom_hashoah yom_hazikaron yom_haatzmaut yom_yerushalayim)
|
14
14
|
|
@@ -30,6 +30,22 @@ module Zmanim::HebrewCalendar
|
|
30
30
|
send("#{jewish_month_name}_significant_day")
|
31
31
|
end
|
32
32
|
|
33
|
+
def assur_bemelacha?
|
34
|
+
day_of_week == 7 || yom_tov_assur_bemelacha?
|
35
|
+
end
|
36
|
+
|
37
|
+
def tomorrow_assur_bemelacha?
|
38
|
+
day_of_week == 6 || erev_yom_tov? || erev_yom_tov_sheni?
|
39
|
+
end
|
40
|
+
|
41
|
+
def candle_lighting?
|
42
|
+
tomorrow_assur_bemelacha?
|
43
|
+
end
|
44
|
+
|
45
|
+
def delayed_candle_lighting?
|
46
|
+
day_of_week != 6 && candle_lighting? && assur_bemelacha?
|
47
|
+
end
|
48
|
+
|
33
49
|
def yom_tov?
|
34
50
|
sd = significant_day
|
35
51
|
sd && !sd.to_s.start_with?('erev_') && (!taanis? || sd == :yom_kippur)
|
@@ -39,17 +55,31 @@ module Zmanim::HebrewCalendar
|
|
39
55
|
%i(pesach shavuos rosh_hashana yom_kippur succos shemini_atzeres simchas_torah).include?(significant_day)
|
40
56
|
end
|
41
57
|
|
42
|
-
def chol_hamoed?
|
43
|
-
sd = significant_day
|
44
|
-
sd && (sd.to_s.start_with?('chol_hamoed_') || sd == :hoshana_rabbah)
|
45
|
-
end
|
46
|
-
|
47
58
|
def erev_yom_tov?
|
48
59
|
return false unless sd = significant_day
|
49
60
|
sd.to_s.start_with?('erev_') || sd == :hoshana_rabbah ||
|
50
61
|
(sd == :chol_hamoed_pesach && jewish_day == 20)
|
51
62
|
end
|
52
63
|
|
64
|
+
def yom_tov_sheni?
|
65
|
+
(jewish_month == 7 && jewish_day == 2) ||
|
66
|
+
(!in_israel && ((jewish_month == 7 && [16, 23].include?(jewish_day)) ||
|
67
|
+
(jewish_month == 1 && [16, 22].include?(jewish_day)) ||
|
68
|
+
(jewish_month == 3 && jewish_day == 7)))
|
69
|
+
end
|
70
|
+
|
71
|
+
def erev_yom_tov_sheni?
|
72
|
+
(jewish_month == 7 && jewish_day == 1) ||
|
73
|
+
(!in_israel && ((jewish_month == 7 && [15, 22].include?(jewish_day)) ||
|
74
|
+
(jewish_month == 1 && [15, 21].include?(jewish_day)) ||
|
75
|
+
(jewish_month == 3 && jewish_day == 6)))
|
76
|
+
end
|
77
|
+
|
78
|
+
def chol_hamoed?
|
79
|
+
sd = significant_day
|
80
|
+
sd && (sd.to_s.start_with?('chol_hamoed_') || sd == :hoshana_rabbah)
|
81
|
+
end
|
82
|
+
|
53
83
|
def taanis?
|
54
84
|
%i(seventeen_of_tammuz tisha_beav tzom_gedalyah yom_kippur tenth_of_teves taanis_esther).include?(significant_day)
|
55
85
|
end
|
@@ -123,6 +153,10 @@ module Zmanim::HebrewCalendar
|
|
123
153
|
molad_as_datetime + 15
|
124
154
|
end
|
125
155
|
|
156
|
+
def end_of_week
|
157
|
+
self + (7 - day_of_week)
|
158
|
+
end
|
159
|
+
|
126
160
|
def daf_yomi_bavli
|
127
161
|
Zmanim::Limudim::Calculators::DafYomiBavli.new.limud(self)
|
128
162
|
end
|
@@ -131,8 +165,14 @@ module Zmanim::HebrewCalendar
|
|
131
165
|
Zmanim::Limudim::Calculators::DafYomiYerushalmi.new.limud(self)
|
132
166
|
end
|
133
167
|
|
134
|
-
def
|
135
|
-
Zmanim::Limudim::Calculators::
|
168
|
+
def daf_hashavua_bavli
|
169
|
+
Zmanim::Limudim::Calculators::DafHashavuaBavli.new.limud(self)
|
170
|
+
end
|
171
|
+
|
172
|
+
def parshas_hashavua(current_week_only: false)
|
173
|
+
limud = Zmanim::Limudim::Calculators::Parsha.new(in_israel: in_israel).limud(self)
|
174
|
+
limud.clear! if current_week_only && limud.interval.end_date > end_of_week
|
175
|
+
limud
|
136
176
|
end
|
137
177
|
|
138
178
|
def tehillim_portion
|
@@ -143,6 +183,10 @@ module Zmanim::HebrewCalendar
|
|
143
183
|
Zmanim::Limudim::Calculators::MishnaYomis.new.limud(self)
|
144
184
|
end
|
145
185
|
|
186
|
+
def pirkei_avos
|
187
|
+
Zmanim::Limudim::Calculators::PirkeiAvos.new(in_israel: in_israel).limud(self)
|
188
|
+
end
|
189
|
+
|
146
190
|
def tefilah_additions(walled_city: false, nusach: :ashkenaz)
|
147
191
|
additions = []
|
148
192
|
if mashiv_haruach_starts?
|
@@ -187,6 +231,12 @@ module Zmanim::HebrewCalendar
|
|
187
231
|
end
|
188
232
|
end
|
189
233
|
|
234
|
+
def shabbos_mevorchim?
|
235
|
+
day_of_week == 7 &&
|
236
|
+
jewish_month != 6 &&
|
237
|
+
(23..29).include?(jewish_day)
|
238
|
+
end
|
239
|
+
|
190
240
|
def mashiv_haruach_starts?
|
191
241
|
jewish_month == 7 && jewish_day == 22
|
192
242
|
end
|
@@ -213,12 +263,18 @@ module Zmanim::HebrewCalendar
|
|
213
263
|
# for the 20th and 21st century.
|
214
264
|
def vesein_tal_umatar?
|
215
265
|
return false if day_of_week == 7 || yom_tov_assur_bemelacha?
|
216
|
-
start_date =
|
217
|
-
start_date.set_gregorian_date(start_date.gregorian_year, 12, gregorian_leap_year?(start_date.gregorian_year+1) ? 6 : 5) unless in_israel
|
266
|
+
start_date = gregorian_vesein_tal_umatar_start
|
218
267
|
end_date = JewishDate.new(jewish_year, 1, 15)
|
219
268
|
self.between?(start_date, end_date)
|
220
269
|
end
|
221
270
|
|
271
|
+
def vesein_tal_umatar_starts_tonight?
|
272
|
+
return false if day_of_week == 6
|
273
|
+
start_date = gregorian_vesein_tal_umatar_start
|
274
|
+
(day_of_week == 7 && self == start_date) ||
|
275
|
+
self == (start_date - 1)
|
276
|
+
end
|
277
|
+
|
222
278
|
def vesein_beracha?
|
223
279
|
return false if day_of_week == 7 || yom_tov_assur_bemelacha?
|
224
280
|
!vesein_tal_umatar?
|
@@ -257,6 +313,8 @@ module Zmanim::HebrewCalendar
|
|
257
313
|
def iyar_significant_day
|
258
314
|
if jewish_day == 14
|
259
315
|
:pesach_sheni
|
316
|
+
elsif jewish_day == 18
|
317
|
+
:lag_baomer
|
260
318
|
elsif use_modern_holidays
|
261
319
|
# Note that this logic follows the current rules, which were last revised in 5764.
|
262
320
|
# The calculations for years prior may not reflect the actual dates observed at that time.
|
@@ -386,5 +444,13 @@ module Zmanim::HebrewCalendar
|
|
386
444
|
:shushan_purim
|
387
445
|
end
|
388
446
|
end
|
447
|
+
|
448
|
+
def gregorian_vesein_tal_umatar_start
|
449
|
+
start_date = JewishDate.new(jewish_year, 8, 7)
|
450
|
+
unless in_israel
|
451
|
+
start_date.set_gregorian_date(start_date.gregorian_year, 12, gregorian_leap_year?(start_date.gregorian_year + 1) ? 6 : 5)
|
452
|
+
end
|
453
|
+
start_date
|
454
|
+
end
|
389
455
|
end
|
390
456
|
end
|
@@ -157,6 +157,40 @@ module Zmanim::HebrewCalendar
|
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
|
+
def succ
|
161
|
+
self + 1
|
162
|
+
end
|
163
|
+
|
164
|
+
def step(limit, step=1, &block)
|
165
|
+
if step < 0
|
166
|
+
downto(limit, -step, &block)
|
167
|
+
else
|
168
|
+
upto(limit, step, &block)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def downto(limit, step=1)
|
173
|
+
raise ArgumentError, 'step argument must be greater than 0' if step <= 0
|
174
|
+
return to_enum(__method__, limit, step) unless block_given?
|
175
|
+
c = self
|
176
|
+
while c >= limit
|
177
|
+
yield c
|
178
|
+
c -= step
|
179
|
+
end
|
180
|
+
self
|
181
|
+
end
|
182
|
+
|
183
|
+
def upto(limit, step=1)
|
184
|
+
raise ArgumentError, 'step argument must be greater than 0' if step <= 0
|
185
|
+
return to_enum(__method__, limit, step) unless block_given?
|
186
|
+
c = self
|
187
|
+
while c <= limit
|
188
|
+
yield c
|
189
|
+
c += step
|
190
|
+
end
|
191
|
+
self
|
192
|
+
end
|
193
|
+
|
160
194
|
def gregorian_year=(year)
|
161
195
|
set_gregorian_date(year, gregorian_month, gregorian_day)
|
162
196
|
end
|
@@ -275,6 +309,17 @@ module Zmanim::HebrewCalendar
|
|
275
309
|
CHESHVAN_KISLEV_KEVIAH[(days_in_jewish_year(year) % 10) - 3]
|
276
310
|
end
|
277
311
|
|
312
|
+
def kviah(year=jewish_year)
|
313
|
+
date = year.is_a?(Numeric) ? Zmanim::HebrewCalendar::JewishDate.new(year, 7, 1) : year
|
314
|
+
kviah = date.cheshvan_kislev_kviah
|
315
|
+
rosh_hashana_day = date.day_of_week
|
316
|
+
date.jewish_month = 1
|
317
|
+
pesach_day = date.day_of_week
|
318
|
+
{rosh_hashana: rosh_hashana_day,
|
319
|
+
kviah: kviah,
|
320
|
+
pesach: pesach_day}
|
321
|
+
end
|
322
|
+
|
278
323
|
# Returns a new JewishDate as the molad for given month
|
279
324
|
def molad(month=jewish_month, year=jewish_year)
|
280
325
|
self.class.from_molad(chalakim_since_molad_tohu(year, month))
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'zmanim/limudim/calculators/daf_yomi_bavli'
|
2
|
+
|
3
|
+
module Zmanim::Limudim::Calculators
|
4
|
+
class DafHashavuaBavli < DafYomiBavli
|
5
|
+
def initial_cycle_date
|
6
|
+
jewish_date(Date.parse('2005-03-02'))
|
7
|
+
end
|
8
|
+
|
9
|
+
def cycle_end_calculation
|
10
|
+
->(start_date, iteration){ start_date + ((2711*7) - start_date.day_of_week) } # 2711 pages except first week * 7 days
|
11
|
+
end
|
12
|
+
|
13
|
+
def interval_end_calculation
|
14
|
+
->(cycle, start_date){ start_date + (7 - start_date.day_of_week) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def cycle_units_calculation
|
18
|
+
->(cycle){ default_units }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
@@ -33,12 +33,8 @@ module Zmanim::Limudim::Calculators
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
37
|
-
|
38
|
-
Zmanim::Limudim::Unit.new('no_daf_today')
|
39
|
-
else
|
40
|
-
super
|
41
|
-
end
|
36
|
+
def skip_unit
|
37
|
+
Zmanim::Limudim::Unit.new('no_daf_today')
|
42
38
|
end
|
43
39
|
|
44
40
|
def skip_interval?(interval)
|
@@ -40,7 +40,7 @@ module Zmanim::Limudim::Calculators
|
|
40
40
|
meilah: [4,9,8,6,5,6], tamid: [4,5,9,3,6,4,3], midos: [9,6,8,7,4], kinnim: [4,5,6],
|
41
41
|
keilim: [9,8,8,4,11,4,6,11,8,8,9,8,8,8,6,8,17,9,10,7,3,10,5,17,9,9,12,10,8,4], ohalos: [8,7,7,3,7,7,6,6,16,7,9,8,6,7,10,5,5,10],
|
42
42
|
negaim: [6,5,8,11,5,8,5,10,3,10,12,7,12,13], parah: [4,5,11,4,9,5,12,11,9,6,9,11], taharos: [9,8,8,13,9,10,9,9,9,8],
|
43
|
-
mikvaos: [8,10,4,5,6,11,7,5,7,8], niddah: [7,7,7,7,9,14,5,4,11,8],
|
43
|
+
mikvaos: [8,10,4,5,6,11,7,5,7,8], niddah: [7,7,7,7,9,14,5,4,11,8], machshirin: [6,11,8,10,11,8], zavim: [6,4,3,7,12],
|
44
44
|
tevul_yom: [5,8,6,7], yadayim: [5,4,5,8], uktzin: [6,10,12]
|
45
45
|
}.map{|k, v| [k, Hash[v.map.with_index{|m, p| [p+1, m]}]]}]
|
46
46
|
end
|
@@ -47,40 +47,40 @@ module Zmanim::Limudim::Calculators
|
|
47
47
|
|
48
48
|
def cycle_units_calculation
|
49
49
|
->(cycle) do
|
50
|
-
|
50
|
+
kviah_values = cycle.start_date.kviah.values
|
51
51
|
modifications = in_israel ?
|
52
52
|
{
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
}[
|
53
|
+
[2,:chaseirim,5] => [%i(matos masei), %i(nitzavim vayeilech)],
|
54
|
+
[2,:shelaimim,7] => [],
|
55
|
+
[3,:kesidran,7] => [],
|
56
|
+
[5,:chaseirim,1] => [],
|
57
|
+
[5,:shelaimim,3] => [%i(nitzavim vayeilech)],
|
58
|
+
[7,:chaseirim,3] => [%i(matos masei), %i(nitzavim vayeilech)],
|
59
|
+
[7,:shelaimim,5] => [%i(matos masei), %i(nitzavim vayeilech)],
|
60
|
+
[2,:chaseirim,3] => [%i(vayakheil pikudei), %i(tazria metzora), %i(acharei kedoshim), %i(behar bechukosai), %i(matos masei), %i(nitzavim vayeilech)],
|
61
|
+
[2,:shelaimim,5] => [%i(vayakheil pikudei), %i(tazria metzora), %i(acharei kedoshim), %i(behar bechukosai), %i(matos masei), %i(nitzavim vayeilech)],
|
62
|
+
[3,:kesidran,5] => [%i(vayakheil pikudei), %i(tazria metzora), %i(acharei kedoshim), %i(behar bechukosai), %i(matos masei), %i(nitzavim vayeilech)],
|
63
|
+
[5,:kesidran,7] => [%i(vayakheil pikudei), %i(tazria metzora), %i(acharei kedoshim), %i(matos masei)],
|
64
|
+
[5,:shelaimim,1] => [%i(tazria metzora), %i(acharei kedoshim), %i(behar bechukosai), %i(matos masei)],
|
65
|
+
[7,:chaseirim,1] => [%i(vayakheil pikudei), %i(tazria metzora), %i(acharei kedoshim), %i(behar bechukosai), %i(matos masei)],
|
66
|
+
[7,:shelaimim,3] => [%i(vayakheil pikudei), %i(tazria metzora), %i(acharei kedoshim), %i(behar bechukosai), %i(matos masei)],
|
67
|
+
}[kviah_values] :
|
68
68
|
{
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
}[
|
69
|
+
[2,:chaseirim,5] => [%i(chukas balak), %i(matos masei), %i(nitzavim vayeilech)],
|
70
|
+
[2,:shelaimim,7] => [%i(matos masei)],
|
71
|
+
[3,:kesidran,7] => [%i(matos masei)],
|
72
|
+
[5,:chaseirim,1] => [],
|
73
|
+
[5,:shelaimim,3] => [%i(nitzavim vayeilech)],
|
74
|
+
[7,:chaseirim,3] => [%i(matos masei), %i(nitzavim vayeilech)],
|
75
|
+
[7,:shelaimim,5] => [%i(chukas balak), %i(matos masei), %i(nitzavim vayeilech)],
|
76
|
+
[2,:chaseirim,3] => [%i(vayakheil pikudei), %i(tazria metzora), %i(acharei kedoshim), %i(behar bechukosai), %i(matos masei), %i(nitzavim vayeilech)],
|
77
|
+
[2,:shelaimim,5] => [%i(vayakheil pikudei), %i(tazria metzora), %i(acharei kedoshim), %i(behar bechukosai), %i(chukas balak), %i(matos masei), %i(nitzavim vayeilech)],
|
78
|
+
[3,:kesidran,5] => [%i(vayakheil pikudei), %i(tazria metzora), %i(acharei kedoshim), %i(behar bechukosai), %i(chukas balak), %i(matos masei), %i(nitzavim vayeilech)],
|
79
|
+
[5,:kesidran,7] => [%i(vayakheil pikudei), %i(tazria metzora), %i(acharei kedoshim), %i(behar bechukosai), %i(matos masei)],
|
80
|
+
[5,:shelaimim,1] => [%i(tazria metzora), %i(acharei kedoshim), %i(behar bechukosai), %i(matos masei)],
|
81
|
+
[7,:chaseirim,1] => [%i(vayakheil pikudei), %i(tazria metzora), %i(acharei kedoshim), %i(behar bechukosai), %i(matos masei)],
|
82
|
+
[7,:shelaimim,3] => [%i(vayakheil pikudei), %i(tazria metzora), %i(acharei kedoshim), %i(behar bechukosai), %i(matos masei), %i(nitzavim vayeilech)],
|
83
|
+
}[kviah_values]
|
84
84
|
modifications.inject(default_units) do |transitioned_units, parsha_pair|
|
85
85
|
index = transitioned_units.index(parsha_pair.first)
|
86
86
|
transitioned_units[0...index] + [parsha_pair] + transitioned_units[(index + 2)..-1]
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'zmanim/limudim/limud_calculator'
|
2
|
+
|
3
|
+
module Zmanim::Limudim::Calculators
|
4
|
+
class PirkeiAvos
|
5
|
+
include Zmanim::Limudim::LimudCalculator
|
6
|
+
|
7
|
+
attr_reader :in_israel
|
8
|
+
|
9
|
+
def initialize(in_israel:false)
|
10
|
+
@in_israel = in_israel
|
11
|
+
end
|
12
|
+
|
13
|
+
def tiered_units?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def perpetual_cycle_anchor
|
18
|
+
Zmanim::Limudim::Anchor::DayOfYearAnchor.new(1, in_israel ? 22 : 23) # Day after Pesach
|
19
|
+
end
|
20
|
+
|
21
|
+
def default_units
|
22
|
+
@default_units ||= (1..6).to_a * 4 # 4 sub-cycles of 6 perakim, with the last sub-cycle being compressed as needed
|
23
|
+
end
|
24
|
+
|
25
|
+
def cycle_end_calculation
|
26
|
+
->(start_date, _iteration) do
|
27
|
+
rosh_hashana = Zmanim::HebrewCalendar::JewishDate.new(start_date.jewish_year + 1, 7, 1)
|
28
|
+
rosh_hashana - rosh_hashana.day_of_week # last Shabbos before Rosh Hashanah
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def interval_end_calculation
|
33
|
+
->(cycle, start_date) do
|
34
|
+
start_date + (7 - start_date.day_of_week)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def skip_interval?(interval)
|
39
|
+
!in_israel && [interval.end_date.jewish_month, interval.end_date.jewish_day] == [3,7]
|
40
|
+
end
|
41
|
+
|
42
|
+
def cycle_units_calculation
|
43
|
+
->(cycle) do
|
44
|
+
cycle_weeks = ((cycle.end_date - cycle.start_date + 1) / 7.0).ceil
|
45
|
+
# If the cycle starts on a Friday, outside of israel the 2nd day of Shavuos will fall on Shabbos
|
46
|
+
# and we lose one week in the pirkei avos cycle
|
47
|
+
cycle_weeks -=1 if !in_israel && cycle.start_date.day_of_week == 6
|
48
|
+
unit_count = default_units.length
|
49
|
+
compress_weeks = (unit_count - cycle_weeks) * 2
|
50
|
+
default_units.first(unit_count - compress_weeks) + default_units.last(compress_weeks).each_slice(2).to_a
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/zmanim/limudim/cycle.rb
CHANGED
@@ -32,9 +32,5 @@ module Zmanim::Limudim
|
|
32
32
|
new_end_date = cycle_end_calculation.(new_start_date, new_iteration)
|
33
33
|
Cycle.new(new_start_date, new_end_date, new_iteration)
|
34
34
|
end
|
35
|
-
|
36
|
-
def first_interval(interval_end_calculation)
|
37
|
-
Interval.first_for_cycle(self, interval_end_calculation)
|
38
|
-
end
|
39
35
|
end
|
40
36
|
end
|
data/lib/zmanim/limudim/limud.rb
CHANGED
@@ -5,14 +5,15 @@ module Zmanim::Limudim
|
|
5
5
|
def limud(date)
|
6
6
|
jewish_date = jewish_date(date)
|
7
7
|
cycle = find_cycle(jewish_date)
|
8
|
-
return nil unless cycle
|
8
|
+
return nil unless cycle && cycle.end_date >= date
|
9
9
|
units = cycle_units_calculation.(cycle)
|
10
|
-
interval =
|
10
|
+
interval = Interval.first_for_cycle(cycle, interval_end_calculation)
|
11
11
|
while !jewish_date.between?(interval.start_date, interval.end_date) do
|
12
|
-
interval = interval
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
interval = if skip_interval?(interval)
|
13
|
+
interval.skip(interval_end_calculation)
|
14
|
+
else
|
15
|
+
interval.next(interval_end_calculation)
|
16
|
+
end
|
16
17
|
end
|
17
18
|
unit = unit_for_interval(units, interval)
|
18
19
|
Zmanim::Limudim::Limud.new(interval, unit)
|
@@ -79,10 +80,15 @@ module Zmanim::Limudim
|
|
79
80
|
end
|
80
81
|
|
81
82
|
def unit_for_interval(units, interval)
|
83
|
+
return skip_unit if skip_interval?(interval)
|
82
84
|
return tiered_units_for_interval(units, interval) if tiered_units?
|
83
85
|
Unit.new(*units[interval.iteration-1])
|
84
86
|
end
|
85
87
|
|
88
|
+
def skip_unit
|
89
|
+
nil
|
90
|
+
end
|
91
|
+
|
86
92
|
def skip_interval?(interval)
|
87
93
|
false
|
88
94
|
end
|
@@ -1,4 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
+
require 'zmanim/util/text_helper'
|
3
|
+
require 'zmanim/util/hebrew_numeric_formatter'
|
4
|
+
|
2
5
|
module Zmanim::Limudim
|
3
6
|
class LimudimFormatter
|
4
7
|
include Zmanim::Util::TextHelper
|
@@ -70,7 +73,7 @@ module Zmanim::Limudim
|
|
70
73
|
sheviis: 'שביעית',
|
71
74
|
terumos: 'תרומות',
|
72
75
|
maasros: 'מעשרות',
|
73
|
-
maaser_sheni: '
|
76
|
+
maaser_sheni: 'מעשר שני',
|
74
77
|
chalah: 'חלה',
|
75
78
|
orlah: 'ערלה',
|
76
79
|
bikurim: 'בכורים',
|
@@ -121,7 +124,7 @@ module Zmanim::Limudim
|
|
121
124
|
taharos: 'טהרות',
|
122
125
|
mikvaos: 'מקואות',
|
123
126
|
niddah: 'נדה',
|
124
|
-
|
127
|
+
machshirin: 'מכשירין',
|
125
128
|
zavim: 'זבים',
|
126
129
|
tevul_yom: 'טבול יום',
|
127
130
|
yadayim: 'ידים',
|
@@ -135,6 +138,7 @@ module Zmanim::Limudim
|
|
135
138
|
end
|
136
139
|
|
137
140
|
def format_parsha(limud)
|
141
|
+
return '' unless limud && limud.unit
|
138
142
|
prefix = hebrew_format ? 'פרשת ' : 'Parshas '
|
139
143
|
prefix + limud.unit.render do |parsha|
|
140
144
|
hebrew_format ? PARSHIYOS[parsha] : titleize(parsha)
|
@@ -159,6 +163,12 @@ module Zmanim::Limudim
|
|
159
163
|
prefix + limud.unit.render {|e| format_number(e) }
|
160
164
|
end
|
161
165
|
|
166
|
+
def format_avos(limud)
|
167
|
+
return '' unless unit = (limud && limud.unit)
|
168
|
+
prefix = hebrew_format ? 'פרקי אבות ' : 'Pirkei Avos '
|
169
|
+
prefix + unit.render {|e| format_number(e) }
|
170
|
+
end
|
171
|
+
|
162
172
|
private
|
163
173
|
|
164
174
|
def format_number(number)
|
data/lib/zmanim/version.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
require_relative 'astronomical_calendar'
|
2
|
+
require_relative 'hebrew_calendar/jewish_calendar'
|
3
|
+
|
1
4
|
module Zmanim
|
2
5
|
class ZmanimCalendar < AstronomicalCalendar
|
3
6
|
attr_accessor :candle_lighting_offset
|
7
|
+
attr_writer :use_elevation
|
4
8
|
|
5
9
|
ZENITH_16_POINT_1 = GEOMETRIC_ZENITH + 16.1
|
6
10
|
ZENITH_8_POINT_5 = GEOMETRIC_ZENITH + 8.5
|
@@ -8,11 +12,31 @@ module Zmanim
|
|
8
12
|
def initialize(opts={})
|
9
13
|
super
|
10
14
|
@candle_lighting_offset = opts[:candle_lighting_offset] || 18
|
15
|
+
@use_elevation = false
|
16
|
+
end
|
17
|
+
|
18
|
+
def use_elevation?
|
19
|
+
!!@use_elevation
|
20
|
+
end
|
21
|
+
|
22
|
+
def elevation_adjusted_sunrise
|
23
|
+
use_elevation? ? sunrise : sea_level_sunrise
|
24
|
+
end
|
25
|
+
alias_method :hanetz, :elevation_adjusted_sunrise
|
26
|
+
|
27
|
+
def elevation_adjusted_sunset
|
28
|
+
use_elevation? ? sunset : sea_level_sunset
|
11
29
|
end
|
30
|
+
alias_method :shkia, :elevation_adjusted_sunset
|
12
31
|
|
13
32
|
def tzais(opts={degrees: 8.5})
|
14
|
-
degrees, offset = extract_degrees_offset(opts)
|
15
|
-
|
33
|
+
degrees, offset, zmanis_offset = extract_degrees_offset(opts)
|
34
|
+
sunset_for_degrees = degrees == 0 ? elevation_adjusted_sunset : sunset_offset_by_degrees(GEOMETRIC_ZENITH + degrees)
|
35
|
+
if zmanis_offset != 0
|
36
|
+
offset_by_minutes_zmanis(sunset_for_degrees, zmanis_offset)
|
37
|
+
else
|
38
|
+
offset_by_minutes(sunset_for_degrees, offset)
|
39
|
+
end
|
16
40
|
end
|
17
41
|
|
18
42
|
def tzais_72
|
@@ -20,12 +44,17 @@ module Zmanim
|
|
20
44
|
end
|
21
45
|
|
22
46
|
def alos(opts={degrees: 16.1})
|
23
|
-
degrees, offset = extract_degrees_offset(opts)
|
24
|
-
|
47
|
+
degrees, offset, zmanis_offset = extract_degrees_offset(opts)
|
48
|
+
sunrise_for_degrees = degrees == 0 ? elevation_adjusted_sunrise : sunrise_offset_by_degrees(GEOMETRIC_ZENITH + degrees)
|
49
|
+
if zmanis_offset != 0
|
50
|
+
offset_by_minutes_zmanis(sunrise_for_degrees, -zmanis_offset)
|
51
|
+
else
|
52
|
+
offset_by_minutes(sunrise_for_degrees, -offset)
|
53
|
+
end
|
25
54
|
end
|
26
55
|
|
27
56
|
def alos_72
|
28
|
-
alos(offset:
|
57
|
+
alos(offset: 72)
|
29
58
|
end
|
30
59
|
|
31
60
|
alias_method :chatzos, :sun_transit
|
@@ -35,7 +64,7 @@ module Zmanim
|
|
35
64
|
end
|
36
65
|
|
37
66
|
def sof_zman_shma_gra
|
38
|
-
sof_zman_shma(
|
67
|
+
sof_zman_shma(elevation_adjusted_sunrise, elevation_adjusted_sunset)
|
39
68
|
end
|
40
69
|
|
41
70
|
def sof_zman_shma_mga
|
@@ -51,22 +80,22 @@ module Zmanim
|
|
51
80
|
end
|
52
81
|
|
53
82
|
def sof_zman_tfila_gra
|
54
|
-
sof_zman_tfila(
|
83
|
+
sof_zman_tfila(elevation_adjusted_sunrise, elevation_adjusted_sunset)
|
55
84
|
end
|
56
85
|
|
57
86
|
def sof_zman_tfila_mga
|
58
87
|
sof_zman_tfila(alos_72, tzais_72)
|
59
88
|
end
|
60
89
|
|
61
|
-
def mincha_gedola(day_start=
|
90
|
+
def mincha_gedola(day_start=elevation_adjusted_sunrise, day_end=elevation_adjusted_sunset)
|
62
91
|
shaos_into_day(day_start, day_end, 6.5)
|
63
92
|
end
|
64
93
|
|
65
|
-
def mincha_ketana(day_start=
|
94
|
+
def mincha_ketana(day_start=elevation_adjusted_sunrise, day_end=elevation_adjusted_sunset)
|
66
95
|
shaos_into_day(day_start, day_end, 9.5)
|
67
96
|
end
|
68
97
|
|
69
|
-
def plag_hamincha(day_start=
|
98
|
+
def plag_hamincha(day_start=elevation_adjusted_sunrise, day_end=elevation_adjusted_sunset)
|
70
99
|
shaos_into_day(day_start, day_end, 10.75)
|
71
100
|
end
|
72
101
|
|
@@ -75,7 +104,7 @@ module Zmanim
|
|
75
104
|
end
|
76
105
|
|
77
106
|
def shaah_zmanis_gra
|
78
|
-
shaah_zmanis(
|
107
|
+
shaah_zmanis(elevation_adjusted_sunrise, elevation_adjusted_sunset)
|
79
108
|
end
|
80
109
|
|
81
110
|
def shaah_zmanis_mga
|
@@ -84,7 +113,15 @@ module Zmanim
|
|
84
113
|
|
85
114
|
def shaah_zmanis_by_degrees_and_offset(degrees, offset)
|
86
115
|
opts = {degrees: degrees, offset: offset}
|
87
|
-
shaah_zmanis(alos(opts
|
116
|
+
shaah_zmanis(alos(opts), tzais(opts))
|
117
|
+
end
|
118
|
+
|
119
|
+
def assur_bemelacha?(current_time, tzais: tzais(), in_israel: false)
|
120
|
+
tzais_time = tzais.is_a?(Hash) ? self.tzais(tzais) : tzais
|
121
|
+
jewish_calendar = HebrewCalendar::JewishCalendar.new(current_time.to_date)
|
122
|
+
jewish_calendar.in_israel = in_israel
|
123
|
+
(current_time.to_datetime <= tzais_time && jewish_calendar.assur_bemelacha?) ||
|
124
|
+
(current_time.to_datetime >= elevation_adjusted_sunset && jewish_calendar.tomorrow_assur_bemelacha?)
|
88
125
|
end
|
89
126
|
|
90
127
|
private
|
@@ -95,12 +132,18 @@ module Zmanim
|
|
95
132
|
end
|
96
133
|
|
97
134
|
def extract_degrees_offset(opts)
|
98
|
-
[opts[:degrees] || 0.0, opts[:offset] || 0]
|
135
|
+
[opts[:degrees] || 0.0, opts[:offset] || 0, opts[:zmanis_offset] || 0]
|
99
136
|
end
|
100
137
|
|
101
138
|
def offset_by_minutes(time, minutes)
|
102
139
|
return unless time
|
103
140
|
time + (minutes / (60 * 24).to_f)
|
104
141
|
end
|
142
|
+
|
143
|
+
def offset_by_minutes_zmanis(time, minutes)
|
144
|
+
return unless time
|
145
|
+
shaah_zmanis_skew = shaah_zmanis_gra / HOUR_MILLIS
|
146
|
+
time + (minutes * shaah_zmanis_skew / (60 * 24).to_f)
|
147
|
+
end
|
105
148
|
end
|
106
149
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zmanim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pinny Markowitz
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzinfo
|
@@ -90,6 +90,7 @@ extra_rdoc_files: []
|
|
90
90
|
files:
|
91
91
|
- ".gitignore"
|
92
92
|
- ".rspec"
|
93
|
+
- CHANGELOG.md
|
93
94
|
- Gemfile
|
94
95
|
- LICENSE
|
95
96
|
- README.md
|
@@ -104,10 +105,12 @@ files:
|
|
104
105
|
- lib/zmanim/limudim/anchor/day_of_month_anchor.rb
|
105
106
|
- lib/zmanim/limudim/anchor/day_of_week_anchor.rb
|
106
107
|
- lib/zmanim/limudim/anchor/day_of_year_anchor.rb
|
108
|
+
- lib/zmanim/limudim/calculators/daf_hashavua_bavli.rb
|
107
109
|
- lib/zmanim/limudim/calculators/daf_yomi_bavli.rb
|
108
110
|
- lib/zmanim/limudim/calculators/daf_yomi_yerushalmi.rb
|
109
111
|
- lib/zmanim/limudim/calculators/mishna_yomis.rb
|
110
112
|
- lib/zmanim/limudim/calculators/parsha.rb
|
113
|
+
- lib/zmanim/limudim/calculators/pirkei_avos.rb
|
111
114
|
- lib/zmanim/limudim/calculators/tehillim_monthly.rb
|
112
115
|
- lib/zmanim/limudim/cycle.rb
|
113
116
|
- lib/zmanim/limudim/interval.rb
|
@@ -130,7 +133,7 @@ homepage: https://github.com/pinnymz/ruby-zmanim
|
|
130
133
|
licenses: []
|
131
134
|
metadata:
|
132
135
|
allowed_push_host: https://rubygems.org
|
133
|
-
post_install_message:
|
136
|
+
post_install_message:
|
134
137
|
rdoc_options: []
|
135
138
|
require_paths:
|
136
139
|
- lib
|
@@ -145,9 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
148
|
- !ruby/object:Gem::Version
|
146
149
|
version: '0'
|
147
150
|
requirements: []
|
148
|
-
|
149
|
-
|
150
|
-
signing_key:
|
151
|
+
rubygems_version: 3.1.4
|
152
|
+
signing_key:
|
151
153
|
specification_version: 4
|
152
154
|
summary: A Zmanim library for Ruby
|
153
155
|
test_files: []
|