zmanim 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60f1ce1f598d2bb45067fadbb609dca84e62e94da2144d6815c04a14083eeeb9
4
- data.tar.gz: e83e26224f23d21216258f3e31ad65bafc18af91f250c09ab9e0a5941061aa34
3
+ metadata.gz: 106a751ffa4c28d37a4d69afc2d8aa91d8f07b668dc126f6008fec90c3a0b308
4
+ data.tar.gz: 8886864f89feb9382a62644de99201c4b0958ff2d8652728fad14ed1c6420df9
5
5
  SHA512:
6
- metadata.gz: '0868fb13463bc643a818c5faa9aad148659ea8597eceadbafbc4a544d8cc88f7b8ec069361939f860eb6c76c4c07b70f7e0100ab3b4e4ff2e19a73fb2dec9908'
7
- data.tar.gz: 946ccd345d2fcb4612ff4b2b2782de1c78a822e97fd70b12b4c48569c51d98907aeb05dd9b97894fa0cc4a9397167e5af75e53492e625c9b2f425282ae9d8e08
6
+ metadata.gz: 971b9186fae5a3eccba8730038b9df6f2e5566d57fac6626dbbcba60ae87ec472eb73a2d72536f9dfbeee473cdd857c68f3c296a25dfad8feb65874f790a04ad
7
+ data.tar.gz: c73d548258fc576a7afaff89025a9c0b7105551e679284d0a291f03bbc91945b5f701bac5236eb6c882fba857ef185944fa879f813d069d11666c654c5f9142f
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
data/CHANGELOG.md CHANGED
@@ -4,6 +4,35 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.5.0] - 2022-03-24
8
+ ### Added
9
+ - `JewishCalendar#taanis_bechorim?` detects Taanis Bechorim for a given date
10
+ - `JewishCalendar#pesach` returns the date for start of Pesach for any year, or the next upcoming event
11
+ - `JewishCalendar#pesach_sheni` returns the date for Pesach Sheni for any year, or the next upcoming event
12
+ - `JewishCalendar#lag_baomer` returns the date for Lag Baomer for any year, or the next upcoming event
13
+ - `JewishCalendar#shavuos` returns the date for start of Shavuos for any year, or the next upcoming event
14
+ - `JewishCalendar#seventeen_of_tammuz` returns the date for Seventeen of Tammuz for any year, or the next upcoming event
15
+ - `JewishCalendar#tisha_beav` returns the date for Tisha Beav for any year, or the next upcoming event
16
+ - `JewishCalendar#tu_beav` returns the date for Tu Beav for any year, or the next upcoming event
17
+ - `JewishCalendar#rosh_hashana` returns the date for start of Rosh Hashana for any year, or the next upcoming event
18
+ - `JewishCalendar#tzom_gedalyah` returns the date for Tzom Gedalyah for any year, or the next upcoming event
19
+ - `JewishCalendar#yom_kippur` returns the date for Yom Kippur for any year, or the next upcoming event
20
+ - `JewishCalendar#succos` returns the date for start of Succos for any year, or the next upcoming event
21
+ - `JewishCalendar#chanukah` returns the date for start of Chanukah for any year, or the next upcoming event
22
+ - `JewishCalendar#tenth_of_teves` returns the date for Tenth of Teves for any year, or the next upcoming event
23
+ - `JewishCalendar#tu_beshvat` returns the date for Tu Beshvat for any year, or the next upcoming event
24
+ - `JewishCalendar#purim` returns the date for Purim for any year, or the next upcoming event
25
+ - `JewishCalendar#rosh_chodesh` returns the date for Rosh Chodesh for any month, or the next upcoming event
26
+ - `JewishCalendar#shabbos_mevorchim` returns the date for Shabbos Mevorchim for any month, or the next upcoming event
27
+ - `JewishCalendar#vesein_tal_umatar_start` returns the date for start of reciting Vesein Tal Umatar for any year, or the next upcoming event
28
+ - `JewishCalendar#vesein_tal_umatar_starts?` detects if reciting of Vesein Tal Umatar started today
29
+ ### Changed
30
+ - Upgraded dependency versions to address known security vulnerabilities:
31
+ - `rake` to 13.0.6
32
+ - `bundler` to 2.3.10
33
+ ### Fixed
34
+ - `JewishCalendar#vesein_tal_umatar?` and `JewishCalendar#vesein_tal_umatar_starts_tonight?` now auto-adjust for any calendar year, previously only valid for 20th/21st century
35
+
7
36
  ## [0.4.0] - 2020-10-13
