ae_bank_days 1.3.0 → 2.0.0

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: 36bfedfe987fca5f33d94432a975911c86c7059e5ebd8ed043c63e3ba1fb79d9
4
- data.tar.gz: 97e533307630017923b3be98066497cc9f8ef839681ac0b556bf57aad03ea118
3
+ metadata.gz: af37f7836eec42406fe3a2c1c86f3079f0b3ee95261020e770a8b3aa960ce524
4
+ data.tar.gz: 50fe48b765afdb9f3675934b157d809490b74985ce74e3a1fdd52428f28ccd9c
5
5
  SHA512:
6
- metadata.gz: 5953980f703d5a2693692712d4d1b3ff4a4c6f4e5805c838447dc3dc4215fd74f56e975d47079fa4add65c41ac8d43c57820918d07ffede9f192f0d44f6e4717
7
- data.tar.gz: 02dbe2927e5da4c4c1bb4f5b9159cefcaaabbccd608f0122aa8d8bd8e0a1d50f4181ac59f93cf21a40a11572c641176771af35c39ae7e9e00199597e18e1f76d
6
+ metadata.gz: 7a9b58a38b414c355268fcd982e232e216d4c8fe0ade9da1a6218e1c41e8cca852e3bcf6ae6b1d6cdae8013400006735eda668378237398ebc9016a7cfd7da79
7
+ data.tar.gz: c4fc232b7874a6d4c6be98c6860e189f7ab156821b61d3eb56b57371384b07acb96934c299fbd24268cebb46d8900e45242fabd43a76f80fe461fd5b11b81357
@@ -11,23 +11,37 @@ module AeBankDays
11
11
  end
12
12
 
13
13
  def next_banking_day(date, number_of_days: 0)
14
- banking_day = date
14
+ banking_day = date.to_date
15
+ banking_day += 1
15
16
  number_of_days.times do
16
- banking_day += 1 until bank_day?(banking_day)
17
+ banking_day = current_or_next_banking_day(banking_day)
17
18
  banking_day += 1
18
19
  end
19
- banking_day += 1 until bank_day?(banking_day)
20
- banking_day
20
+
21
+ current_or_next_banking_day(banking_day)
21
22
  end
22
23
 
23
24
  def previous_banking_day(date, number_of_days: 0)
24
- banking_day = date
25
+ banking_day = date.to_date
26
+ banking_day -= 1
25
27
  number_of_days.times do
26
- banking_day -= 1 until bank_day?(banking_day)
28
+ banking_day = current_or_previous_banking_day(banking_day)
27
29
  banking_day -= 1
28
30
  end
29
- banking_day -= 1 until bank_day?(banking_day)
30
- banking_day
31
+
32
+ current_or_previous_banking_day(banking_day)
33
+ end
34
+
35
+ def current_or_previous_banking_day(day)
36
+ date = day.to_date
37
+ date -= 1 until bank_day?(date)
38
+ date
39
+ end
40
+
41
+ def current_or_next_banking_day(day)
42
+ date = day.to_date
43
+ date += 1 until bank_day?(date)
44
+ date
31
45
  end
32
46
 
33
47
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AeBankDays
4
- VERSION = '1.3.0'
4
+ VERSION = '2.0.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ae_bank_days
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AppFolio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-02 00:00:00.000000000 Z
11
+ date: 2021-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: holidays