mudrat_projector 0.9.2 → 0.9.3

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: 208d646de1dd5f31047845e03d7e568af08dd7a7
4
- data.tar.gz: 2eeefa3080632f09f31cac386f66ce461c850e12
3
+ metadata.gz: 99cf860a7f16e297d956e8b018652994a216552c
4
+ data.tar.gz: 51de6ef4a9280d86339c5e045cd3514f6475259c
5
5
  SHA512:
6
- metadata.gz: a7791e334bd3f788353bfd312c5804d712095e815d7c3f7c44235a99400432a05c611ec31210e22bc1d2924f8c82d8f3acd4fb3f31cec48066076aac72b52f3b
7
- data.tar.gz: a0ef6be6cc6535a7199bface1c4c591b4d4a60e04a4530d35f253008e5be650815944609c09237f3b44c16d7a82ff05e646430914d0ba0eb3bf0017e5d89306d
6
+ metadata.gz: 25820eacfe06c533db174462a6cc9ae66a826751ddbeda829250ae2970fb92ed8a15ffdc3366d92b9a76b478a3996206ec074ea7f965609d24b1904435b00834
7
+ data.tar.gz: 89671345c7a2ebd2ef4513a20312d676bd1d0a023df1a066def36a6fa3c855eb6ec3400745431f375800ac7cc35240d795b84b0dff917d3f9b4d56c0c20ca0e4
@@ -113,8 +113,14 @@ module MudratProjector
113
113
  end
114
114
 
115
115
  def self.advance intervals, from: from
116
- method = intervals > 0 ? :next_year : :prev_year
117
- intervals.times.inject from do |date, _| date.public_send method; end
116
+ if intervals < 1
117
+ days_in_year = from.leap? ? 366 : 365
118
+ days = intervals * days_in_year
119
+ DayCalculator.advance days, from: from
120
+ else
121
+ method = intervals > 0 ? :next_year : :prev_year
122
+ intervals.times.inject from do |date, _| date.public_send method; end
123
+ end
118
124
  end
119
125
  end
120
126
 
@@ -1,3 +1,3 @@
1
1
  module MudratProjector
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
@@ -109,6 +109,11 @@ class DateDiffTest < Minitest::Test
109
109
  assert_equal Date.new(2001, 2, 28), advance(from: feb_29_2000, unit: :year, intervals: 1)
110
110
  end
111
111
 
112
+ def test_advancing_one_year_and_a_day
113
+ assert_equal Date.new(2000, 1, 2), advance(from: jan_1_2000, unit: :year, intervals: (1.to_d / 366))
114
+ assert_equal Date.new(2001, 1, 2), advance(from: jan_1_2001, unit: :year, intervals: (1.to_d / 365))
115
+ end
116
+
112
117
  private
113
118
 
114
119
  def date_diff *args
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mudrat_projector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ntl