business_calendar 0.0.7 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +1 -0
- data/.simplecov +8 -0
- data/.travis.yml +25 -0
- data/Gemfile +2 -0
- data/README.md +27 -12
- data/business_calendar.gemspec +2 -3
- data/data/BR.yml +17 -0
- data/data/CN.yml +116 -0
- data/data/GB.yml +54 -0
- data/data/US.yml +236 -0
- data/gemfiles/ree.gemfile +7 -0
- data/lib/business_calendar/calendar.rb +5 -2
- data/lib/business_calendar/holiday_determiner.rb +2 -3
- data/lib/business_calendar/ruby18_shim.rb +13 -0
- data/lib/business_calendar/version.rb +1 -1
- data/lib/business_calendar.rb +26 -17
- data/spec/acceptance_cn_spec.rb +44 -16
- data/spec/acceptance_gb_spec.rb +18 -1
- data/spec/acceptance_us_spec.rb +226 -39
- data/spec/business_calendar_spec.rb +7 -3
- data/spec/spec_helper.rb +4 -1
- metadata +20 -49
- data/data/holidays.yml +0 -137
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZGE0ZjdmY2IzN2NiM2VkNzE2ZTk2YjIxMDIxYjE2YTk2YTIwMGEyNQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NjA1YWJhOGY4NmZhMDhlZWFmMmM2ZjQ2ZTljZjNmNTU2OWNiNjQyNw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ODdkZjc2MzdhYWU1ODkwMzM1ZTBmZjdiZGMyMTFhYTE2NDEwYmQyYmE3ODVl
|
10
|
+
ODJkMDc0NGM5MjRiMzQ4NDRjOGMwZjVkYzBiMDgyZTI0NjUyNzhmMTNmY2Vh
|
11
|
+
ZWQyMDc5OGQ1M2Q3ZmQ4OWNiYzM1OGY5Njc5MTQ0ZWNmNzI4ODc=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MTM3MDBlZDA4MDUzNGZmYWY3YmNiMDgxODdlNThlMDU2YjI2MWRlZTJkZDQ4
|
14
|
+
NzBmMjg3YWUxOGZkYmNmZTIzZGU2MWEyN2QzNzc2ZjY4ZjQ3NGQzNWJiNzdl
|
15
|
+
NzMzMmY5ZmMzZDMyYWEzMWUxZWQxMDQwOWI3ZWJlYzc4ZTYyMDM=
|
data/.gitignore
CHANGED
data/.simplecov
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
cache: bundler
|
4
|
+
rvm:
|
5
|
+
- 2.3.1
|
6
|
+
|
7
|
+
script: bundle exec rspec
|
8
|
+
|
9
|
+
env:
|
10
|
+
global:
|
11
|
+
secure: klQ3BQNdKkGIq3Zfv8Sr6oZqaMg9GHx+LGhynQ5xt7A6SGvxbMuoXJlE9wW4me6u+B9S2D+q+pdKgGPE/+fHsVt/d0zDXRnrjVyo1eexT220AMfpjiFDAtya8sAcuuAICLhw8AmzTjns8yAWInv5U5vC6oejkLA71FXtHU//210=
|
12
|
+
|
13
|
+
matrix:
|
14
|
+
include:
|
15
|
+
- rvm: ree
|
16
|
+
gemfile: gemfiles/ree.gemfile
|
17
|
+
env: TEST_SUITE=spec
|
18
|
+
|
19
|
+
deploy:
|
20
|
+
provider: rubygems
|
21
|
+
api_key:
|
22
|
+
secure: "c9QcNX+nk0Yzl22ZVknZtv+/G4fUeLph0TH9PS6hQ92zywM61wtXTJExZdBHulvKAaQbKaq20LcFjLw41qwJc6tvIEYXpOinfOaiemTKaGmKscDrIi3wUAxfjmTacXZAaTdEORQVqTOmppqsuKnP7cqmSNxTSI901Sz5Cy6Jpl0="
|
23
|
+
on:
|
24
|
+
tags: true
|
25
|
+
repo: enova/business_calendar
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# BusinessCalendar
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/business_calendar.svg)](https://rubygems.org/gems/business_calendar)
|
4
|
+
[![Build Status](https://travis-ci.org/enova/business_calendar.svg)](https://travis-ci.org/enova/business_calendar)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/github/enova/business_calendar/badge.svg?branch=master)](https://coveralls.io/github/enova/business_calendar?branch=master)
|
6
|
+
[![Dependency Status](https://gemnasium.com/enova/business_calendar.svg)](https://gemnasium.com/enova/business_calendar)
|
7
|
+
|
3
8
|
Need to know what days you can actually debit a customer on in excruciating detail? Fed up with singleton-based gems
|
4
9
|
that can't handle your complex, multi-international special needs? *So* over extending core objects like Numeric
|
5
10
|
and Date just to make your code a little cleaner? Well, do I have the gem for you! **BusinessCalendar** is a
|
@@ -9,7 +14,9 @@ reasonably light-weight solution, concerned primarily with banking holidays in d
|
|
9
14
|
|
10
15
|
Add this line to your application's Gemfile:
|
11
16
|
|
12
|
-
|
17
|
+
```ruby
|
18
|
+
gem 'business_calendar'
|
19
|
+
```
|
13
20
|
|
14
21
|
And then execute:
|
15
22
|
|
@@ -21,30 +28,38 @@ And then execute:
|
|
21
28
|
|
22
29
|
Instantiate a calendar object with:
|
23
30
|
|
24
|
-
|
25
|
-
|
31
|
+
```ruby
|
32
|
+
bc = BusinessCalendar.for(:US)
|
33
|
+
```
|
34
|
+
|
26
35
|
This will automatically load holidays based on the US banking holiday schedule, as configured in `data/holidays.yml`.
|
27
36
|
Currently, this gem supports `:GB` and `:US` regions.
|
28
37
|
|
29
38
|
Now, you can use it:
|
30
39
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
40
|
+
```ruby
|
41
|
+
bc.is_business_day? Date.parse('2014-03-10') # => true
|
42
|
+
bc.add_business_day Date.parse('2014-03-10') # => #<Date 2014-03-11>
|
43
|
+
bc.nearest_business_day Date.parse('2014-03-08') # => #<Date 2014-03-10>
|
44
|
+
bc.add_business_days Date.parse('2014-03-10'), 2 # => #<Date 2014-03-12>
|
45
|
+
bc.preceding_business_day Date.parse('2014-03-11') # => #<Date 2014-03-10>
|
46
|
+
```
|
36
47
|
|
37
48
|
And in multi-value contexts, too!
|
38
49
|
|
39
|
-
|
40
|
-
|
50
|
+
```ruby
|
51
|
+
bc.add_business_day [ Date.parse('2014-03-10'), Date.parse('2014-03-11') ]
|
52
|
+
# => [ #<Date 2014-03-11>, #<Date 2014-03-12> ]
|
53
|
+
```
|
41
54
|
|
42
55
|
### Non-standard holidays
|
43
56
|
|
44
57
|
If you need a different list of holidays, you can skip the porcelain and create the calendar yourself with a custom holiday-determiner proc:
|
45
58
|
|
46
|
-
|
47
|
-
|
59
|
+
```ruby
|
60
|
+
holiday_tester = Proc.new { |date| MY_HOLIDAY_DATES.include? date }
|
61
|
+
bc = BusinessCalendar::Calendar.new(holiday_tester)
|
62
|
+
```
|
48
63
|
|
49
64
|
## Contributing
|
50
65
|
|
data/business_calendar.gemspec
CHANGED
@@ -22,8 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
24
|
spec.add_development_dependency "rake"
|
25
|
-
spec.add_development_dependency "pry"
|
26
|
-
spec.add_development_dependency "pry-debugger"
|
27
25
|
spec.add_development_dependency "rspec", "~> 3.2"
|
28
|
-
spec.add_development_dependency "
|
26
|
+
spec.add_development_dependency "simplecov"
|
27
|
+
spec.add_development_dependency "pry"
|
29
28
|
end
|
data/data/BR.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# +additions_only+ will tell business_calendar to not attempt to fetch holidays from the underlying
|
2
|
+
# `holidays` gem, and instead only use the defined +additions+ here. Useful e.g. for cases where a
|
3
|
+
# country is not even defined in the `holidays` gem.
|
4
|
+
# Defaults to `false`
|
5
|
+
|
6
|
+
BR:
|
7
|
+
regions:
|
8
|
+
- br
|
9
|
+
holiday_names:
|
10
|
+
- Dia da Confraternização Universal
|
11
|
+
- Dia de Tiradentes
|
12
|
+
- Dia do Trabalho
|
13
|
+
- Proclamação da Independência
|
14
|
+
- Dia de Nossa Senhora Aparecida
|
15
|
+
- Dia de Finados
|
16
|
+
- Proclamação da República
|
17
|
+
- Natal
|
data/data/CN.yml
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
# +additions_only+ will tell business_calendar to not attempt to fetch holidays from the underlying
|
2
|
+
# `holidays` gem, and instead only use the defined +additions+ here. Useful e.g. for cases where a
|
3
|
+
# country is not even defined in the `holidays` gem.
|
4
|
+
# Defaults to `false`
|
5
|
+
|
6
|
+
CN:
|
7
|
+
regions:
|
8
|
+
- cn
|
9
|
+
additions:
|
10
|
+
- '2014-01-01'
|
11
|
+
- '2014-01-31'
|
12
|
+
- '2014-02-01'
|
13
|
+
- '2014-02-02'
|
14
|
+
- '2014-02-03'
|
15
|
+
- '2014-02-04'
|
16
|
+
- '2014-02-05'
|
17
|
+
- '2014-02-06'
|
18
|
+
- '2014-04-05'
|
19
|
+
- '2014-04-06'
|
20
|
+
- '2014-04-07'
|
21
|
+
- '2014-05-01'
|
22
|
+
- '2014-05-02'
|
23
|
+
- '2014-05-03'
|
24
|
+
- '2014-05-31'
|
25
|
+
- '2014-06-01'
|
26
|
+
- '2014-06-02'
|
27
|
+
- '2014-09-06'
|
28
|
+
- '2014-09-07'
|
29
|
+
- '2014-09-08'
|
30
|
+
- '2014-10-01'
|
31
|
+
- '2014-10-02'
|
32
|
+
- '2014-10-03'
|
33
|
+
- '2014-10-04'
|
34
|
+
- '2014-10-05'
|
35
|
+
- '2014-10-06'
|
36
|
+
- '2014-10-07'
|
37
|
+
- '2015-01-01'
|
38
|
+
- '2015-01-02'
|
39
|
+
- '2015-01-03'
|
40
|
+
- '2015-02-18'
|
41
|
+
- '2015-02-19'
|
42
|
+
- '2015-02-20'
|
43
|
+
- '2015-02-21'
|
44
|
+
- '2015-02-22'
|
45
|
+
- '2015-02-23'
|
46
|
+
- '2015-02-24'
|
47
|
+
- '2015-04-05'
|
48
|
+
- '2015-04-06'
|
49
|
+
- '2015-05-01'
|
50
|
+
- '2015-06-22'
|
51
|
+
- '2015-09-27'
|
52
|
+
- '2015-10-01'
|
53
|
+
- '2015-10-02'
|
54
|
+
- '2015-10-03'
|
55
|
+
- '2015-10-04'
|
56
|
+
- '2015-10-05'
|
57
|
+
- '2015-10-06'
|
58
|
+
- '2015-10-07'
|
59
|
+
- '2016-01-01'
|
60
|
+
- '2016-01-02'
|
61
|
+
- '2016-01-03'
|
62
|
+
- '2016-02-07'
|
63
|
+
- '2016-02-08'
|
64
|
+
- '2016-02-09'
|
65
|
+
- '2016-02-10'
|
66
|
+
- '2016-02-11'
|
67
|
+
- '2016-02-12'
|
68
|
+
- '2016-02-13'
|
69
|
+
- '2016-04-03'
|
70
|
+
- '2016-04-04'
|
71
|
+
- '2016-04-30'
|
72
|
+
- '2016-05-01'
|
73
|
+
- '2016-05-02'
|
74
|
+
- '2016-06-09'
|
75
|
+
- '2016-06-10'
|
76
|
+
- '2016-06-11'
|
77
|
+
- '2016-09-15'
|
78
|
+
- '2016-09-16'
|
79
|
+
- '2016-09-17'
|
80
|
+
- '2016-10-01'
|
81
|
+
- '2016-10-02'
|
82
|
+
- '2016-10-03'
|
83
|
+
- '2016-10-04'
|
84
|
+
- '2016-10-05'
|
85
|
+
- '2016-10-06'
|
86
|
+
- '2016-10-07'
|
87
|
+
- '2017-01-01'
|
88
|
+
- '2017-01-02'
|
89
|
+
- '2017-01-03'
|
90
|
+
- '2017-02-07'
|
91
|
+
- '2017-02-08'
|
92
|
+
- '2017-02-09'
|
93
|
+
- '2017-02-10'
|
94
|
+
- '2017-02-11'
|
95
|
+
- '2017-02-12'
|
96
|
+
- '2017-02-13'
|
97
|
+
- '2017-04-03'
|
98
|
+
- '2017-04-04'
|
99
|
+
- '2017-04-30'
|
100
|
+
- '2017-05-01'
|
101
|
+
- '2017-05-02'
|
102
|
+
- '2017-06-09'
|
103
|
+
- '2017-06-10'
|
104
|
+
- '2017-06-11'
|
105
|
+
- '2017-09-15'
|
106
|
+
- '2017-09-16'
|
107
|
+
- '2017-09-17'
|
108
|
+
- '2017-10-01'
|
109
|
+
- '2017-10-02'
|
110
|
+
- '2017-10-03'
|
111
|
+
- '2017-10-04'
|
112
|
+
- '2017-10-05'
|
113
|
+
- '2017-10-06'
|
114
|
+
- '2017-10-07'
|
115
|
+
additions_only: true
|
116
|
+
holiday_names: []
|
data/data/GB.yml
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# +additions_only+ will tell business_calendar to not attempt to fetch holidays from the underlying
|
2
|
+
# `holidays` gem, and instead only use the defined +additions+ here. Useful e.g. for cases where a
|
3
|
+
# country is not even defined in the `holidays` gem.
|
4
|
+
# Defaults to `false`
|
5
|
+
|
6
|
+
GB:
|
7
|
+
regions:
|
8
|
+
- gb
|
9
|
+
- gb_eng
|
10
|
+
holiday_names:
|
11
|
+
- Good Friday
|
12
|
+
- Easter Sunday
|
13
|
+
- Easter Monday
|
14
|
+
- May Day
|
15
|
+
- Bank Holiday
|
16
|
+
- Christmas Day
|
17
|
+
- Boxing Day
|
18
|
+
- New Year's Day
|
19
|
+
additions:
|
20
|
+
- '2002-06-04'
|
21
|
+
- '2011-04-29'
|
22
|
+
- '2012-06-04'
|
23
|
+
- '2012-06-05'
|
24
|
+
- '2012-09-22'
|
25
|
+
- '2012-09-23'
|
26
|
+
- '2015-12-26'
|
27
|
+
- '2016-12-25'
|
28
|
+
- '2017-01-01'
|
29
|
+
- '2020-12-26'
|
30
|
+
- '2021-12-25'
|
31
|
+
- '2021-12-26'
|
32
|
+
- '2022-01-01'
|
33
|
+
- '2022-12-25'
|
34
|
+
- '2023-01-01'
|
35
|
+
removals:
|
36
|
+
- '2002-05-28'
|
37
|
+
- '2007-04-08'
|
38
|
+
- '2008-03-23'
|
39
|
+
- '2009-04-12'
|
40
|
+
- '2010-04-04'
|
41
|
+
- '2011-04-24'
|
42
|
+
- '2012-04-08'
|
43
|
+
- '2012-05-28'
|
44
|
+
- '2013-03-31'
|
45
|
+
- '2014-04-20'
|
46
|
+
- '2015-12-28'
|
47
|
+
- '2016-12-27'
|
48
|
+
- '2017-01-02'
|
49
|
+
- '2020-12-28'
|
50
|
+
- '2021-12-27'
|
51
|
+
- '2021-12-28'
|
52
|
+
- '2022-01-03'
|
53
|
+
- '2022-12-27'
|
54
|
+
- '2023-01-02'
|
data/data/US.yml
ADDED
@@ -0,0 +1,236 @@
|
|
1
|
+
# +additions_only+ will tell business_calendar to not attempt to fetch holidays from the underlying
|
2
|
+
# `holidays` gem, and instead only use the defined +additions+ here. Useful e.g. for cases where a
|
3
|
+
# country is not even defined in the `holidays` gem.
|
4
|
+
# Defaults to `false`
|
5
|
+
|
6
|
+
US:
|
7
|
+
regions:
|
8
|
+
- us
|
9
|
+
holiday_names: []
|
10
|
+
additions_only: true
|
11
|
+
additions:
|
12
|
+
- '2004-01-01'
|
13
|
+
- '2004-01-19'
|
14
|
+
- '2004-02-16'
|
15
|
+
- '2004-05-31'
|
16
|
+
- '2004-07-05'
|
17
|
+
- '2004-09-06'
|
18
|
+
- '2004-10-11'
|
19
|
+
- '2004-11-11'
|
20
|
+
- '2004-11-25'
|
21
|
+
- '2004-12-25'
|
22
|
+
- '2005-01-01'
|
23
|
+
- '2005-01-17'
|
24
|
+
- '2005-02-21'
|
25
|
+
- '2005-05-30'
|
26
|
+
- '2005-07-04'
|
27
|
+
- '2005-09-05'
|
28
|
+
- '2005-10-10'
|
29
|
+
- '2005-11-11'
|
30
|
+
- '2005-11-24'
|
31
|
+
- '2005-12-26'
|
32
|
+
- '2006-01-02'
|
33
|
+
- '2006-01-16'
|
34
|
+
- '2006-02-20'
|
35
|
+
- '2006-05-29'
|
36
|
+
- '2006-07-04'
|
37
|
+
- '2006-09-04'
|
38
|
+
- '2006-10-09'
|
39
|
+
- '2006-11-11'
|
40
|
+
- '2006-11-23'
|
41
|
+
- '2006-12-25'
|
42
|
+
- '2007-01-01'
|
43
|
+
- '2007-01-15'
|
44
|
+
- '2007-02-19'
|
45
|
+
- '2007-05-28'
|
46
|
+
- '2007-07-04'
|
47
|
+
- '2007-09-03'
|
48
|
+
- '2007-10-08'
|
49
|
+
- '2007-11-12'
|
50
|
+
- '2007-11-22'
|
51
|
+
- '2007-12-25'
|
52
|
+
- '2008-01-01'
|
53
|
+
- '2008-01-21'
|
54
|
+
- '2008-02-18'
|
55
|
+
- '2008-05-26'
|
56
|
+
- '2008-07-04'
|
57
|
+
- '2008-09-01'
|
58
|
+
- '2008-10-13'
|
59
|
+
- '2008-11-11'
|
60
|
+
- '2008-11-27'
|
61
|
+
- '2008-12-25'
|
62
|
+
- '2009-01-01'
|
63
|
+
- '2009-01-19'
|
64
|
+
- '2009-02-16'
|
65
|
+
- '2009-05-25'
|
66
|
+
- '2009-09-07'
|
67
|
+
- '2009-10-12'
|
68
|
+
- '2009-11-11'
|
69
|
+
- '2009-11-26'
|
70
|
+
- '2009-12-25'
|
71
|
+
- '2010-01-01'
|
72
|
+
- '2010-01-18'
|
73
|
+
- '2010-02-15'
|
74
|
+
- '2010-05-31'
|
75
|
+
- '2010-07-05'
|
76
|
+
- '2010-09-06'
|
77
|
+
- '2010-10-11'
|
78
|
+
- '2010-11-11'
|
79
|
+
- '2010-11-25'
|
80
|
+
- '2010-12-25'
|
81
|
+
- '2011-01-01'
|
82
|
+
- '2011-01-17'
|
83
|
+
- '2011-02-21'
|
84
|
+
- '2011-05-30'
|
85
|
+
- '2011-07-04'
|
86
|
+
- '2011-09-05'
|
87
|
+
- '2011-10-10'
|
88
|
+
- '2011-11-11'
|
89
|
+
- '2011-11-24'
|
90
|
+
- '2011-12-26'
|
91
|
+
- '2012-01-02'
|
92
|
+
- '2012-01-16'
|
93
|
+
- '2012-02-20'
|
94
|
+
- '2012-05-28'
|
95
|
+
- '2012-07-04'
|
96
|
+
- '2012-09-03'
|
97
|
+
- '2012-10-08'
|
98
|
+
- '2012-11-12'
|
99
|
+
- '2012-11-22'
|
100
|
+
- '2012-12-25'
|
101
|
+
- '2013-01-01'
|
102
|
+
- '2013-01-21'
|
103
|
+
- '2013-02-18'
|
104
|
+
- '2013-05-27'
|
105
|
+
- '2013-07-04'
|
106
|
+
- '2013-09-02'
|
107
|
+
- '2013-10-14'
|
108
|
+
- '2013-11-11'
|
109
|
+
- '2013-11-28'
|
110
|
+
- '2013-12-25'
|
111
|
+
- '2014-01-01'
|
112
|
+
- '2014-01-20'
|
113
|
+
- '2014-02-17'
|
114
|
+
- '2014-05-26'
|
115
|
+
- '2014-07-04'
|
116
|
+
- '2014-09-01'
|
117
|
+
- '2014-10-13'
|
118
|
+
- '2014-11-11'
|
119
|
+
- '2014-11-27'
|
120
|
+
- '2014-12-25'
|
121
|
+
- '2015-01-01'
|
122
|
+
- '2015-01-19'
|
123
|
+
- '2015-02-16'
|
124
|
+
- '2015-05-25'
|
125
|
+
- '2015-07-04'
|
126
|
+
- '2015-09-07'
|
127
|
+
- '2015-10-12'
|
128
|
+
- '2015-11-11'
|
129
|
+
- '2015-11-26'
|
130
|
+
- '2015-12-25'
|
131
|
+
- '2016-01-01'
|
132
|
+
- '2016-01-18'
|
133
|
+
- '2016-02-15'
|
134
|
+
- '2016-05-30'
|
135
|
+
- '2016-07-04'
|
136
|
+
- '2016-09-05'
|
137
|
+
- '2016-10-10'
|
138
|
+
- '2016-11-11'
|
139
|
+
- '2016-11-24'
|
140
|
+
- '2016-12-25'
|
141
|
+
- '2016-12-26'
|
142
|
+
- '2017-01-01'
|
143
|
+
- '2017-01-02'
|
144
|
+
- '2017-01-16'
|
145
|
+
- '2017-02-20'
|
146
|
+
- '2017-05-29'
|
147
|
+
- '2017-07-04'
|
148
|
+
- '2017-09-04'
|
149
|
+
- '2017-10-09'
|
150
|
+
- '2017-11-11'
|
151
|
+
- '2017-11-23'
|
152
|
+
- '2017-12-25'
|
153
|
+
- '2018-01-01'
|
154
|
+
- '2018-01-15'
|
155
|
+
- '2018-02-19'
|
156
|
+
- '2018-05-28'
|
157
|
+
- '2018-07-04'
|
158
|
+
- '2018-09-03'
|
159
|
+
- '2018-10-08'
|
160
|
+
- '2018-11-11'
|
161
|
+
- '2018-11-12'
|
162
|
+
- '2018-11-22'
|
163
|
+
- '2018-12-25'
|
164
|
+
- '2019-01-01'
|
165
|
+
- '2019-01-21'
|
166
|
+
- '2019-02-18'
|
167
|
+
- '2019-05-27'
|
168
|
+
- '2019-07-04'
|
169
|
+
- '2019-09-02'
|
170
|
+
- '2019-10-14'
|
171
|
+
- '2019-11-11'
|
172
|
+
- '2019-11-28'
|
173
|
+
- '2019-12-25'
|
174
|
+
- '2020-01-01'
|
175
|
+
- '2020-01-20'
|
176
|
+
- '2020-02-17'
|
177
|
+
- '2020-05-25'
|
178
|
+
- '2020-07-04'
|
179
|
+
- '2020-09-07'
|
180
|
+
- '2020-10-12'
|
181
|
+
- '2020-11-11'
|
182
|
+
- '2020-11-26'
|
183
|
+
- '2020-12-25'
|
184
|
+
- '2021-01-01'
|
185
|
+
- '2021-01-18'
|
186
|
+
- '2021-02-15'
|
187
|
+
- '2021-05-31'
|
188
|
+
- '2021-07-04'
|
189
|
+
- '2021-07-05'
|
190
|
+
- '2021-09-06'
|
191
|
+
- '2021-10-11'
|
192
|
+
- '2021-11-11'
|
193
|
+
- '2021-11-25'
|
194
|
+
- '2021-12-25'
|
195
|
+
- '2022-01-01'
|
196
|
+
- '2022-01-17'
|
197
|
+
- '2022-02-21'
|
198
|
+
- '2022-05-30'
|
199
|
+
- '2022-07-04'
|
200
|
+
- '2022-09-05'
|
201
|
+
- '2022-10-10'
|
202
|
+
- '2022-11-11'
|
203
|
+
- '2022-11-24'
|
204
|
+
- '2022-12-25'
|
205
|
+
- '2022-12-26'
|
206
|
+
- '2023-01-01'
|
207
|
+
- '2023-01-02'
|
208
|
+
- '2023-01-16'
|
209
|
+
- '2023-02-20'
|
210
|
+
- '2023-05-29'
|
211
|
+
- '2023-07-04'
|
212
|
+
- '2023-09-04'
|
213
|
+
- '2023-10-09'
|
214
|
+
- '2023-11-11'
|
215
|
+
- '2023-11-23'
|
216
|
+
- '2023-12-25'
|
217
|
+
- '2024-01-01'
|
218
|
+
- '2024-01-15'
|
219
|
+
- '2024-02-19'
|
220
|
+
- '2024-05-27'
|
221
|
+
- '2024-07-04'
|
222
|
+
- '2024-09-02'
|
223
|
+
- '2024-10-14'
|
224
|
+
- '2024-11-11'
|
225
|
+
- '2024-11-28'
|
226
|
+
- '2024-12-25'
|
227
|
+
- '2025-01-01'
|
228
|
+
- '2025-01-20'
|
229
|
+
- '2025-02-17'
|
230
|
+
- '2025-05-26'
|
231
|
+
- '2025-07-04'
|
232
|
+
- '2025-09-01'
|
233
|
+
- '2025-10-13'
|
234
|
+
- '2025-11-11'
|
235
|
+
- '2025-11-27'
|
236
|
+
- '2025-12-25'
|
@@ -10,6 +10,7 @@ class BusinessCalendar::Calendar
|
|
10
10
|
# @param [Date] date
|
11
11
|
# @return [Boolean] Whether or not this calendar's list of holidays includes <date>.
|
12
12
|
def is_holiday?(date)
|
13
|
+
date = date.send(:to_date) if date.respond_to?(:to_date, true)
|
13
14
|
holiday_determiner.call(date)
|
14
15
|
end
|
15
16
|
|
@@ -36,7 +37,7 @@ class BusinessCalendar::Calendar
|
|
36
37
|
|
37
38
|
with_one_or_many(date_or_dates) do |date|
|
38
39
|
start = nearest_business_day(date, initial_direction)
|
39
|
-
num.times.reduce(start) { |d| following_business_day(d) }
|
40
|
+
num.times.reduce(start) { |d, _| following_business_day(d) }
|
40
41
|
end
|
41
42
|
end
|
42
43
|
alias :add_business_day :add_business_days
|
@@ -50,7 +51,7 @@ class BusinessCalendar::Calendar
|
|
50
51
|
return add_business_days(date_or_dates, -num) if num < 0
|
51
52
|
|
52
53
|
with_one_or_many(date_or_dates) do |date|
|
53
|
-
num.times.reduce(date) { |d| preceding_business_day(d) }
|
54
|
+
num.times.reduce(date) { |d, _| preceding_business_day(d) }
|
54
55
|
end
|
55
56
|
end
|
56
57
|
alias :subtract_business_day :subtract_business_days
|
@@ -62,6 +63,7 @@ class BusinessCalendar::Calendar
|
|
62
63
|
begin
|
63
64
|
date = date - 1
|
64
65
|
end until is_business_day? date
|
66
|
+
|
65
67
|
date
|
66
68
|
end
|
67
69
|
end
|
@@ -84,6 +86,7 @@ class BusinessCalendar::Calendar
|
|
84
86
|
raise ArgumentError, "Invalid direction supplied: '#{direction}' should instead be :forward or :backward"
|
85
87
|
end
|
86
88
|
end
|
89
|
+
|
87
90
|
date
|
88
91
|
end
|
89
92
|
end
|
@@ -17,9 +17,8 @@ class BusinessCalendar::HolidayDeterminer
|
|
17
17
|
elsif removals.include? date
|
18
18
|
false
|
19
19
|
elsif !additions_only
|
20
|
-
Holidays.between(date, date, @regions, :observed)
|
21
|
-
|
22
|
-
.size > 0
|
20
|
+
Holidays.between(date, date, @regions, :observed).
|
21
|
+
any? { |h| @holiday_names.include? h[:name] }
|
23
22
|
end
|
24
23
|
end
|
25
24
|
end
|