interest_days 0.5.2 → 0.5.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
  SHA256:
3
- metadata.gz: 2883c05efa288b06891b2aac71fca5331c723d1df471b18267f60879a9faad7f
4
- data.tar.gz: 74379f2e234f43b03c711a26c0ad7fa3cc5ca32fce5bcfacb3ceb329a4f44448
3
+ metadata.gz: 10512ef2d8b56d0c8110707011f3b9588a2fdd11bea9c5ba2efbf28f4f898da5
4
+ data.tar.gz: 5d5eceafc7ef04cb73e07828d28cd9345f6b6bc065682d8da8d770f6ab64ed9c
5
5
  SHA512:
6
- metadata.gz: 72b9afc11e72d1f9b015d8c457187c1f9c3a4d99cf5606a4ae6279eff57df24d8b3ea6d7b659b64920edce0898c8ba5194a532b7c1797c2eef73539b7a7d11b5
7
- data.tar.gz: b12ea6908e66b813a5d4a8567a5da45a63f612b23b66c2752377dd614e035bb5e260bb4e1595f8e2eef80d37de194ba06b7c90868fc328da8aa996edf945454b
6
+ metadata.gz: 6ecb400209fb903908d8e3c1bf9be08f81ca2b8dd58543b87a301b167b1f875faf6831f52d31da9862cb071a2852ef797dd00b2478918771cdb99aab3d803daa
7
+ data.tar.gz: 381edf8b7bf4ee0dce7ed7c0ef288ebbf2ddf617da4cfc5980254b46826a48035267bc901734e1c78eceebe7e7ae46ae0247df1cb5165a4c18ea858136927ce5
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
1
 
2
+ ## [0.5.3] / 2022-11-14
3
+ ==================
4
+ * Fix ICMA act/act strategy for interest periods relates to small periods within a leap year.
5
+
2
6
  ## [0.5.2] / 2022-11-11
3
7
  ==================
4
8
  * Fix ICMA act/act strategy for interest periods longer than one year.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- interest_days (0.5.2)
4
+ interest_days (0.5.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -14,7 +14,6 @@ Gem::Specification.new do |spec|
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = ">= 2.7.0"
16
16
 
17
-
18
17
  spec.metadata["homepage_uri"] = spec.homepage
19
18
  spec.metadata["source_code_uri"] = "https://github.com/eugenmueller/interest_days"
20
19
  spec.metadata["changelog_uri"] = "https://github.com/eugenmueller/interest_days/blob/v0.2.0/CHANGELOG.md"
@@ -8,17 +8,14 @@ module InterestDays
8
8
  DAYS_IN_LEAP_YEAR = 366
9
9
 
10
10
  def day_count_factor
11
- return days.fdiv(start_date_days_in_year) if start_date_and_end_date_in_same_year?
12
-
13
- if years_in_between_factor.positive?
14
- return start_date_period_factor + years_in_between_factor + end_date_period_factor
15
- end
11
+ return multiple_years_day_count_factor if years_in_between_factor.positive?
16
12
 
17
13
  days.fdiv(year_days_in_period)
18
14
  end
19
15
 
20
16
  private
21
17
 
18
+ # calculate for periods smaller than a year
22
19
  def year_days_in_period
23
20
  period_contains_leap_day? ? DAYS_IN_LEAP_YEAR : DAYS_IN_YEAR
24
21
  end
@@ -35,6 +32,11 @@ module InterestDays
35
32
  end
36
33
  end
37
34
 
35
+ # claculate for period span more than a year
36
+ def multiple_years_day_count_factor
37
+ start_date_period_factor + years_in_between_factor + end_date_period_factor
38
+ end
39
+
38
40
  def start_date_period_factor
39
41
  (start_date_days_in_year - start_date.yday).fdiv(start_date_days_in_year)
40
42
  end
@@ -48,11 +50,11 @@ module InterestDays
48
50
  end
49
51
 
50
52
  def start_date_period_with_leap_date?
51
- start_date.leap? && start_date.month < 3
53
+ start_date.leap? && Date.new(start_date.year, 2, 29)&.between?(start_date, Date.new(start_date.year, 12, 31))
52
54
  end
53
55
 
54
56
  def end_date_period_with_leap_date?
55
- end_date.leap? && end_date >= Date.new(end_date.year, 2, 29)
57
+ end_date.leap? && Date.new(end_date.year, 2, 29)&.between?(Date.new(end_date.year, 1, 1), end_date)
56
58
  end
57
59
 
58
60
  def start_date_and_end_date_in_same_year?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InterestDays
4
- VERSION = "0.5.2"
4
+ VERSION = "0.5.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interest_days
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Mueller