fat_core 0.2.9 → 0.3.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
  SHA1:
3
- metadata.gz: 35128d619a5a539a01d9dca576d4320a4b92376f
4
- data.tar.gz: a49087393debc6cbe6671ab032c150ff911e80c9
3
+ metadata.gz: ab979ecd2ac34d1c729d80fff62e4bf2edc3e024
4
+ data.tar.gz: 2a53dd80c0d65df335d3d238cec0c4f71d17f768
5
5
  SHA512:
6
- metadata.gz: cd166e12d04182998e3daf894fac4d30f9979b4ce168047a782e279897c51783395a02a81f9044beb10e496be0b1dbcf4e951bfd7fee4ed0f2b38fadaca4d5ed
7
- data.tar.gz: 7904ddf24bcb792d71e373e50f9f9be05b82169f1e013da76d04f3586a512ce0bd313dd7d24a7dc72142221e35a5344d47e8d6913e5253048a5f7e1976bd0141
6
+ metadata.gz: 2698c7c8bd529073b3eaf9cc9b360aa1129c126316aa05c8e0f429ebffd01e30981a8a208cf5dcb1f7b006eca1d2352cddfd5f1e28bd93934b4e2f81a4d6737f
7
+ data.tar.gz: 3efee775ac480bbfe74649a70d26ffb1e0fe8c173c711f1c926647709db88596e0db38e7fa1da2cb8654c8a99fe2f064bf9dbecf2905804624a069aba198c226
data/lib/fat_core/date.rb CHANGED
@@ -876,4 +876,24 @@ class Date
876
876
  add_nyse_business_days(-1)
877
877
  end
878
878
  alias :prior_trading_day :prior_nyse_workday
879
+
880
+ # Return self if its a trading day, otherwise skip back to the first prior
881
+ # trading day.
882
+ def prior_until_trading_day
883
+ date = self
884
+ while !date.trading_day?
885
+ date -= 1
886
+ end
887
+ date
888
+ end
889
+
890
+ # Return self if its a trading day, otherwise skip forward to the first
891
+ # later trading day.
892
+ def next_until_trading_day
893
+ date = self
894
+ while !date.trading_day?
895
+ date += 1
896
+ end
897
+ date
898
+ end
879
899
  end
@@ -1,7 +1,7 @@
1
1
  module FatCore
2
2
  MAJOR = 0
3
- MINOR = 2
4
- PATCH = 9
3
+ MINOR = 3
4
+ PATCH = 0
5
5
 
6
6
  VERSION = [MAJOR, MINOR, PATCH].compact.join('.')
7
7
  end
@@ -838,6 +838,21 @@ describe Date do
838
838
  expect(Date.parse('2016-04-25').prior_trading_day)
839
839
  .to eq Date.parse('2016-04-22')
840
840
  end
841
+
842
+ it "should be able to skip until it hits a trading day" do
843
+ # A Wednesday
844
+ expect(Date.parse('2014-03-26').prior_until_trading_day)
845
+ .to eq(Date.parse('2014-03-26'))
846
+ # A Sunday
847
+ expect(Date.parse('2014-03-30').prior_until_trading_day)
848
+ .to eq(Date.parse('2014-03-28'))
849
+ # A Wednesday
850
+ expect(Date.parse('2014-03-26').next_until_trading_day)
851
+ .to eq(Date.parse('2014-03-26'))
852
+ # A Sunday
853
+ expect(Date.parse('2014-03-30').next_until_trading_day)
854
+ .to eq(Date.parse('2014-03-31'))
855
+ end
841
856
  end
842
857
  end
843
858
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-01 00:00:00.000000000 Z
11
+ date: 2015-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov