banking_calendar 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/README.md +10 -0
- data/lib/banking_calendar/version.rb +1 -1
- data/spec/calendar_spec.rb +58 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d96746db24d89b922d684ad9a5e5968c5d76195edf3879fbf5196e604206f1b5
|
4
|
+
data.tar.gz: 613f94a1a6782a5f698f257fa883ffadd472e449f80a25179714eef083c9d5c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f1102ddab923ed55daababbed00c4b51b41087de6584fb03bf5f253e556eacaca170c2d60a4bcc2fafea6c3fdf67e990cf0c361a40fd16db3dfeda45cd62f8f
|
7
|
+
data.tar.gz: b8da93ecea919c463cfa9066a5154356610ddce0b8e1a86ec9ee6284d4f7ad29b66f63bf2006688511d3f76390958517855ea8a58da811d49ed75afacc105fd7
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -57,6 +57,16 @@ calendar.banking_day?(Date.parse('15 April 2020'))
|
|
57
57
|
# => true
|
58
58
|
```
|
59
59
|
|
60
|
+
### banking_hour?(date)
|
61
|
+
Given a `date`, determine if the time component falls within the configured banking hours.
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
calendar.banking_hour?(DateTime.parse('2020-05-04 11:00'))
|
65
|
+
# => true
|
66
|
+
calendar.banking_hour?(DateTime.parse('2020-05-04 19:00'))
|
67
|
+
# => false
|
68
|
+
```
|
69
|
+
|
60
70
|
### banking_days_after(date, interval)
|
61
71
|
Given a `date`, this method returns the date after `interval` number of business days. If the given
|
62
72
|
`date` falls on a non-banking day, the calculation starts at the next possible banking day.
|
data/spec/calendar_spec.rb
CHANGED
@@ -558,7 +558,65 @@ describe BankingCalendar::Calendar do
|
|
558
558
|
end
|
559
559
|
|
560
560
|
context 'when it is a non-banking day' do
|
561
|
+
context 'preceded only by banking days' do
|
562
|
+
context 'when time is before banking hours' do
|
563
|
+
let(:date) { date_class.parse('2020-05-16 08:00') }
|
564
|
+
let(:delta) { 2 }
|
565
|
+
it { is_expected.to eq(cal.end_of_banking_day(date - (delta + 1) * interval)) }
|
566
|
+
end
|
561
567
|
|
568
|
+
context 'when time is during banking hours' do
|
569
|
+
let(:date) { date_class.parse('2020-05-16 09:00') }
|
570
|
+
let(:delta) { 2 }
|
571
|
+
it { is_expected.to eq(cal.end_of_banking_day(date - (delta + 1) * interval)) }
|
572
|
+
end
|
573
|
+
|
574
|
+
context 'when time is after banking hours' do
|
575
|
+
let(:date) { date_class.parse('2020-05-16 18:00') }
|
576
|
+
let(:delta) { 2 }
|
577
|
+
it { is_expected.to eq(cal.end_of_banking_day(date - (delta + 1) * interval)) }
|
578
|
+
end
|
579
|
+
end
|
580
|
+
|
581
|
+
context 'preceded by a weekend' do
|
582
|
+
context 'when time is before banking hours' do
|
583
|
+
let(:date) { date_class.parse('2020-05-17 08:00') }
|
584
|
+
let(:delta) { 2 }
|
585
|
+
it { is_expected.to eq(cal.end_of_banking_day(date - (delta + 2) * interval)) }
|
586
|
+
end
|
587
|
+
|
588
|
+
context 'when time is during banking hours' do
|
589
|
+
let(:date) { date_class.parse('2020-05-17 09:00') }
|
590
|
+
let(:delta) { 2 }
|
591
|
+
it { is_expected.to eq(cal.end_of_banking_day(date - (delta + 2) * interval)) }
|
592
|
+
end
|
593
|
+
|
594
|
+
context 'when time is after banking hours' do
|
595
|
+
let(:date) { date_class.parse('2020-05-17 18:00') }
|
596
|
+
let(:delta) { 2 }
|
597
|
+
it { is_expected.to eq(cal.end_of_banking_day(date - (delta + 2) * interval)) }
|
598
|
+
end
|
599
|
+
end
|
600
|
+
|
601
|
+
context 'preceded by banking days and non-banking days' do
|
602
|
+
context 'when time is before banking hours' do
|
603
|
+
let(:date) { date_class.parse('2020-04-11 08:00') }
|
604
|
+
let(:delta) { 2 }
|
605
|
+
it { is_expected.to eq(cal.end_of_banking_day(date - (delta + 3) * interval)) }
|
606
|
+
end
|
607
|
+
|
608
|
+
context 'when time is during banking hours' do
|
609
|
+
let(:date) { date_class.parse('2020-04-11 09:00') }
|
610
|
+
let(:delta) { 2 }
|
611
|
+
it { is_expected.to eq(cal.end_of_banking_day(date - (delta + 3) * interval)) }
|
612
|
+
end
|
613
|
+
|
614
|
+
context 'when time is after banking hours' do
|
615
|
+
let(:date) { date_class.parse('2020-04-11 18:00') }
|
616
|
+
let(:delta) { 2 }
|
617
|
+
it { is_expected.to eq(cal.end_of_banking_day(date - (delta + 3) * interval)) }
|
618
|
+
end
|
619
|
+
end
|
562
620
|
end
|
563
621
|
end
|
564
622
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: banking_calendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PayMongo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|