ae_bank_days 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -12
- data/LICENSE.txt +1 -1
- data/README.rdoc +3 -3
- data/Rakefile +4 -2
- data/ae_bank_days.gemspec +18 -15
- data/lib/ae_bank_days.rb +2 -43
- data/lib/ae_bank_days/bank_day_helper.rb +44 -0
- data/lib/ae_bank_days/version.rb +1 -1
- data/test/ae_bank_days/bank_day_helper_test.rb +88 -0
- data/test/ae_bank_days_test.rb +9 -0
- data/test/test_helper.rb +19 -0
- metadata +42 -29
- data/test/bank_day_helper_test.rb +0 -87
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78328538c2b370e7d744ec107ee252dae174538d69352d0f1e85fa83382c449a
|
4
|
+
data.tar.gz: 74655b450f093f68d30cbb498356d3db45b914dfc7697991cb0b8d612ef53911
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbf08e548ca896facd91a448331ab86e6687bf8f16132c88c1cb3eb08a3dd4acbed7f7f489b71f2fb4024c8587f617b135658778435029227239d5d837bcfa31
|
7
|
+
data.tar.gz: 6075ed1dc21f239f558e40d0ee740938b5ca3f9e8640f63a63a4cab3034fb739e6eb12be580f300a6ca6f69caff581441835af30461c9d20f94bd1a5672dba7a
|
data/Gemfile.lock
CHANGED
@@ -2,26 +2,22 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
ae_bank_days (1.1.1)
|
5
|
-
activesupport (>= 5.2, < 7)
|
6
5
|
holidays (~> 7.1)
|
7
6
|
|
8
7
|
GEM
|
9
8
|
remote: https://rubygems.org/
|
10
9
|
specs:
|
11
|
-
|
12
|
-
|
13
|
-
i18n (>= 0.7, < 2)
|
14
|
-
minitest (~> 5.1)
|
15
|
-
tzinfo (~> 1.1)
|
16
|
-
concurrent-ruby (1.1.5)
|
10
|
+
ansi (1.5.0)
|
11
|
+
builder (3.2.3)
|
17
12
|
holidays (7.1.0)
|
18
|
-
i18n (1.7.0)
|
19
|
-
concurrent-ruby (~> 1.0)
|
20
13
|
minitest (5.13.0)
|
14
|
+
minitest-reporters (1.3.0)
|
15
|
+
ansi
|
16
|
+
builder
|
17
|
+
minitest (>= 5.0)
|
18
|
+
ruby-progressbar
|
21
19
|
rake (12.3.2)
|
22
|
-
|
23
|
-
tzinfo (1.2.5)
|
24
|
-
thread_safe (~> 0.1)
|
20
|
+
ruby-progressbar (1.10.1)
|
25
21
|
|
26
22
|
PLATFORMS
|
27
23
|
ruby
|
@@ -29,6 +25,8 @@ PLATFORMS
|
|
29
25
|
DEPENDENCIES
|
30
26
|
ae_bank_days!
|
31
27
|
bundler (>= 1.10.4, < 3)
|
28
|
+
minitest (>= 5.8)
|
29
|
+
minitest-reporters (>= 1.3)
|
32
30
|
rake (>= 12.0)
|
33
31
|
|
34
32
|
BUNDLED WITH
|
data/LICENSE.txt
CHANGED
data/README.rdoc
CHANGED
@@ -9,9 +9,9 @@ Simple utility to find the next banking day
|
|
9
9
|
* Fork the project.
|
10
10
|
* Start a feature/bugfix branch.
|
11
11
|
* Commit and push until you are happy with your contribution.
|
12
|
-
* Make sure to add tests for it. This is important so
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so
|
12
|
+
* Make sure to add tests for it. This is important so it doesn't break in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so it can be cherry-picked around.
|
14
14
|
|
15
15
|
== Copyright
|
16
16
|
|
17
|
-
Copyright © 2019 AppFolio.
|
17
|
+
Copyright © 2019-2020 AppFolio.
|
data/Rakefile
CHANGED
@@ -2,13 +2,15 @@
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'bundler'
|
5
|
+
|
5
6
|
begin
|
6
7
|
Bundler.setup(:default, :development)
|
7
8
|
rescue Bundler::BundlerError => e
|
8
|
-
|
9
|
-
|
9
|
+
warn e.message
|
10
|
+
warn 'Run `bundle install` to install missing gems'
|
10
11
|
exit e.status_code
|
11
12
|
end
|
13
|
+
|
12
14
|
require 'rake/testtask'
|
13
15
|
|
14
16
|
Rake::TestTask.new(:test) do |test|
|
data/ae_bank_days.gemspec
CHANGED
@@ -5,23 +5,26 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
require 'ae_bank_days/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name
|
9
|
-
spec.version
|
10
|
-
spec.
|
11
|
-
spec.
|
12
|
-
spec.
|
13
|
-
spec.
|
14
|
-
spec.
|
8
|
+
spec.name = 'ae_bank_days'
|
9
|
+
spec.version = AeBankDays::VERSION
|
10
|
+
spec.platform = Gem::Platform::RUBY
|
11
|
+
spec.authors = ['AppFolio']
|
12
|
+
spec.email = ['dev@appfolio.com']
|
13
|
+
spec.summary = 'Gem for finding the next banking date'
|
14
|
+
spec.description = spec.summary
|
15
|
+
spec.homepage = 'http://github.com/appfolio/ae_bank_days'
|
15
16
|
spec.required_ruby_version = ['>= 2.3.3', '< 2.7']
|
16
|
-
spec.licenses
|
17
|
+
spec.licenses = ['MIT']
|
18
|
+
spec.files = Dir['**/*'].reject { |f| f[%r{^log/}] || f[%r{^pkg/}] }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test)/})
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
17
22
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
23
|
|
19
|
-
spec.
|
20
|
-
spec.test_files = spec.files.grep(%r{^(test)/})
|
21
|
-
spec.require_paths = ['lib']
|
24
|
+
spec.add_dependency('holidays', '~> 7.1')
|
22
25
|
|
23
|
-
spec.
|
24
|
-
spec.
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
26
|
+
spec.add_development_dependency('bundler', ['>= 1.10.4', '< 3'])
|
27
|
+
spec.add_development_dependency('minitest', '>= 5.8')
|
28
|
+
spec.add_development_dependency('minitest-reporters', '>= 1.3')
|
29
|
+
spec.add_development_dependency('rake', '>= 12.0')
|
27
30
|
end
|
data/lib/ae_bank_days.rb
CHANGED
@@ -1,49 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'date'
|
4
4
|
require 'holidays'
|
5
|
-
require 'active_support'
|
6
|
-
require 'active_support/core_ext/time'
|
7
|
-
require 'active_support/core_ext/integer/time'
|
8
5
|
|
9
6
|
module AeBankDays
|
10
|
-
|
11
|
-
ten_years_from_now = Time.now + 10.years
|
12
|
-
HOLIDAYS = Holidays.between(Date.civil(2014, 1, 1), ten_years_from_now, :federalreserve, :observed).map do |holiday|
|
13
|
-
holiday[:date]
|
14
|
-
end
|
15
|
-
|
16
|
-
class << self
|
17
|
-
def bank_day?(day)
|
18
|
-
date = day.to_date
|
19
|
-
weekday?(date) && !HOLIDAYS.include?(date)
|
20
|
-
end
|
21
|
-
|
22
|
-
def next_banking_day(date, number_of_days: 0)
|
23
|
-
banking_day = date
|
24
|
-
number_of_days.times do
|
25
|
-
banking_day += 1 until bank_day?(banking_day)
|
26
|
-
banking_day += 1
|
27
|
-
end
|
28
|
-
banking_day += 1 until bank_day?(banking_day)
|
29
|
-
banking_day
|
30
|
-
end
|
31
|
-
|
32
|
-
def previous_banking_day(date, number_of_days: 0)
|
33
|
-
banking_day = date
|
34
|
-
number_of_days.times do
|
35
|
-
banking_day -= 1 until bank_day?(banking_day)
|
36
|
-
banking_day -= 1
|
37
|
-
end
|
38
|
-
banking_day -= 1 until bank_day?(banking_day)
|
39
|
-
banking_day
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def weekday?(day)
|
45
|
-
[1, 2, 3, 4, 5].include? day.wday
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
7
|
+
autoload :BankDayHelper, 'ae_bank_days/bank_day_helper'
|
49
8
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AeBankDays
|
4
|
+
class BankDayHelper
|
5
|
+
START_DATE = Date.civil(2014, 1, 1)
|
6
|
+
END_DATE = Date.today.next_year(10)
|
7
|
+
HOLIDAYS = Holidays.between(START_DATE, END_DATE, :federalreserve, :observed).map do |holiday|
|
8
|
+
holiday[:date]
|
9
|
+
end
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def bank_day?(day)
|
13
|
+
date = day.to_date
|
14
|
+
weekday?(date) && !HOLIDAYS.include?(date)
|
15
|
+
end
|
16
|
+
|
17
|
+
def next_banking_day(date, number_of_days: 0)
|
18
|
+
banking_day = date
|
19
|
+
number_of_days.times do
|
20
|
+
banking_day += 1 until bank_day?(banking_day)
|
21
|
+
banking_day += 1
|
22
|
+
end
|
23
|
+
banking_day += 1 until bank_day?(banking_day)
|
24
|
+
banking_day
|
25
|
+
end
|
26
|
+
|
27
|
+
def previous_banking_day(date, number_of_days: 0)
|
28
|
+
banking_day = date
|
29
|
+
number_of_days.times do
|
30
|
+
banking_day -= 1 until bank_day?(banking_day)
|
31
|
+
banking_day -= 1
|
32
|
+
end
|
33
|
+
banking_day -= 1 until bank_day?(banking_day)
|
34
|
+
banking_day
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def weekday?(day)
|
40
|
+
(1..5).include?(day.wday)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/ae_bank_days/version.rb
CHANGED
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
module AeBankDays
|
6
|
+
class BankDayHelperTest < Minitest::Test
|
7
|
+
def test_constants
|
8
|
+
assert_equal Date.civil(2014, 1, 1), BankDayHelper::START_DATE
|
9
|
+
assert_equal Date.today.next_year(10), BankDayHelper::END_DATE
|
10
|
+
assert BankDayHelper::HOLIDAYS.any?
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_bank_day__weekday
|
14
|
+
time = Time.parse('2017-10-03 14:30:45 -0500')
|
15
|
+
assert BankDayHelper.bank_day?(time.to_date)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_bank_day__weekend
|
19
|
+
time = Time.parse('2017-10-14 14:30:45 -0500')
|
20
|
+
refute BankDayHelper.bank_day?(time.to_date)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_bank_day__holiday
|
24
|
+
time = Time.parse('2017-10-09 14:30:45 -0500')
|
25
|
+
refute BankDayHelper.bank_day?(time.to_date)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_next_banking_day__weekday
|
29
|
+
time = Time.parse('2017-10-03 14:30:45 -0500')
|
30
|
+
assert_equal Date.parse('2017-10-03'), BankDayHelper.next_banking_day(time.to_date)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_next_banking_day__weekday__extra_days
|
34
|
+
time = Time.parse('2017-10-03 14:30:45 -0500')
|
35
|
+
assert_equal Date.parse('2017-10-06'), BankDayHelper.next_banking_day(time.to_date, number_of_days: 3)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_next_banking_day__weekend
|
39
|
+
time = Time.parse('2017-10-14 14:30:45 -0500')
|
40
|
+
assert_equal Date.parse('2017-10-16'), BankDayHelper.next_banking_day(time.to_date)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_next_banking_day__weekend__extra_days
|
44
|
+
time = Time.parse('2017-10-14 14:30:45 -0500')
|
45
|
+
assert_equal Date.parse('2017-10-19'), BankDayHelper.next_banking_day(time.to_date, number_of_days: 3)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_next_banking_day__holiday
|
49
|
+
time = Time.parse('2017-10-09 14:30:45 -0500')
|
50
|
+
assert_equal Date.parse('2017-10-10'), BankDayHelper.next_banking_day(time.to_date)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_next_banking_day__holiday__extra_days
|
54
|
+
time = Time.parse('2017-10-09 14:30:45 -0500')
|
55
|
+
assert_equal Date.parse('2017-10-13'), BankDayHelper.next_banking_day(time.to_date, number_of_days: 3)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_previous_banking_day__weekday
|
59
|
+
time = Time.parse('2017-10-03 14:30:45 -0500')
|
60
|
+
assert_equal Date.parse('2017-10-03'), BankDayHelper.previous_banking_day(time.to_date)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_previous_banking_day__weekday__extra_days
|
64
|
+
time = Time.parse('2017-10-06 14:30:45 -0500')
|
65
|
+
assert_equal Date.parse('2017-10-03'), BankDayHelper.previous_banking_day(time.to_date, number_of_days: 3)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_previous_banking_day__weekend
|
69
|
+
time = Time.parse('2017-10-14 14:30:45 -0500')
|
70
|
+
assert_equal Date.parse('2017-10-13'), BankDayHelper.previous_banking_day(time.to_date)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_previous_banking_day__weekend__extra_days
|
74
|
+
time = Time.parse('2017-10-14 14:30:45 -0500')
|
75
|
+
assert_equal Date.parse('2017-10-10'), BankDayHelper.previous_banking_day(time.to_date, number_of_days: 3)
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_previous_banking_day__holiday
|
79
|
+
time = Time.parse('2017-10-09 14:30:45 -0500')
|
80
|
+
assert_equal Date.parse('2017-10-06'), BankDayHelper.previous_banking_day(time.to_date)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_previous_banking_day__holiday__extra_days
|
84
|
+
time = Time.parse('2017-10-09 14:30:45 -0500')
|
85
|
+
assert_equal Date.parse('2017-10-03'), BankDayHelper.previous_banking_day(time.to_date, number_of_days: 3)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
|
6
|
+
begin
|
7
|
+
Bundler.setup(:default, :development)
|
8
|
+
rescue Bundler::BundlerError => e
|
9
|
+
warn e.message
|
10
|
+
warn 'Run `bundle install` to install missing gems'
|
11
|
+
exit e.status_code
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'ae_bank_days'
|
15
|
+
require 'minitest/autorun'
|
16
|
+
require 'minitest/reporters'
|
17
|
+
require 'time'
|
18
|
+
|
19
|
+
MiniTest::Reporters.use!
|
metadata
CHANGED
@@ -1,84 +1,92 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ae_bank_days
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AppFolio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: holidays
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '7.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '7.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
33
|
+
version: 1.10.4
|
20
34
|
- - "<"
|
21
35
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
23
|
-
type: :
|
36
|
+
version: '3'
|
37
|
+
type: :development
|
24
38
|
prerelease: false
|
25
39
|
version_requirements: !ruby/object:Gem::Requirement
|
26
40
|
requirements:
|
27
41
|
- - ">="
|
28
42
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
43
|
+
version: 1.10.4
|
30
44
|
- - "<"
|
31
45
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
46
|
+
version: '3'
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
48
|
+
name: minitest
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
36
50
|
requirements:
|
37
|
-
- - "
|
51
|
+
- - ">="
|
38
52
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
40
|
-
type: :
|
53
|
+
version: '5.8'
|
54
|
+
type: :development
|
41
55
|
prerelease: false
|
42
56
|
version_requirements: !ruby/object:Gem::Requirement
|
43
57
|
requirements:
|
44
|
-
- - "
|
58
|
+
- - ">="
|
45
59
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
60
|
+
version: '5.8'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
62
|
+
name: minitest-reporters
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
50
64
|
requirements:
|
51
65
|
- - ">="
|
52
66
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
67
|
+
version: '1.3'
|
54
68
|
type: :development
|
55
69
|
prerelease: false
|
56
70
|
version_requirements: !ruby/object:Gem::Requirement
|
57
71
|
requirements:
|
58
72
|
- - ">="
|
59
73
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
74
|
+
version: '1.3'
|
61
75
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
76
|
+
name: rake
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
64
78
|
requirements:
|
65
79
|
- - ">="
|
66
80
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
68
|
-
- - "<"
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: '3'
|
81
|
+
version: '12.0'
|
71
82
|
type: :development
|
72
83
|
prerelease: false
|
73
84
|
version_requirements: !ruby/object:Gem::Requirement
|
74
85
|
requirements:
|
75
86
|
- - ">="
|
76
87
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
78
|
-
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: '3'
|
81
|
-
description: ''
|
88
|
+
version: '12.0'
|
89
|
+
description: Gem for finding the next banking date
|
82
90
|
email:
|
83
91
|
- dev@appfolio.com
|
84
92
|
executables: []
|
@@ -92,8 +100,11 @@ files:
|
|
92
100
|
- Rakefile
|
93
101
|
- ae_bank_days.gemspec
|
94
102
|
- lib/ae_bank_days.rb
|
103
|
+
- lib/ae_bank_days/bank_day_helper.rb
|
95
104
|
- lib/ae_bank_days/version.rb
|
96
|
-
- test/bank_day_helper_test.rb
|
105
|
+
- test/ae_bank_days/bank_day_helper_test.rb
|
106
|
+
- test/ae_bank_days_test.rb
|
107
|
+
- test/test_helper.rb
|
97
108
|
homepage: http://github.com/appfolio/ae_bank_days
|
98
109
|
licenses:
|
99
110
|
- MIT
|
@@ -122,4 +133,6 @@ signing_key:
|
|
122
133
|
specification_version: 4
|
123
134
|
summary: Gem for finding the next banking date
|
124
135
|
test_files:
|
125
|
-
- test/bank_day_helper_test.rb
|
136
|
+
- test/ae_bank_days/bank_day_helper_test.rb
|
137
|
+
- test/ae_bank_days_test.rb
|
138
|
+
- test/test_helper.rb
|
@@ -1,87 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
require 'ae_bank_days'
|
5
|
-
|
6
|
-
module AeBankDays
|
7
|
-
class BankDayHelperTest < ActiveSupport::TestCase
|
8
|
-
def test_constant
|
9
|
-
refute AeBankDays::BankDayHelper::HOLIDAYS.empty?
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_bank_day__weekday
|
13
|
-
time = Time.parse('2017-10-03 14:30:45 -0500')
|
14
|
-
assert AeBankDays::BankDayHelper.bank_day?(time.to_date)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_bank_day__weekend
|
18
|
-
time = Time.parse('2017-10-14 14:30:45 -0500')
|
19
|
-
refute AeBankDays::BankDayHelper.bank_day?(time.to_date)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_bank_day__holiday
|
23
|
-
time = Time.parse('2017-10-09 14:30:45 -0500')
|
24
|
-
refute AeBankDays::BankDayHelper.bank_day?(time.to_date)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_next_banking_day__weekday
|
28
|
-
time = Time.parse('2017-10-03 14:30:45 -0500')
|
29
|
-
assert_equal Date.parse('2017-10-03'), AeBankDays::BankDayHelper.next_banking_day(time.to_date)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_next_banking_day__weekday__extra_days
|
33
|
-
time = Time.parse('2017-10-03 14:30:45 -0500')
|
34
|
-
assert_equal Date.parse('2017-10-06'), AeBankDays::BankDayHelper.next_banking_day(time.to_date, number_of_days: 3)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_next_banking_day__weekend
|
38
|
-
time = Time.parse('2017-10-14 14:30:45 -0500')
|
39
|
-
assert_equal Date.parse('2017-10-16'), AeBankDays::BankDayHelper.next_banking_day(time.to_date)
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_next_banking_day__weekend__extra_days
|
43
|
-
time = Time.parse('2017-10-14 14:30:45 -0500')
|
44
|
-
assert_equal Date.parse('2017-10-19'), AeBankDays::BankDayHelper.next_banking_day(time.to_date, number_of_days: 3)
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_next_banking_day__holiday
|
48
|
-
time = Time.parse('2017-10-09 14:30:45 -0500')
|
49
|
-
assert_equal Date.parse('2017-10-10'), AeBankDays::BankDayHelper.next_banking_day(time.to_date)
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_next_banking_day__holiday__extra_days
|
53
|
-
time = Time.parse('2017-10-09 14:30:45 -0500')
|
54
|
-
assert_equal Date.parse('2017-10-13'), AeBankDays::BankDayHelper.next_banking_day(time.to_date, number_of_days: 3)
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_previous_banking_day__weekday
|
58
|
-
time = Time.parse('2017-10-03 14:30:45 -0500')
|
59
|
-
assert_equal Date.parse('2017-10-03'), AeBankDays::BankDayHelper.previous_banking_day(time.to_date)
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_previous_banking_day__weekday__extra_days
|
63
|
-
time = Time.parse('2017-10-06 14:30:45 -0500')
|
64
|
-
assert_equal Date.parse('2017-10-03'), AeBankDays::BankDayHelper.previous_banking_day(time.to_date, number_of_days: 3)
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_previous_banking_day__weekend
|
68
|
-
time = Time.parse('2017-10-14 14:30:45 -0500')
|
69
|
-
assert_equal Date.parse('2017-10-13'), AeBankDays::BankDayHelper.previous_banking_day(time.to_date)
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_previous_banking_day__weekend__extra_days
|
73
|
-
time = Time.parse('2017-10-14 14:30:45 -0500')
|
74
|
-
assert_equal Date.parse('2017-10-10'), AeBankDays::BankDayHelper.previous_banking_day(time.to_date, number_of_days: 3)
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_previous_banking_day__holiday
|
78
|
-
time = Time.parse('2017-10-09 14:30:45 -0500')
|
79
|
-
assert_equal Date.parse('2017-10-06'), AeBankDays::BankDayHelper.previous_banking_day(time.to_date)
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_previous_banking_day__holiday__extra_days
|
83
|
-
time = Time.parse('2017-10-09 14:30:45 -0500')
|
84
|
-
assert_equal Date.parse('2017-10-03'), AeBankDays::BankDayHelper.previous_banking_day(time.to_date, number_of_days: 3)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|