stock_market_days 1.2.0 → 1.2.1

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: 94a9949aced23cb51da7cb4ec329e08b0f6a20af566b770bd71c5fe3d8c6a6d1
4
- data.tar.gz: b4b4fc2ff915c2f36b73974a91e61f6e5a672124a74d6dac0360de1d792fdf11
3
+ metadata.gz: e824858c3ddb3a1012e7500b350d828a6acc24d1dbc7c7144ba2196149f0469f
4
+ data.tar.gz: 87318b90f7aae3c0ce8533f2a1a5f814c8cb113ac2747f20a2420221294cf0b9
5
5
  SHA512:
6
- metadata.gz: 1a39aa6f5543811ec0dd0e13d57e97f639d05cfe20bcde5e9e90b3fda647f420ab0a5decafa954bb13b27be236438b964ad9423165f3562adf9bc957824bc8a4
7
- data.tar.gz: 120cdf30630d1180307529497e49c39b1da5ff32ad46e366158d6204be1bf17b92d264851bb1fcc129df4b537c40b48efe1e0dd9348321c4b3dd3d771784f41e
6
+ metadata.gz: cc7acc5605614dc40a2ead182d1255e333598d7705774171575d2bb1dea9cfd4abfa796a1079f9294a0eeec087d6efa0f980e5b585678f1329a892c5a038fd2f
7
+ data.tar.gz: acc414f62188c452c5a9ee2ff155fd0950c67cd02f1eee8af467be0ea4f543ee77844b4f59c98dc23a069edcf5a14e858a6046811ba364621e4e7382c3060ccd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ Version 1.2.1 (10/25/2024)
2
+ * Fixes a bug in the date calculation when given date is a weekend. (thanks wtn!)
3
+
1
4
  Version 1.2.0 (8/26/2024)
2
5
  * Several date corrections on future market days (thanks to the community)
3
6
  * 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
- market_days_list[begin_index - 1 + days]
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
@@ -1,3 +1,3 @@
1
1
  module StockMarketDays
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
@@ -211,4 +211,32 @@ describe StockMarketDays do
211
211
  end
212
212
  end
213
213
 
214
- end
214
+ context '#previous_market_day' do
215
+ subject { described_class.previous_market_day(from_date) }
216
+
217
+ context 'on a Saturday' do
218
+ let(:from_date) { Date.new(2020,1,4) }
219
+
220
+ it { is_expected.to eql(Date.new(2020,1,3)) }
221
+ end
222
+
223
+ context 'on Labor Day' do
224
+ let(:from_date) { Date.new(2019,9,2) }
225
+
226
+ it { is_expected.to eql(Date.new(2019,8,30)) }
227
+ end
228
+
229
+ context 'on a regular trading day' do
230
+ let(:from_date) { Date.new(2019,9,5) }
231
+
232
+ it { is_expected.to eql(Date.new(2019,9,4)) }
233
+ end
234
+
235
+ context 'on a Monday' do
236
+ let(:from_date) { Date.new(2019,9,23) }
237
+
238
+ it { is_expected.to eql(Date.new(2019,9,20)) }
239
+ end
240
+ end
241
+
242
+ 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.2.0
4
+ version: 1.2.1
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-08-27 00:00:00.000000000 Z
11
+ date: 2024-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler