Skip to content

Commit 814026a

Browse files
authoredSep 30, 2018
Merge pull request #79 from ppeble/issue-24
Issue-24: add tests to ensure coverage on all methods
2 parents a1d3c41 + 90402fa commit 814026a

33 files changed

+396
-158
lines changed
 

‎CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Holiday definitions
22

3+
## 3.0.0
4+
5+
Major semver bump as the format for custom methods has been changed to complete [issue-24](https://github.com/holidays/definitions/issues/24). Downstream consumers will need to update to be able to parse them. However there are **no behavior changes** with this update.
6+
7+
In summary: we have switched to language-specific custom methods. Instead of a plain `source` field you will need a specific language implementation, e.g. `ruby`, `golang`, etc.
8+
9+
Currently we only have `ruby` but we can now expand these definitions for use in other languages. Please see the [custom methods ADR](doc/architecture/adr-001.md) for more in-depth information on why this change was made.
10+
11+
You can also view the updated ['Methods' section in the SYNTAX doc](doc/SYNTAX.md#methods) for more info and examples.
12+
313
## 2.5.3
414

515
* Add missing `observed` logic for 'St. Patricks Day' in `gb_nir`

‎METHODS.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
methods:
3+
easter:
4+
arguments: year
5+
orthodox_easter:
6+
arguments: year
7+
orthodox_easter_julian:
8+
arguments: year
9+
to_monday_if_sunday:
10+
arguments: date
11+
to_monday_if_weekend:
12+
arguments: date
13+
to_weekday_if_boxing_weekend:
14+
arguments: date
15+
to_weekday_if_boxing_weekend_from_year:
16+
arguments: year
17+
to_weekday_if_weekend:
18+
arguments: date
19+
calculate_day_of_month:
20+
arguments: year, month, day, wday
21+
to_weekday_if_boxing_weekend_from_year_or_to_tuesday_if_monday:
22+
arguments: year
23+
to_tuesday_if_sunday_or_monday_if_saturday:
24+
arguments: date
25+
lunar_to_solar:
26+
arguments: year, month, day, region

‎README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ Currently it is only used by the [existing Holidays gem](https://github.com/holi
77
definitions and generates ruby classes for use in that gem. In the future it will be used by other languages in
88
a similar manner.
99

10-
*Please note* that this is *not* a gem. The validation process is written in ruby simply for convenience. The real
10+
**Please note** that this is _not_ a gem. The validation process is written in ruby simply for convenience. The real
1111
stars of this show are the YAML files.
1212

13-
### Syntax
13+
### Documentation
1414

15-
The definition syntax is a custom format developed over the life of this project. Please see
16-
[our syntax doc](SYNTAX.md) for more information on how to format definitions.
17-
18-
### How to contribute
19-
20-
See our [contribution guidelines](CONTRIBUTING.md) for information on how to help out!
15+
1. [Syntax Guide](doc/SYNTAX.md)
16+
2. [Contribution Guidelines](doc/CONTRIBUTING.md)
17+
3. [Maintainer Guidelines](doc/MAINTAINERS.md)
18+
4. [Architecture Decision Records](doc/architecture/README.md)
2119

2220
### Credits
2321

‎ar.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ months:
7272
- name: Navidad
7373
regions: [ar]
7474
mday: 25
75+
7576
tests:
7677
- given:
7778
date: '2016-01-01'

‎at.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ months:
5757
- name: 2. Weihnachtstag
5858
regions: [at]
5959
mday: 26
60+
6061
tests:
6162
- given:
6263
date: '2009-01-01'
@@ -67,19 +68,16 @@ tests:
6768
- given:
6869
date: '2009-04-13'
6970
regions: ['at']
70-
options: 'informal'
7171
expect:
7272
name: 'Ostermontag'
7373
- given:
7474
date: '2009-05-21'
7575
regions: ['at']
76-
options: 'informal'
7776
expect:
7877
name: 'Christi Himmelfahrt'
7978
- given:
8079
date: '2009-06-01'
8180
regions: ['at']
82-
options: 'informal'
8381
expect:
8482
name: 'Pfingstmontag'
8583
- given:
@@ -111,3 +109,8 @@ tests:
111109
regions: ['at']
112110
expect:
113111
holiday: false
112+
- given:
113+
date: '2017-06-15'
114+
regions: ['at']
115+
expect:
116+
name: "Fronleichnam"

‎au.yaml

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Australian holiday definitions for the Ruby Holiday gem.
2-
# Updated: 2008-11-29.
2+
# Updated: 2018-08-30
33
# Sources:
44
# - http://en.wikipedia.org/wiki/Australian_public_holidays
55
# - http://www.docep.wa.gov.au/lr/LabourRelations/Content/Wages%20and%20Conditions/Public%20Holidays/Public_Holidays.html
@@ -178,7 +178,7 @@ months:
178178
methods:
179179
afl_grand_final:
180180
arguments: year
181-
source: |
181+
ruby: |
182182
case year
183183
when 2015
184184
Date.civil(2015, 10, 2)
@@ -192,7 +192,7 @@ methods:
192192
# celebrated twice in 2012
193193
# in october again from 2016
194194
arguments: year
195-
source: |
195+
ruby: |
196196
if year >= 2016
197197
Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 1, 1)
198198
elsif year == 2012
@@ -204,44 +204,44 @@ methods:
204204
# http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
205205
# in june until 2015
206206
arguments: year
207-
source: |
207+
ruby: |
208208
if year <= 2015
209209
Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 6, 2, 1)
210210
end
211211
qld_labour_day_may:
212212
# http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
213213
# for 2013 to 2016 it was in October, otherwise it's in May
214214
arguments: year
215-
source: |
215+
ruby: |
216216
if year < 2013 || year >= 2016
217217
Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 5, 1, 1)
218218
end
219219
qld_labour_day_october:
220220
# http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
221221
# for 2013 to 2016 it was in October, otherwise it's in May
222222
arguments: year
223-
source: |
223+
ruby: |
224224
if year >= 2013 && year < 2016
225225
Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 1, 1)
226226
end
227227
g20_day_2014_only:
228228
# http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
229229
# G20 day in brisbane, in 2014, on november 14
230230
arguments: year
231-
source: |
231+
ruby: |
232232
year == 2014 ? 14 : nil
233233
hobart_show_day:
234234
# http://worksafe.tas.gov.au/__data/assets/pdf_file/0008/287036/Public_Holidays_2014.pdf
235235
# The Thursday before the fourth Saturday in October.
236236
arguments: year
237-
source: |
237+
ruby: |
238238
fourth_sat_in_oct = Date.civil(year, 10, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 4, :saturday))
239239
fourth_sat_in_oct - 2 # the thursday before
240240
march_pub_hol_sa:
241241
# http://www.safework.sa.gov.au/show_page.jsp?id=2483#.VQ9Mfmb8-8E
242242
# The Holidays Act 1910 provides for the third Monday in May to be a public holiday. Since 2006 this public holiday has been observed on the second Monday in March through the issuing of a special Proclamation by the Governor.
243243
arguments: year
244-
source: |
244+
ruby: |
245245
if year < 2006
246246
nil
247247
else
@@ -251,14 +251,29 @@ methods:
251251
# http://www.safework.sa.gov.au/show_page.jsp?id=2483#.VQ9Mfmb8-8E
252252
# The Holidays Act 1910 provides for the third Monday in May to be a public holiday. Since 2006 this public holiday has been observed on the second Monday in March through the issuing of a special Proclamation by the Governor.
253253
arguments: year
254-
source: |
254+
ruby: |
255255
if year >= 2006
256256
nil
257257
else
258258
Date.civil(year, 5, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 5, :third, :monday))
259259
end
260260
261261
tests:
262+
- given:
263+
date: "2017-04-14"
264+
regions: ["au"]
265+
expect:
266+
name: "Good Friday"
267+
- given:
268+
date: "2017-04-15"
269+
regions: ["au_nsw"]
270+
expect:
271+
name: "Easter Saturday"
272+
- given:
273+
date: ['2010-4-4', "2017-04-16"]
274+
regions: ["au_nsw"]
275+
expect:
276+
name: "Easter Sunday"
262277
- given:
263278
date: '2013-10-07'
264279
regions: ["au_qld"]
@@ -713,8 +728,18 @@ tests:
713728
regions: ["au_tas"]
714729
expect:
715730
name: "New Year's Day"
731+
- given:
732+
date: '2016-03-27'
733+
regions: ["au_qld"]
734+
expect:
735+
holiday: false
716736
- given:
717737
date: '2017-04-16'
718738
regions: ["au_qld"]
719739
expect:
720740
name: "Easter Sunday"
741+
- given:
742+
date: "2014-11-14"
743+
regions: ["au_qld_brisbane"]
744+
expect:
745+
name: "G20 Day"

‎be_fr.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,28 @@ tests:
126126
options: ["informal"]
127127
expect:
128128
name: 'Noël'
129+
- given:
130+
date: '2017-4-16'
131+
regions: ['be_fr']
132+
expect:
133+
name: 'Pâques'
134+
- given:
135+
date: '2017-4-17'
136+
regions: ['be_fr']
137+
expect:
138+
name: 'Lundi de Pâques'
139+
- given:
140+
date: '2017-5-25'
141+
regions: ['be_fr']
142+
expect:
143+
name: 'Ascension'
144+
- given:
145+
date: '2017-6-4'
146+
regions: ['be_fr']
147+
expect:
148+
name: 'Pentecôte'
149+
- given:
150+
date: '2017-6-5'
151+
regions: ['be_fr']
152+
expect:
153+
name: 'Lundi de Pentecôte'

‎be_nl.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,28 @@ tests:
126126
options: ["informal"]
127127
expect:
128128
name: 'Kerstmis'
129+
- given:
130+
date: '2017-4-16'
131+
regions: ['be_nl']
132+
expect:
133+
name: 'Pasen'
134+
- given:
135+
date: '2017-4-17'
136+
regions: ['be_nl']
137+
expect:
138+
name: 'Paasmaandag'
139+
- given:
140+
date: '2017-5-25'
141+
regions: ['be_nl']
142+
expect:
143+
name: 'O.H. Hemelvaart'
144+
- given:
145+
date: '2017-6-4'
146+
regions: ['be_nl']
147+
expect:
148+
name: 'Pinksteren'
149+
- given:
150+
date: '2017-6-5'
151+
regions: ['be_nl']
152+
expect:
153+
name: 'Pinkstermaandag'

‎ca.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ months:
106106
regions: [ca_yt]
107107
mday: 21
108108
year_ranges:
109-
- after: 2017
109+
- after: 2017
110110
7:
111111
- name: Canada Day
112112
regions: [ca]
@@ -184,11 +184,12 @@ months:
184184
mday: 26
185185
observed: to_weekday_if_boxing_weekend(date)
186186
type: informal
187+
187188
methods:
188189
ca_victoria_day:
189190
# Monday on or before May 24
190191
arguments: year
191-
source: |
192+
ruby: |
192193
date = Date.civil(year,5,24)
193194
if date.wday > 1
194195
date -= (date.wday - 1)

‎ch.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,12 @@ months:
125125
- name: Restauration de la République
126126
regions: [ch_ge]
127127
mday: 31
128+
128129
methods:
129130
ch_vd_lundi_du_jeune_federal:
130131
# Monday after the third Sunday of September
131132
arguments: year
132-
source: |
133+
ruby: |
133134
date = Date.civil(year,9,1)
134135
# Find the first Sunday of September
135136
until date.wday.eql? 0 do
@@ -141,7 +142,7 @@ methods:
141142
ch_ge_jeune_genevois:
142143
# Thursday after the first Sunday of September
143144
arguments: year
144-
source: |
145+
ruby: |
145146
date = Date.civil(year,9,1)
146147
# Find the first Sunday of September
147148
until date.wday.eql? 0 do
@@ -152,7 +153,7 @@ methods:
152153
ch_gl_naefelser_fahrt:
153154
# First Thursday of April. If the first Thursday of April is in the week before easter, then a week later.
154155
arguments: year
155-
source: |
156+
ruby: |
156157
date = Date.civil(year,4,1)
157158
# Find the first Thursday of April
158159
until date.wday.eql? 4 do

0 commit comments

Comments
 (0)
Please sign in to comment.