zmanim 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca99f24408a8ee9ef58732e6d92aa20150ec680b
4
- data.tar.gz: eb8a70763999f4f75e72baa42f31fca8e702e1a1
3
+ metadata.gz: 34f16334bc5be809d6cfb0cfd526c90256d5eb34
4
+ data.tar.gz: 6e94981da77ece13e27c9bca543b272da20a0d54
5
5
  SHA512:
6
- metadata.gz: '038a38a4022840534376573885d933b14d36693b995b0676cd2489ca9ce413ab7fced22635ba82a6cffda49e551d5a350963261f4536c5e916e8321a30f064f9'
7
- data.tar.gz: db91a82beb8aab922ef8c055545397b04e6c07bb53e70430939843206cb7baef1c318c4f7ec71dd448ceb2ea6d430137f8ed5974cae68604b0312753118dab61
6
+ metadata.gz: 49f97be4628c3b48d1fecbce00a8d14b47e89d0f8950dfd84412c6e3ba172ed398f8ed30b8a8bd3ec28862750fc70d63dae8e571ec563a00fe517cf3d617288f
7
+ data.tar.gz: e4013fada5d08005b6e4206844d43df41dfba2b062e7d1a2e70819b48fc0552d9cec419e84b0ac3c8c8fe634f065f06f25be70ae1a78c5cd470f4b186435a502
@@ -4,6 +4,16 @@ 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.3.0] - 2018-09-17
8
+ ### Added
9
+ - Elevations used in shaos zmanios calculations if use_elevation property is set
10
+ - Hanetz and Shkia methods will use the appropriate calculation based on use_elevation setting
11
+ - Support Alos and Tzais offset using temporal minutes
12
+ - Various Assur Bemelacha related methods for calendar dates using JewishCalendar,
13
+ as well as point-in-time using ZmanimCalendar.
14
+ - Methods to determine Shabbos Mevorchim, first night of Vesein Tal Umatar,
15
+ and delayed candle lighting
16
+
7
17
  ## [0.2.2] - 2018-08-31
8
18
  ### Fixed
9
19
  - Typo in formatted Masechtos
@@ -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
@@ -191,6 +221,12 @@ module Zmanim::HebrewCalendar
191
221
  end
192
222
  end
193
223
 
224
+ def shabbos_mevorchim?
225
+ day_of_week == 7 &&
226
+ jewish_month != 6 &&
227
+ (23..29).include?(jewish_day)
228
+ end
229
+
194
230
  def mashiv_haruach_starts?
195
231
  jewish_month == 7 && jewish_day == 22
196
232
  end
@@ -217,12 +253,18 @@ module Zmanim::HebrewCalendar
217
253
  # for the 20th and 21st century.
218
254
  def vesein_tal_umatar?
219
255
  return false if day_of_week == 7 || yom_tov_assur_bemelacha?
220
- start_date = JewishDate.new(jewish_year, 8, 7)
221
- start_date.set_gregorian_date(start_date.gregorian_year, 12, gregorian_leap_year?(start_date.gregorian_year+1) ? 6 : 5) unless in_israel
256
+ start_date = gregorian_vesein_tal_umatar_start
222
257
  end_date = JewishDate.new(jewish_year, 1, 15)
223
258
  self.between?(start_date, end_date)
224
259
  end
225
260
 
261
+ def vesein_tal_umatar_starts_tonight?
262
+ return false if day_of_week == 6
263
+ start_date = gregorian_vesein_tal_umatar_start
264
+ (day_of_week == 7 && self == start_date) ||
265
+ self == (start_date - 1)
266
+ end
267
+
226
268
  def vesein_beracha?
227
269
  return false if day_of_week == 7 || yom_tov_assur_bemelacha?
228
270
  !vesein_tal_umatar?
@@ -390,5 +432,13 @@ module Zmanim::HebrewCalendar
390
432
  :shushan_purim
391
433
  end
392
434
  end
435
+
436
+ def gregorian_vesein_tal_umatar_start
437
+ start_date = JewishDate.new(jewish_year, 8, 7)
438
+ unless in_israel
439
+ start_date.set_gregorian_date(start_date.gregorian_year, 12, gregorian_leap_year?(start_date.gregorian_year + 1) ? 6 : 5)
440
+ end
441
+ start_date
442
+ end
393
443
  end
394
444
  end
@@ -1,3 +1,3 @@
1
1
  module Zmanim
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,8 +1,10 @@
1
1
  require_relative 'astronomical_calendar'
2
+ require_relative 'hebrew_calendar/jewish_calendar'
2
3
 
3
4
  module Zmanim
4
5
  class ZmanimCalendar < AstronomicalCalendar
5
6
  attr_accessor :candle_lighting_offset
7
+ attr_writer :use_elevation
6
8
 
7
9
  ZENITH_16_POINT_1 = GEOMETRIC_ZENITH + 16.1
8
10
  ZENITH_8_POINT_5 = GEOMETRIC_ZENITH + 8.5
