stock_market_days 1.2.0 → 1.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e76a55bcd76b991250ce5791ac9dec3e9a925166d40edad0b208cdbc12071cd
|
4
|
+
data.tar.gz: 3452283cbc55cd4ec99b2483111e83bd908b2e16f327feafc55e0bb40c2d765c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c40613090f2a9302d31af6f927f37d9329e0ba561cb8e675694b8ef15053526715752dd6160ab687ddbb5107b747d78a2abf30fd43e4800c555358a3f10d3db6
|
7
|
+
data.tar.gz: ac5ff806c47c7e09742389b99c0f868d2d3d1f54c10845043edac45edfe1cdbcff8ead09578b0446760e20acaebedc5d3d9a16b3380892d2157a7d821c376872
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
Version 1.3.0 (12/30/2024)
|
2
|
+
* Add 1/9/25 market closed day for Jimmy Carter's death
|
3
|
+
|
4
|
+
Version 1.2.1 (10/25/2024)
|
5
|
+
* Fixes a bug in the date calculation when given date is a weekend. (thanks wtn!)
|
6
|
+
|
1
7
|
Version 1.2.0 (8/26/2024)
|
2
8
|
* Several date corrections on future market days (thanks to the community)
|
3
9
|
* Improved benchmarks on date calculation
|
@@ -40,12 +40,16 @@ module StockMarketDays
|
|
40
40
|
if market_days_list[begin_index] == begin_day
|
41
41
|
market_days_list[begin_index + days]
|
42
42
|
elsif market_days_list[begin_index] > begin_day
|
43
|
-
|
43
|
+
if days == 0
|
44
|
+
market_days_list[begin_index - 1]
|
45
|
+
else
|
46
|
+
offset = days > 0 ? -1 : 0
|
47
|
+
market_days_list[begin_index + offset + days]
|
48
|
+
end
|
44
49
|
else
|
45
50
|
raise "Calculator Error - This shouldn't happen in StockMarketDays#market_days_from"
|
46
51
|
end
|
47
52
|
end
|
48
53
|
|
49
|
-
|
50
54
|
end
|
51
|
-
end
|
55
|
+
end
|
@@ -105,6 +105,21 @@ describe StockMarketDays do
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
108
|
+
|
109
|
+
context 'is National Day of Mourning' do
|
110
|
+
let(:dates) do
|
111
|
+
[
|
112
|
+
Date.new(2018,12,5),
|
113
|
+
Date.new(2025,1,9),
|
114
|
+
]
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'reports market closed' do
|
118
|
+
dates.each do |market_closed_day|
|
119
|
+
expect(described_class.is_market_day?(market_closed_day)).to be_falsey
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
108
123
|
end
|
109
124
|
|
110
125
|
context '#market_days_between' do
|
@@ -211,4 +226,32 @@ describe StockMarketDays do
|
|
211
226
|
end
|
212
227
|
end
|
213
228
|
|
214
|
-
|
229
|
+
context '#previous_market_day' do
|
230
|
+
subject { described_class.previous_market_day(from_date) }
|
231
|
+
|
232
|
+
context 'on a Saturday' do
|
233
|
+
let(:from_date) { Date.new(2020,1,4) }
|
234
|
+
|
235
|
+
it { is_expected.to eql(Date.new(2020,1,3)) }
|
236
|
+
end
|
237
|
+
|
238
|
+
context 'on Labor Day' do
|
239
|
+
let(:from_date) { Date.new(2019,9,2) }
|
240
|
+
|
241
|
+
it { is_expected.to eql(Date.new(2019,8,30)) }
|
242
|
+
end
|
243
|
+
|
244
|
+
context 'on a regular trading day' do
|
245
|
+
let(:from_date) { Date.new(2019,9,5) }
|
246
|
+
|
247
|
+
it { is_expected.to eql(Date.new(2019,9,4)) }
|
248
|
+
end
|
249
|
+
|
250
|
+
context 'on a Monday' do
|
251
|
+
let(:from_date) { Date.new(2019,9,23) }
|
252
|
+
|
253
|
+
it { is_expected.to eql(Date.new(2019,9,20)) }
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stock_market_days
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Winston Kotzan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|