8
37
  ### Added
9
38
  - `JewishCalendar#end_of_week` returns Shabbos for this week
data/Gemfile.lock ADDED
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ zmanim (0.5.0)
5
+ tzinfo
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ byebug (9.1.0)
11
+ concurrent-ruby (1.1.10)
12
+ diff-lcs (1.5.0)
13
+ rake (13.0.6)
14
+ rspec (3.11.0)
15
+ rspec-core (~> 3.11.0)
16
+ rspec-expectations (~> 3.11.0)
17
+ rspec-mocks (~> 3.11.0)
18
+ rspec-core (3.11.0)
19
+ rspec-support (~> 3.11.0)
20
+ rspec-expectations (3.11.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.11.0)
23
+ rspec-mocks (3.11.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.11.0)
26
+ rspec-support (3.11.0)
27
+ tzinfo (2.0.4)
28
+ concurrent-ruby (~> 1.0)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ bundler (~> 2.3)
35
+ byebug (~> 9.1)
36
+ rake (~> 13.0)
37
+ rspec (~> 3.7)
38
+ zmanim!
39
+
40
+ BUNDLED WITH
41
+ 2.3.10
@@ -84,6 +84,11 @@ module Zmanim::HebrewCalendar
84
84
  %i(seventeen_of_tammuz tisha_beav tzom_gedalyah yom_kippur tenth_of_teves taanis_esther).include?(significant_day)
85
85
  end
86
86
 
87
+ def taanis_bechorim?
88
+ (day_of_week != 7 && jewish_day == 14 && jewish_month == 1) || # normally 14th of nissan,
89
+ (day_of_week == 5 && jewish_day == 12 && jewish_month == 1) # when that falls on shabbos, moved to previous Thursday
90
+ end
91
+
87
92
  def rosh_chodesh?
88
93
  jewish_day == 30 || (jewish_day == 1 && jewish_month != 7)
89
94
  end
@@ -231,6 +236,138 @@ module Zmanim::HebrewCalendar
231
236
  end
232
237
  end
233
238
 
239
+ def pesach(upcoming: nil, year: nil)
240
+ find_annual_event(upcoming, year) do |y|
241
+ JewishCalendar.new(y, 1, 15)
242
+ end
243
+ end
244
+
245
+ def pesach_sheni(upcoming: nil, year: nil)
246
+ find_annual_event(upcoming, year) do |y|
247
+ JewishCalendar.new(y, 2, 14)
248
+ end
249
+ end
250
+
251
+ def lag_baomer(upcoming: nil, year: nil)
252
+ find_annual_event(upcoming, year) do |y|
253
+ JewishCalendar.new(y, 2, 18)
254
+ end
255
+ end
256
+
257
+ def shavuos(upcoming: nil, year: nil)
258
+ find_annual_event(upcoming, year) do |y|
259
+ JewishCalendar.new(y, 3, 6)
260
+ end
261
+ end
262
+
263
+ def seventeen_of_tammuz(upcoming: nil, year: nil)
264
+ find_annual_event(upcoming, year) do |y|
265
+ date = JewishCalendar.new(y, 4, 17)
266
+ date.forward! if date.day_of_week == 7
267
+ date
268
+ end
269
+ end
270
+
271
+ def tisha_beav(upcoming: nil, year: nil)
272
+ find_annual_event(upcoming, year) do |y|
273
+ date = JewishCalendar.new(y, 5, 9)
274
+ date.forward! if date.day_of_week == 7
275
+ date
276
+ end
277
+ end
278
+
279
+ def tu_beav(upcoming: nil, year: nil)
280
+ find_annual_event(upcoming, year) do |y|
281
+ JewishCalendar.new(y, 5, 15)
282
+ end
283
+ end
284
+
285
+ def rosh_hashana(upcoming: nil, year: nil)
286
+ find_annual_event(upcoming, year) do |y|
287
+ JewishCalendar.new(y, 7, 1)
288
+ end
289
+ end
290
+
291
+ def tzom_gedalyah(upcoming: nil, year: nil)
292
+ find_annual_event(upcoming, year) do |y|
293
+ date = JewishCalendar.new(y, 7, 3)
294
+ date.forward! if date.day_of_week == 7
295
+ date
296
+ end
297
+ end
298
+
299
+ def yom_kippur(upcoming: nil, year: nil)
300
+ find_annual_event(upcoming, year) do |y|
301
+ JewishCalendar.new(y, 7, 10)
302
+ end
303
+ end
304
+
305
+ def succos(upcoming: nil, year: nil)
306
+ find_annual_event(upcoming, year) do |y|
307
+ JewishCalendar.new(y, 7, 15)
308
+ end
309
+ end
310
+
311
+ def chanukah(upcoming: nil, year: nil)
312
+ find_annual_event(upcoming, year) do |y|
313
+ JewishCalendar.new(y, 9, 25)
314
+ end
315
+ end
316
+
317
+ def tenth_of_teves(upcoming: nil, year: nil)
318
+ find_annual_event(upcoming, year) do |y|
319
+ JewishCalendar.new(y, 10, 10)
320
+ end
321
+ end
322
+
323
+ def tu_beshvat(upcoming: nil, year: nil)
324
+ find_annual_event(upcoming, year) do |y|
325
+ JewishCalendar.new(y, 11, 15)
326
+ end
327
+ end
328
+
329
+ def purim(upcoming: nil, year: nil)
330
+ find_annual_event(upcoming, year) do |y|
331
+ JewishCalendar.new(y, months_in_jewish_year(y), 14)
332
+ end
333
+ end
334
+
335
+ def rosh_chodesh(upcoming: nil, month: nil, year: nil)
336
+ find_monthly_event(upcoming, month, year) do |m, y|
337
+ m = 8 if m == 7
338
+ prev = m - 1
339
+ prev = months_in_jewish_year(y) if prev < 1
340
+ if days_in_jewish_month(prev,y) == 30
341
+ JewishCalendar.new(y, prev, 30)
342
+ else
343
+ JewishCalendar.new(y, m, 1)
344
+ end
345
+ end
346
+ end
347
+
348
+ def shabbos_mevorchim(upcoming: nil, month: nil, year: nil)
349
+ find_monthly_event(upcoming, month, year) do |m, y|
350
+ m = 8 if m == 7
351
+ prev = m - 1
352
+ prev = months_in_jewish_year(y) if prev < 1
353
+ mevorchim_start = JewishCalendar.new(y,prev,23)
354
+ mevorchim_start + (7 - mevorchim_start.day_of_week)
355
+ end
356
+ end
357
+
358
+ def vesein_tal_umatar_start(upcoming: nil, year: nil)
359
+ find_annual_event(upcoming, year) do |y|
360
+ start_date =
361
+ if in_israel
362
+ JewishCalendar.new(y, 8, 7)
363
+ else
364
+ JewishCalendar.new(y, 7, 1) + (47 - tekufas_tishrei_elapsed_days(1, year: y))
365
+ end
366
+ start_date.forward! if start_date.day_of_week == 7
367
+ start_date
368
+ end
369
+ end
370
+
234
371
  def shabbos_mevorchim?
235
372
  day_of_week == 7 &&
236
373
  jewish_month != 6 &&
@@ -255,24 +392,33 @@ module Zmanim::HebrewCalendar
255
392
  !mashiv_haruach? || mashiv_haruach_starts? || mashiv_haruach_ends?
256
393
  end
257
394
 
258
- # This presumes the evenings of December 4/5 are always the initial start date outside of Israel
259
- # Because the jewish date does not auto-increment in the evening, we use December 5/6 as the start date
395
+ # Because the jewish date does not auto-increment in the evening,
396
+ # we use the daytime transition (e.g. December 5/6 for 20th/21st century) as the start date
260
397
  # and rely on the user to increment the jewish date after nightfall.
261
- # Note that according to many, the date for Vesein Tal Umatar is tied to the Julian calendar and has historically
262
- # moved over time as the deviance from the Gregorian calendar increases. The date of December 4/5 is to be used
263
- # for the 20th and 21st century.
264
398
  def vesein_tal_umatar?
265
399
  return false if day_of_week == 7 || yom_tov_assur_bemelacha?
266
- start_date = gregorian_vesein_tal_umatar_start
267
- end_date = JewishDate.new(jewish_year, 1, 15)
268
- self.between?(start_date, end_date)
400
+ return true if jewish_month == 1 && jewish_day < 15
401
+ return false if jewish_month < 8
402
+ if in_israel
403
+ jewish_month > 8 || (jewish_month == 8 && jewish_day >= 7)
404
+ else
405
+ tekufas_tishrei_elapsed_days >= 47
406
+ end
407
+ end
408
+
409
+ def vesein_tal_umatar_starts?
410
+ if in_israel
411
+ # 7 Cheshvan, or 8 Cheshvan if 7 is Shabbos
412
+ return false unless jewish_month == 8
413
+ (day_of_week != 7 && jewish_day == 7) || (day_of_week == 1 && jewish_day == 8)
414
+ else
415
+ elapsed_days = tekufas_tishrei_elapsed_days
416
+ (day_of_week != 7 && elapsed_days == 47) || (day_of_week == 1 && elapsed_days == 48)
417
+ end
269
418
  end
270
419
 
271
420
  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)
421
+ succ.vesein_tal_umatar_starts?
276
422
  end
277
423
 
278
424
  def vesein_beracha?
@@ -445,12 +591,53 @@ module Zmanim::HebrewCalendar
445
591
  end
446
592
  end
447
593
 
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)
594
+ def tekufas_tishrei_elapsed_days(day_number=day_number_of_jewish_year, year: jewish_year)
595
+ days = jewish_calendar_elapsed_days(year) + (day_number-1) + 0.5
596
+ solar = (year - 1) * 365.25
597
+ (days - solar).floor.to_i
598
+ end
599
+
600
+ # Finds the date for an annual event whose rules are provided to the method as a block
601
+ # Supports boolean `upcoming` or a given integer jewish `year`.
602
+ # If both are nil, defaults to current jewish year.
603
+ # `upcoming` finds the current or next occurrence of this event
604
+ def find_annual_event(upcoming, year)
605
+ if upcoming && year
606
+ raise "'upcoming' and 'year' options cannot be used together"
452
607
  end
453
- start_date
608
+
609
+ upcoming = false if upcoming.nil? # 'upcoming' only when explicitly passed
610
+ year = jewish_year if year.nil?
611
+
612
+ current = yield(year)
613
+ upcoming && current < self ? yield(year+1) : current
454
614
  end
615
+
616
+ # Finds the date for a monthly event whose rules are provided to the method as a block
617
+ # Supports boolean `upcoming` or a given integer jewish `year` and `month`.
618
+ # If all are nil, defaults to current jewish month and year.
619
+ # `upcoming` finds the current or next occurrence of this event
620
+ # If only month is provided, defaults to current jewish year.
621
+ # If only year is provided, defaults to current jewish month.
622
+ def find_monthly_event(upcoming, month, year)
623
+ if upcoming && (year || month)
624
+ raise "'upcoming' option cannot be used together with 'year' or 'month'"
625
+ end
626
+
627
+ upcoming = false if upcoming.nil? # 'upcoming' only when explicitly passed
628
+ year ||= jewish_year
629
+ month ||= jewish_month
630
+
631
+ current = yield(month, year)
632
+ if upcoming && current < self
633
+ month += 1
634
+ month = 1 if month > months_in_jewish_year(year)
635
+ year += 1 if month == 7
636
+ yield(month, year)
637
+ else
638
+ current
639
+ end
640
+ end
641
+
455
642
  end
456
643
  end
@@ -1,3 +1,3 @@
1
1
  module Zmanim
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/zmanim.gemspec CHANGED
@@ -30,8 +30,8 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ["lib"]
31
31
 
32
32
  spec.add_runtime_dependency "tzinfo"
33
- spec.add_development_dependency "bundler", "~> 1.15"
34
- spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "bundler", "~> 2.3"
34
+ spec.add_development_dependency "rake", "~> 13.0"
35
35
  spec.add_development_dependency "rspec", "~> 3.7"
36
36
  spec.add_development_dependency "byebug", "~> 9.1"
37
37
  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.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pinny Markowitz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-14 00:00:00.000000000 Z
11
+ date: 2022-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.15'
33
+ version: '2.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.15'
40
+ version: '2.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -92,6 +92,7 @@ files:
92
92
  - ".rspec"
93
93
  - CHANGELOG.md
94
94
  - Gemfile
95
+ - Gemfile.lock
95
96
  - LICENSE
96
97
  - README.md
97
98
  - Rakefile