@@ -10,11 +12,31 @@ module Zmanim
10
12
  def initialize(opts={})
11
13
  super
12
14
  @candle_lighting_offset = opts[:candle_lighting_offset] || 18
15
+ @use_elevation = false
13
16
  end
14
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
29
+ end
30
+ alias_method :shkia, :elevation_adjusted_sunset
31
+
15
32
  def tzais(opts={degrees: 8.5})
16
- degrees, offset = extract_degrees_offset(opts)
17
- offset_by_minutes(sunset_offset_by_degrees(GEOMETRIC_ZENITH + degrees), offset)
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
18
40
  end
19
41
 
20
42
  def tzais_72
@@ -22,12 +44,17 @@ module Zmanim
22
44
  end
23
45
 
24
46
  def alos(opts={degrees: 16.1})
25
- degrees, offset = extract_degrees_offset(opts)
26
- offset_by_minutes(sunrise_offset_by_degrees(GEOMETRIC_ZENITH + degrees), offset)
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
27
54
  end
28
55
 
29
56
  def alos_72
30
- alos(offset: -72)
57
+ alos(offset: 72)
31
58
  end
32
59
 
33
60
  alias_method :chatzos, :sun_transit
@@ -37,7 +64,7 @@ module Zmanim
37
64
  end
38
65
 
39
66
  def sof_zman_shma_gra
40
- sof_zman_shma(sea_level_sunrise, sea_level_sunset)
67
+ sof_zman_shma(elevation_adjusted_sunrise, elevation_adjusted_sunset)
41
68
  end
42
69
 
43
70
  def sof_zman_shma_mga
@@ -53,22 +80,22 @@ module Zmanim
53
80
  end
54
81
 
55
82
  def sof_zman_tfila_gra
56
- sof_zman_tfila(sea_level_sunrise, sea_level_sunset)
83
+ sof_zman_tfila(elevation_adjusted_sunrise, elevation_adjusted_sunset)
57
84
  end
58
85
 
59
86
  def sof_zman_tfila_mga
60
87
  sof_zman_tfila(alos_72, tzais_72)
61
88
  end
62
89
 
63
- def mincha_gedola(day_start=sea_level_sunrise, day_end=sea_level_sunset)
90
+ def mincha_gedola(day_start=elevation_adjusted_sunrise, day_end=elevation_adjusted_sunset)
64
91
  shaos_into_day(day_start, day_end, 6.5)
65
92
  end
66
93
 
67
- def mincha_ketana(day_start=sea_level_sunrise, day_end=sea_level_sunset)
94
+ def mincha_ketana(day_start=elevation_adjusted_sunrise, day_end=elevation_adjusted_sunset)
68
95
  shaos_into_day(day_start, day_end, 9.5)
69
96
  end
70
97
 
71
- def plag_hamincha(day_start=sea_level_sunrise, day_end=sea_level_sunset)
98
+ def plag_hamincha(day_start=elevation_adjusted_sunrise, day_end=elevation_adjusted_sunset)
72
99
  shaos_into_day(day_start, day_end, 10.75)
73
100
  end
74
101
 
@@ -77,7 +104,7 @@ module Zmanim
77
104
  end
78
105
 
79
106
  def shaah_zmanis_gra
80
- shaah_zmanis(sea_level_sunrise, sea_level_sunset)
107
+ shaah_zmanis(elevation_adjusted_sunrise, elevation_adjusted_sunset)
81
108
  end
82
109
 
83
110
  def shaah_zmanis_mga
@@ -86,7 +113,15 @@ module Zmanim
86
113
 
87
114
  def shaah_zmanis_by_degrees_and_offset(degrees, offset)
88
115
  opts = {degrees: degrees, offset: offset}
89
- shaah_zmanis(alos(opts.merge(offset: -offset)), tzais(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?)
90
125
  end
91
126
 
92
127
  private
@@ -97,12 +132,18 @@ module Zmanim
97
132
  end
98
133
 
99
134
  def extract_degrees_offset(opts)
100
- [opts[:degrees] || 0.0, opts[:offset] || 0]
135
+ [opts[:degrees] || 0.0, opts[:offset] || 0, opts[:zmanis_offset] || 0]
101
136
  end
102
137
 
103
138
  def offset_by_minutes(time, minutes)
104
139
  return unless time
105
140
  time + (minutes / (60 * 24).to_f)
106
141
  end
142
+
143
+ def offset_by_minutes_zmanis(time, minutes)
144
+ return unless time
145
+ shaah_zmanis_skew = shaah_zmanis(elevation_adjusted_sunrise, elevation_adjusted_sunset) / HOUR_MILLIS
146
+ time + (minutes * shaah_zmanis_skew / (60 * 24).to_f)
147
+ end
107
148
  end
108
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.2.2
4
+ version: 0.3.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: 2018-08-31 00:00:00.000000000 Z
11
+ date: 2018-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo