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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fe25c53a1e7a771f43de415ee1195c06ff985a47ed297cd1e438688d64dbe06
4
- data.tar.gz: ba475f817892c882ff8372c83e54c2df30a1df1c691cd1fec9ad3ed90c9eb0bf
3
+ metadata.gz: d96746db24d89b922d684ad9a5e5968c5d76195edf3879fbf5196e604206f1b5
4
+ data.tar.gz: 613f94a1a6782a5f698f257fa883ffadd472e449f80a25179714eef083c9d5c1
5
5
  SHA512:
6
- metadata.gz: 492881d3f120a304143e02a8cf491a74440470956944019e6bd4273196b33172cdfc348d10c8738ec3df0af1232625d7fb8e6cab9c59aa3fbab52353ddda6c00
7
- data.tar.gz: be84c832399d0806fd4a4af9831eb30f2300eae20d79815dcca2cf9914d72e014089f6fc5bd8de41be03b2fd7570b896ee1a23b877d22b87a148a492ceb18625
6
+ metadata.gz: 3f1102ddab923ed55daababbed00c4b51b41087de6584fb03bf5f253e556eacaca170c2d60a4bcc2fafea6c3fdf67e990cf0c361a40fd16db3dfeda45cd62f8f
7
+ data.tar.gz: b8da93ecea919c463cfa9066a5154356610ddce0b8e1a86ec9ee6284d4f7ad29b66f63bf2006688511d3f76390958517855ea8a58da811d49ed75afacc105fd7
@@ -2,7 +2,7 @@
2
2
 
3
3
  - Initial release
4
4
 
5
- # v0.1.0 - May 19, 2020
5
+ # v0.1.0 - May 18, 2020
6
6
 
7
7
  - Adds support for banking time and normalization of banking days
8
8
  - Includes banking time in rollover calculations, if provided
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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BankingCalendar
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
@@ -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.0
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-18 00:00:00.000000000 Z
11
+ date: 2020-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec