slide_rule 0.1.0 → 0.1.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
  SHA1:
3
- metadata.gz: 140911c7f9078ab2887f32012e167852d15f9ccd
4
- data.tar.gz: c7f8db4642867e007875ee81d8403e037d647389
3
+ metadata.gz: 15b535d71c03e3343c521cd0558bdff9c398bb9d
4
+ data.tar.gz: b520ab84e2f9dccfda40499ea471abcdf4f8ac2b
5
5
  SHA512:
6
- metadata.gz: 24a59fcbca5f635b1a52d0cd8186df12d97ba0f55cb27e2389c55023b87e3cd9b06f3cd8f752cd97b1480466d2c6eb47ab36ca425edd804ae04543f06b33b2d0
7
- data.tar.gz: 9856686afc80d0437803c44095d0c9561049d1fee4f38913aec2e7f647d7456eb0c959ecde55efd74613e04a265fc4b60de7bf4f48be915b185bd05022eeaeec
6
+ metadata.gz: 960910993780635fb5c8be9a347a8d2d8932a1a70255af019cb30bba25181ca5e0905f25ff1c1fe4e7c701c49f0204c447229a4365188e0e2fd158abcf0c4b4d
7
+ data.tar.gz: 883bdb53e7575cd4ce3b2d24fa89fe05bb97898573b5351f239ec52d803a6dfcabe7f250e61b3f37753ecc31b61c2c2fc32bb07663ec87f07a58e78e38a18c8c
@@ -23,6 +23,7 @@ module SlideRule
23
23
  private
24
24
 
25
25
  def cleanse_date(date)
26
+ date = Time.at(date).utc.to_date if date.is_a?(::Fixnum)
26
27
  date = Date.parse(date) unless date.is_a?(::Date) || date.is_a?(::Time)
27
28
  date = date.to_date if date.is_a?(::Time)
28
29
 
@@ -18,6 +18,7 @@ module SlideRule
18
18
  private
19
19
 
20
20
  def cleanse_date(date)
21
+ date = Time.at(date).utc.to_date if date.is_a?(::Fixnum)
21
22
  date = Date.parse(date) unless date.is_a?(::Date) || date.is_a?(::Time)
22
23
  date = date.to_date if date.is_a?(::Time)
23
24
 
@@ -1,3 +1,3 @@
1
1
  module SlideRule
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -6,6 +6,10 @@ describe ::SlideRule::DistanceCalculators::DayOfMonth do
6
6
  expect(described_class.new.calculate('2012-03-19', '2014-08-19')).to eq(0.0)
7
7
  end
8
8
 
9
+ it 'should accept epoch date' do
10
+ expect(described_class.new.calculate(1_444_262_400, 1_444_262_400)).to eq(0.0)
11
+ end
12
+
9
13
  it 'should calculate when date is in the same month' do
10
14
  expect(described_class.new.calculate('2012-03-19', '2014-08-22')).to eq(3.0 / 15)
11
15
  expect(described_class.new.calculate('2012-03-19', '2014-08-09')).to eq(10.0 / 15)
@@ -5,6 +5,10 @@ describe ::SlideRule::DistanceCalculators::DayOfYear do
5
5
  it 'should return a 0 distance' do
6
6
  expect(described_class.new.calculate('2015-10-8', '2015-10-8')).to eq(0.0)
7
7
  end
8
+
9
+ it 'should accept epoch date' do
10
+ expect(described_class.new.calculate(1_444_262_400, 1_444_262_400)).to eq(0.0)
11
+ end
8
12
  end
9
13
 
10
14
  context 'when dates are more than a year apart' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slide_rule
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mattnichols
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-11 00:00:00.000000000 Z
12
+ date: 2015-11-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: vladlev