holidays 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/README.md +18 -9
  4. data/definitions/README.md +174 -0
  5. data/definitions/ar.yaml +37 -27
  6. data/definitions/au.yaml +73 -13
  7. data/definitions/{be.yaml → be_fr.yaml} +15 -15
  8. data/definitions/be_nl.yaml +65 -0
  9. data/definitions/cz.yaml +7 -4
  10. data/definitions/de.yaml +80 -10
  11. data/definitions/index.yaml +3 -2
  12. data/definitions/jp.yaml +20 -3
  13. data/definitions/nl.yaml +2 -1
  14. data/definitions/nz.yaml +0 -3
  15. data/lib/generated_definitions/MANIFEST +2 -0
  16. data/lib/generated_definitions/REGIONS.rb +1 -1
  17. data/lib/generated_definitions/ar.rb +9 -6
  18. data/lib/generated_definitions/au.rb +33 -9
  19. data/lib/generated_definitions/be_fr.rb +40 -0
  20. data/lib/generated_definitions/be_nl.rb +40 -0
  21. data/lib/generated_definitions/de.rb +14 -5
  22. data/lib/generated_definitions/europe.rb +37 -16
  23. data/lib/generated_definitions/jp.rb +3 -2
  24. data/lib/generated_definitions/nl.rb +1 -1
  25. data/lib/generated_definitions/nz.rb +0 -1
  26. data/lib/holidays.rb +12 -0
  27. data/lib/holidays/date_calculator/easter.rb +9 -9
  28. data/lib/holidays/date_calculator/weekend_modifier.rb +25 -4
  29. data/lib/holidays/definition/context/generator.rb +1 -1
  30. data/lib/holidays/definition/repository/holidays_by_month.rb +1 -1
  31. data/lib/holidays/option/context/parse_options.rb +1 -1
  32. data/lib/holidays/version.rb +1 -1
  33. data/test/defs/test_defs_ar.rb +18 -14
  34. data/test/defs/test_defs_au.rb +29 -2
  35. data/test/defs/{test_defs_be.rb → test_defs_be_fr.rb} +5 -4
  36. data/test/defs/test_defs_be_nl.rb +26 -0
  37. data/test/defs/test_defs_de.rb +25 -4
  38. data/test/defs/test_defs_europe.rb +44 -6
  39. data/test/defs/test_defs_jp.rb +8 -0
  40. data/test/holidays/date_calculator/test_weekend_modifier.rb +10 -0
  41. data/test/test_all_regions.rb +1 -1
  42. metadata +11 -6
  43. data/definitions/SYNTAX.rdoc +0 -111
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 371634066d0abbf2aa11ace0e06461808a38a69a
4
- data.tar.gz: 2abd58ba908382b7b3c2a265c41d7a48652332ed
3
+ metadata.gz: 314e234058d757423c0e873ac27f9ce001a54fa0
4
+ data.tar.gz: f827b9614cd1037c20153fa2b316d000b784e2f4
5
5
  SHA512:
6
- metadata.gz: 03b8ea83d6100f4308ac35dbc01c0eeaefa75dc6263457457fa12e6cd6bf5a3000aedc570bc841d0c4357abffad09e796cd622957dcd5256ae92630f8ebdef0f
7
- data.tar.gz: d893607cb825d6f73c020bad7dff40dec30f032fa0e4c6ab9d6524d3e7b9bafd8111f0c397410ab5676e01b0395434db0b12b7f8a1413f6d1b2d45f58e4ba90f
6
+ metadata.gz: 3fbe210da7f49b7e8c5d5693e230ee2b5bb46190656be2c99bd28f795bc9e8e8ede109e699ebd87ed7b024ca76cfa6cc34220d2853603296700c8feaf3e95562
7
+ data.tar.gz: 66f1d44e7a7fc1c10b84f959dccc5c0710a10f802d0ee9bcdd8b74e7bf526d3be95ee1c36dc4dd2a756086bc3753218d7b87b6f8c872cc252e5cf8ba4e04c21e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Ruby Holidays Gem CHANGELOG
2
2
 
3
+ ## 3.3.0
4
+
5
+ This is the final minor point release in v3.X.X. I am releasing it so that all of the latest definitions can be
6
+ used by anyone that is not ready to jump to version 4.0.0. I am not planning on supporting this version unless a major
7
+ issue is found that needs to be immediately addressed.
8
+
9
+ * Update public holidays for Argentina (https://github.com/schmierkov)
10
+ * Remove redundant `require` from weekend modifier (https://github.com/Eric-Guo)
11
+ * FIX: Easter Saturday not a holiday in NZ (https://github.com/ghiculescu)
12
+ * FIX: Japan 'Marine Day' for 1996-2002 year ranges (https://github.com/shuhei)
13
+ * FIX: Australia calculations for Christmas and Boxing (https://github.com/ghiculescu)
14
+ * Add dutch language version of definitions for Belgium (michael.cox@novalex.be)
15
+ * Make 'Goede Vrijdag' informal for NL definitions (https://github.com/MathijsK93)
16
+ * Add 'Great Friday' to Czech holidays (juris@uol.cz)
17
+ * Add new informal holidays for Germany (https://github.com/knut2)
18
+ * FIX: correctly check for new `year_range` attribute in holidays by month repository (https://github.com/knut2)
19
+ * Add DE-Reformationstag for 2017 (https://github.com/knut2)
20
+ * Update Australia QLD definition Queens Bday and Labour Day (https://github.com/ghiculescu)
21
+
3
22
  ## 3.2.0
4
23
 
5
24
  * add 'valid year' functionality to definitions - https://github.com/holidays/holidays/issues/33 - (thanks to https://github.com/ttwo32)
data/README.md CHANGED
@@ -14,14 +14,12 @@ To install the gem from RubyGems:
14
14
 
15
15
  The Holidays gem is tested on Ruby 2.0.0, 2.1.0, 2.2.0, 2.3.0 and JRuby.
16
16
 
17
+ The Holidays gem follows [semantic versioning](http://semver.org/). Please take this into account when relying on this gem as a dependency.
18
+
17
19
  ## Time zones
18
20
 
19
21
  Time zones are ignored. This library assumes that all dates are within the same time zone.
20
22
 
21
- ## Examples
22
-
23
- For more information, see the notes at the top of the Holidays module.
24
-
25
23
  ### Using the Holidays class
26
24
 
27
25
  Get all holidays on April 25, 2008 in Australia.
@@ -120,15 +118,26 @@ See the [original pull request](https://github.com/alexdunae/holidays/pull/36) f
120
118
 
121
119
  ### How to contribute
122
120
 
123
- To make changes to any of the definitions, edit the YAML files under the 'definitions' directory only. These YAML files are read by the 'generate' rake target and the final definition files are created automatically. Don't directly edit any other files.
121
+ #### For definition updates
122
+
123
+ * Edit desired definition YAML file(s) located under `definitions/`. If you are adding a new region be sure to update `definitions/index.yaml` as well
124
+ * Run `bundle exec rake generate` to generate updated final definitions (they will be located under `lib/generated_definitions/`)
125
+ * Run `bundle exec rake test` to ensure your changes did not introduce errors
126
+ * Open a PR with *all* of these changes. You *MUST* include the generated definition files in your PR. There is no automatic process to generated definitions at this time
127
+
128
+ Including documentation with your updates is very much appreciated. A simple Wikipedia entry or government link in the comments alongside your changes would be perfect.
129
+
130
+ Lastly, note that there are many 'meta' regions. For example, there are regions for Europe, Scandinavia, and North America. If your new region(s) falls into these areas consider adding them. You can find these 'meta' regions in `definitions/index.yaml`.
124
131
 
125
- Tests are also allowed at the end of the YAML files. Please add tests. PRs will not be accepted unless there are tests proving that the new definitions work.
132
+ #### For non-definition functionality
126
133
 
127
- After you're satisfied with the YAML file if you have added a brand-new region you must edit the index.yaml file to include the new region. Then run `rake generate`, which will generate the Ruby files that make up the actual code as well as the tests. Then run `rake test`. If that passes then add all of the changed files to a commit and open a pull request.
134
+ * Fork the repository
135
+ * Make your changes
136
+ * Create a PR pointing back to `master`
128
137
 
129
- It is also very appreciated if documentation is attached to the pull request. A simple Wikipedia or government link referencing the change would be perfect.
138
+ Don't worry about versioning, we'll handle it on our end.
130
139
 
131
- If you wish to test out your changes via irb you can run `bin/console`. This will load all required lib files and open an irb session.
140
+ Tests are required. If your PR results in lower test coverage then it will not be accepted.
132
141
 
133
142
  ### Credits and code
134
143
 
@@ -0,0 +1,174 @@
1
+ # Holiday Gem Definition Syntax
2
+
3
+ All holidays are defined in YAML files in the `definitions/` directory. These definition files have three main top-level properties:
4
+
5
+ * `months` - this is the meat! All definitions for months 1-12 are defined here
6
+ * `methods` - this contains any custom logic that your definitions require
7
+ * `tests` - this contains the tests for your definitions
8
+
9
+ The `months` property is required. The two other properties are not strictly required but are almost always used.
10
+
11
+ In fact, if you leave out `tests` your PR will probably not be accepted unless there is a very, very good reason for leaving it out.
12
+
13
+ ## Key Words
14
+
15
+ There are some terms that you should be familiar with before we dive into each section:
16
+
17
+ #### `region`
18
+
19
+ A region is a symbol that denotes the geographic or cultural region for that holiday. In general these symbols will be the [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166) code for a country or region.
20
+
21
+ Please note that before version v1.1.0 the compliance with ISO 3166 was not as strict. There might be cases where an existing region symbol does not match the standard.
22
+
23
+ In addition, some sub-regions do not have a matching ISO 3116 entry. In those cases we attempt to choose symbols that are reasonably clear.
24
+
25
+ Examples: `:us` for USA, `:fr` for France, `:us_dc` for Washington, D.C in USA
26
+
27
+ #### `formal`/`informal`
28
+
29
+ We consider `formal` dates as government-defined holidays. These could be the kinds of holidays where everyone stays home from work or perhaps are bank holidays but it is *not required* for a holiday to have these features to be considered formal.
30
+
31
+ `Informal` holidays are holidays that everyone knows about but aren't enshrined in law. For example, Valentine's Day in the US is considered an informal holiday.
32
+
33
+ We recognize that these definitions can be highly subjective. If you disagree with the current status of a holiday please open an issue so we can discuss it.
34
+
35
+ #### `observed`
36
+
37
+ There are certain holidays that can be legally observed on different days than they occur. For example, if a holiday falls on a Saturday but it is legally observed on the following Monday then you can define it as `observed` on the Monday. Please see the section below for more details and examples.
38
+
39
+ ## Months
40
+
41
+ Holidays are grouped by month from 1 through 12. Each entry within a month can have several properties depending on the behavior of the holiday. Each section below lays out the various different ways you can define your holiday.
42
+
43
+ The two required properties are:
44
+
45
+ * `name` - The name of the holiday
46
+ * `regions` - One or more region codes (targeted to match [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166))
47
+
48
+ ### Dates defined by a fixed date (e.g. January 1st)
49
+
50
+ * `mday` - A non-negative integer representing day of the month (1 through 31).
51
+
52
+ For example, the following holiday is on the first of January and available in the `:ca`, `:us` and `:au` regions:
53
+
54
+ ```
55
+ 1:
56
+ - name: New Year's Day
57
+ regions: [ca, us, au]
58
+ mday: 1
59
+ ```
60
+
61
+ ### Dates defined by a week number (e.g. first Monday of a month)
62
+
63
+ * `wday` - A non-negative integer representing day of the week (0 = Sunday through 6 = Saturday).
64
+ * `week` - A non-negative integer representing week number (1 = first week, 3 = third week, -1 = last week),
65
+
66
+ For example, the following holiday is on the first Monday of September and available in the `:ca` region:
67
+
68
+ ```
69
+ 9:
70
+ - name: Labour Day
71
+ regions: [ca]
72
+ week: 1
73
+ wday: 1
74
+ ```
75
+
76
+ ## Methods
77
+
78
+ In addition to defining holidays by day or week, you can create custom methods to calculate a date. These should be placed under the `methods` property. Methods named in this way can then be referenced by entries in the `months` property.
79
+
80
+ For example, Canada celebrates Victoria Day, which falls on the Monday on or before May 24. So, under the `methods` property we create a custom method that returns a Date object.
81
+
82
+ ```
83
+ methods:
84
+ ca_victoria_day: |
85
+ def self.ca_victoria_day(year)
86
+ date = Date.civil(year,5,24)
87
+ if date.wday > 1
88
+ date -= (date.wday - 1)
89
+ elsif date.wday == 0
90
+ date -= 6
91
+ end
92
+ date
93
+ end
94
+ ```
95
+
96
+ This would be represented in `months` entry as:
97
+
98
+ ```
99
+ 5:
100
+ - name: Victoria Day
101
+ regions: [ca]
102
+ function: ca_victoria_day(year)
103
+ ```
104
+
105
+ If a holiday can occur in different months (e.g. Easter) it can go in the '0' month.
106
+
107
+ ```
108
+ 0:
109
+ - name: Easter Monday
110
+ regions: [ca]
111
+ function: easter(year)+1
112
+ ```
113
+
114
+ There are pre-existing methods for highly-used calculations. They are:
115
+
116
+ * `easter(year)` - calculates Easter via Gregorian calendar for a given year
117
+ * `orthodox_easter(year)` - calculates Easter via Julian calendar for a given year
118
+ * `to_monday_if_sunday(date)` - returns date of the following Monday if the 'date' argument falls on a Sunday
119
+ * `to_monday_if_weekend(date)` - returns date of the following Monday if the 'date' argument falls on a weekend (Saturday or Sunday)
120
+ * `to_weekday_if_boxing_weekend(date)` - returns nearest following weekday if the 'date' argument falls on Boxing Day
121
+ * `to_weekday_if_boxing_weekend_from_year(year)` - calculates nearest weekday following Boxing weekend for given year
122
+ * `to_weekday_if_weekend(date)` - returns nearest weekday (Monday or Friday) if 'date' argument falls on a weekend (Saturday or Sunday)
123
+
124
+ *Protip*: you can use the `easter` methods to calculate all of the dates that are based around Easter. It's especially useful to use since the Easter calculation is complex. For example, 'Good Friday' in the US is 2 days before Easter. Therefore you could do the following:
125
+
126
+ ```
127
+ 0:
128
+ - name: Good Friday
129
+ regions: [us]
130
+ function: easter(year)-2
131
+ type: informal
132
+ ```
133
+
134
+ ### Calculating observed dates
135
+
136
+ Users can specify that this gem only return holidays on their 'observed' day. This can be especially useful if they are using this gem for business-related logic. If you wish for your definitions to allow for this then you can add the `observed` property to your entry. This requires a method to help calculate the observed day.
137
+
138
+ Several built-in methods are available for holidays that are observed on varying dates. For example, for a holiday that is observed on Monday if it falls on a weekend you could write:
139
+
140
+ ```
141
+ 7:
142
+ - name: Canada Day
143
+ regions: [ca]
144
+ mday: 1
145
+ observed: to_monday_if_weekend(date)
146
+ ```
147
+
148
+ If a user does not specify `observed` when calling the gem then 1/1 will be the date found for 'Canada Day', regardless of whether it falls on a Saturday or Sunday. If a user specifies 'observed' then it will show as the following Monday if the date falls on a Saturday or Sunday.
149
+
150
+ ## Tests
151
+
152
+ All definition files should have tests included. In the YAML file, tests are just a block of Ruby code:
153
+
154
+ ```
155
+ tests: |
156
+ {Date.civil(2008,1,1) => 'New Year\'s Day',
157
+ Date.civil(2008,3,21) => 'Good Friday',
158
+ Date.civil(2008,3,24) => 'Easter Monday',
159
+ Date.civil(2008,9,1) => 'Labour Day',
160
+ Date.civil(2008,12,25) => 'Christmas Day',
161
+ Date.civil(2008,12,26) => 'Boxing Day'}.each do |date, name|
162
+ assert_equal name, (Holidays.on(date, :ca, :informal)[0] || {})[:name]
163
+ end
164
+
165
+ # Victoria Day
166
+ [Date.civil(2004,5,24), Date.civil(2005,5,23), Date.civil(2006,5,22),
167
+ Date.civil(2007,5,21), Date.civil(2008,5,19)].each do |date|
168
+ assert_equal 'Victoria Day', Holidays.on(date, :ca)[0][:name]
169
+ end
170
+ ```
171
+
172
+ These tests will be picked up by the `generate` process and written into actual Test::Unit tests that are run when a user executes the test suite.
173
+
174
+ Please please please include tests. Your PR won't be accepted if tests are not included with your changes.
data/definitions/ar.yaml CHANGED
@@ -1,16 +1,13 @@
1
1
  # Argentinian holiday definitions for the Ruby Holiday gem.
2
2
  #
3
- # Updated: 2013-10-17.
3
+ # Updated: 2016-02-26.
4
4
  #
5
5
  # Sources:
6
6
  # - http://en.wikipedia.org/wiki/Public_holidays_in_Argentina
7
- #
7
+ # - http://servicios.lanacion.com.ar/feriados/2016
8
8
  ---
9
9
  months:
10
10
  0:
11
- - name: Jueves Santo
12
- regions: [ar]
13
- function: easter(year)-3
14
11
  - name: Viernes Santo
15
12
  regions: [ar]
16
13
  function: easter(year)-2
@@ -18,6 +15,13 @@ months:
18
15
  - name: Año Nuevo
19
16
  regions: [ar]
20
17
  mday: 1
18
+ 2:
19
+ - name: Carnaval
20
+ regions: [ar]
21
+ mday: 8
22
+ - name: Carnaval
23
+ regions: [ar]
24
+ mday: 9
21
25
  3:
22
26
  - name: Día Nacional de la Memoria por la Verdad y la Justicia
23
27
  regions: [ar]
@@ -38,45 +42,51 @@ months:
38
42
  regions: [ar]
39
43
  mday: 20
40
44
  7:
45
+ - name: Feriado puente turístico
46
+ regions: [ar]
47
+ mday: 8
41
48
  - name: Día de la Independencia
42
49
  regions: [ar]
43
50
  mday: 9
44
51
  8:
45
52
  - name: Paso a la Inmortalidad del General José de San Martín
46
53
  regions: [ar]
47
- week: 3
48
- wday: 1
54
+ mday: 15
49
55
  10:
50
56
  - name: Día del Respeto a la Diversidad Cultural
51
57
  regions: [ar]
52
- week: 2
53
- wday: 1
58
+ mday: 12
54
59
  11:
55
- - name: Día de la Soberanía nacional
60
+ - name: Día de la Soberanía Nacional
56
61
  regions: [ar]
57
- week: 4
58
- wday: 1
62
+ mday: 20
59
63
  12:
60
64
  - name: Inmaculada Concepción de María
61
65
  regions: [ar]
62
66
  mday: 8
67
+ - name: Feriado puente turístico
68
+ regions: [ar]
69
+ mday: 9
63
70
  - name: Navidad
64
71
  regions: [ar]
65
72
  mday: 25
66
73
  tests: |
67
- {Date.civil(2013,1,1) => 'Año Nuevo',
68
- Date.civil(2013,3,24) => 'Día Nacional de la Memoria por la Verdad y la Justicia',
69
- Date.civil(2013,3,28) => 'Jueves Santo',
70
- Date.civil(2013,3,29) => 'Viernes Santo',
71
- Date.civil(2013,4,2) => 'Día del Veterano y de los Caídos en la Guerra de Malvinas',
72
- Date.civil(2013,5,1) => 'Día del Trabajador',
73
- Date.civil(2013,5,25) => 'Día de la Revolución de Mayo',
74
- Date.civil(2013,6,20) => 'Día de la Bandera',
75
- Date.civil(2013,7,9) => 'Día de la Independencia',
76
- Date.civil(2013,8,19) => 'Paso a la Inmortalidad del General José de San Martín',
77
- Date.civil(2013,10,14) => 'Día del Respeto a la Diversidad Cultural',
78
- Date.civil(2013,11,25) => 'Día de la Soberanía nacional',
79
- Date.civil(2013,12,8) => 'Inmaculada Concepción de María',
80
- Date.civil(2013,12,25) => 'Navidad'}.each do |date, name|
74
+ {Date.civil(2016,1,1) => 'Año Nuevo',
75
+ Date.civil(2016,2,8) => 'Carnaval',
76
+ Date.civil(2016,2,9) => 'Carnaval',
77
+ Date.civil(2016,3,24) => 'Día Nacional de la Memoria por la Verdad y la Justicia',
78
+ Date.civil(2016,3,25) => 'Viernes Santo',
79
+ Date.civil(2016,4,2) => 'Día del Veterano y de los Caídos en la Guerra de Malvinas',
80
+ Date.civil(2016,5,1) => 'Día del Trabajador',
81
+ Date.civil(2016,5,25) => 'Día de la Revolución de Mayo',
82
+ Date.civil(2016,6,20) => 'Día de la Bandera',
83
+ Date.civil(2016,7,8) => 'Feriado puente turístico',
84
+ Date.civil(2016,7,9) => 'Día de la Independencia',
85
+ Date.civil(2016,8,15) => 'Paso a la Inmortalidad del General José de San Martín',
86
+ Date.civil(2016,10,12) => 'Día del Respeto a la Diversidad Cultural',
87
+ Date.civil(2016,11,20) => 'Día de la Soberanía Nacional',
88
+ Date.civil(2016,12,8) => 'Inmaculada Concepción de María',
89
+ Date.civil(2016,12,9) => 'Feriado puente turístico',
90
+ Date.civil(2016,12,25) => 'Navidad'}.each do |date, name|
81
91
  assert_equal name, (Holidays.on(date, :ar, :informal)[0] || {})[:name]
82
- end
92
+ end
data/definitions/au.yaml CHANGED
@@ -4,7 +4,7 @@
4
4
  # - http://en.wikipedia.org/wiki/Australian_public_holidays
5
5
  # - http://www.docep.wa.gov.au/lr/LabourRelations/Content/Wages%20and%20Conditions/Public%20Holidays/Public_Holidays.html
6
6
  # - http://www.wst.tas.gov.au/employment_info/public_holidays
7
- # TODO: missing some regional holidays
7
+ # - https://www.fairwork.gov.au/leave/public-holidays/list-of-public-holidays
8
8
  ---
9
9
  months:
10
10
  0:
@@ -79,9 +79,12 @@ months:
79
79
  week: 1
80
80
  wday: 1
81
81
  - name: Queen's Birthday
82
- regions: [au_act, au_nsw, au_sa, au_qld, au_tas, au_nt, au_vic]
82
+ regions: [au_act, au_nsw, au_sa, au_tas, au_nt, au_vic]
83
83
  week: 2
84
84
  wday: 1
85
+ - name: Queen's Birthday
86
+ regions: [au_qld]
87
+ function: qld_queens_birthday_june(year)
85
88
  - name: Queensland Day
86
89
  regions: [au_qld]
87
90
  mday: 6
@@ -137,16 +140,26 @@ months:
137
140
  week: 1
138
141
  wday: 2
139
142
  12:
140
- - name: Christmas Day
141
- regions: [au]
143
+ - name: Christmas Day # CHRISTMAS DAY - ACT, NSW, QLD, Tas, WA observe on 27th (and 25th) if 25th is a Sunday
144
+ regions: [au_qld, au_nsw, au_act, au_tas, au_wa]
145
+ mday: 25
146
+ observed: to_tuesday_if_sunday_or_monday_if_saturday
147
+ - name: Christmas Day # CHRISTMAS DAY - SA observes on 26th if 25th is a Sunday (Boxing Day goes to 27th)
148
+ regions: [au_sa]
142
149
  mday: 25
143
150
  observed: to_monday_if_weekend
151
+ - name: Christmas Day # CHRISTMAS DAY - Victoria and NT don't observe 25th if weekend - xmas is on the 27th
152
+ regions: [au_vic, au_nt]
153
+ function: xmas_to_weekday_if_weekend(year)
144
154
  - name: Boxing Day
145
155
  regions: [au_nsw, au_vic, au_qld, au_act, au_wa]
146
156
  mday: 26
147
- observed: to_weekday_if_boxing_weekend
157
+ observed: to_tuesday_if_sunday_or_monday_if_saturday
148
158
  - name: Boxing Day
149
- regions: [au_sa, au_tas, au_nt]
159
+ regions: [au_sa]
160
+ function: to_weekday_if_boxing_weekend_from_year_or_to_tuesday_if_monday(year)
161
+ - name: Boxing Day
162
+ regions: [au_tas, au_nt]
150
163
  function: to_weekday_if_boxing_weekend_from_year(year)
151
164
  methods:
152
165
  afl_grand_final: |
@@ -158,20 +171,39 @@ methods:
158
171
  qld_queens_bday_october: |
159
172
  # http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
160
173
  # celebrated twice in 2012
174
+ # in october again from 2016
161
175
  def self.qld_queens_bday_october(year)
162
- year == 2012 ? 1 : nil
176
+ if year >= 2016
177
+ Holidays.calculate_day_of_month(year, 10, 1, 1)
178
+ elsif year == 2012
179
+ 1
180
+ else
181
+ nil
182
+ end
163
183
  end
164
184
  qld_labour_day_may: |
165
185
  # http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
166
- # changed from may to october after 2012
186
+ # for 2013 to 2016 it was in October, otherwise it's in May
167
187
  def self.qld_labour_day_may(year)
168
- year <= 2012 ? Holidays.calculate_day_of_month(year, 5, 1, 1) : nil
188
+ if year < 2013 || year >= 2016
189
+ Holidays.calculate_day_of_month(year, 5, 1, 1)
190
+ end
169
191
  end
170
192
  qld_labour_day_october: |
171
193
  # http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
172
- # changed from may to october after 2012
194
+ # for 2013 to 2016 it was in October, otherwise it's in May
173
195
  def self.qld_labour_day_october(year)
174
- year <= 2012 ? nil : Holidays.calculate_day_of_month(year, 10, 1, 1)
196
+ if year >= 2013 && year < 2016
197
+ Holidays.calculate_day_of_month(year, 10, 1, 1)
198
+ end
199
+ end
200
+ qld_queens_birthday_june: |
201
+ # http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
202
+ # in june until 2015
203
+ def self.qld_queens_birthday_june(year)
204
+ if year <= 2015
205
+ Holidays.calculate_day_of_month(year, 6, 2, 1)
206
+ end
175
207
  end
176
208
  g20_day_2014_only: |
177
209
  # http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
@@ -211,8 +243,7 @@ tests: |
211
243
  Date.civil(2007,1,26) => 'Australia Day',
212
244
  Date.civil(2007,4,6) => 'Good Friday',
213
245
  Date.civil(2007,4,9) => 'Easter Monday',
214
- Date.civil(2007,4,25) => 'ANZAC Day',
215
- Date.civil(2007,12,25) => 'Christmas Day'}.each do |date, name|
246
+ Date.civil(2007,4,25) => 'ANZAC Day'}.each do |date, name|
216
247
  assert_equal name, (Holidays.on(date, :au, :informal)[0] || {})[:name]
217
248
  end
218
249
 
@@ -236,10 +267,14 @@ tests: |
236
267
 
237
268
  assert_equal 'Labour Day', Holidays.on(Date.civil(2013,10,7), :au_qld)[0][:name]
238
269
  assert_equal 'Labour Day', Holidays.on(Date.civil(2012,5,7), :au_qld)[0][:name]
270
+ assert_equal 'Labour Day', Holidays.on(Date.civil(2015,10,5), :au_qld)[0][:name]
271
+ assert_equal 'Labour Day', Holidays.on(Date.civil(2016,5,2), :au_qld)[0][:name]
239
272
 
240
273
  assert_equal "Queen's Birthday", Holidays.on(Date.civil(2012,6,11), :au_qld)[0][:name]
241
274
  assert_equal "Queen's Birthday", Holidays.on(Date.civil(2012,10,1), :au_qld)[0][:name]
242
275
  assert_equal "Queen's Birthday", Holidays.on(Date.civil(2013,6,10), :au_qld)[0][:name]
276
+ assert_equal "Queen's Birthday", Holidays.on(Date.civil(2015,6,8), :au_qld)[0][:name]
277
+ assert_equal "Queen's Birthday", Holidays.on(Date.civil(2016,10,3), :au_qld)[0][:name]
243
278
 
244
279
  assert_equal "Queen's Birthday", Holidays.on(Date.civil(2014, 9, 29), :au_wa)[0][:name]
245
280
  assert_equal "Queen's Birthday", Holidays.on(Date.civil(2015, 9, 28), :au_wa)[0][:name]
@@ -308,3 +343,28 @@ tests: |
308
343
  assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2014, 2, 10), :au_tas_south)[0][:name]
309
344
  assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2015, 2, 9), :au_tas_south)[0][:name]
310
345
  assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2016, 2, 8), :au_tas_south)[0][:name]
346
+
347
+ # CHRISTMAS DAY - ACT, NSW, QLD, Tas, WA observe on 27th (and 25th) if 25th is a Sunday
348
+ assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_qld)[0][:name]
349
+ assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_qld, :observed)[0][:name]
350
+ assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_nsw)[0][:name]
351
+ assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_nsw, :observed)[0][:name]
352
+ assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_act)[0][:name]
353
+ assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_act, :observed)[0][:name]
354
+ assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_tas)[0][:name]
355
+ assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_tas, :observed)[0][:name]
356
+ assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_wa)[0][:name]
357
+ assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_wa, :observed)[0][:name]
358
+
359
+ # CHRISTMAS DAY - SA observes on 26th if 25th is a Sunday (Boxing Day goes to 27th)
360
+ assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_sa)[0][:name]
361
+ assert_equal "Christmas Day", Date.civil(2016, 12, 26).holidays(:au_sa, :observed)[0][:name]
362
+ assert_equal "Boxing Day", Date.civil(2016, 12, 27).holidays(:au_sa)[0][:name]
363
+
364
+ # CHRISTMAS DAY - Victoria and NT don't observe 25th if weekend - xmas is on the 27th
365
+ assert_nil Date.civil(2016, 12, 25).holidays(:au_vic)[0]
366
+ assert_nil Date.civil(2016, 12, 25).holidays(:au_nt)[0]
367
+ assert_equal "Boxing Day", Date.civil(2016, 12, 26).holidays(:au_vic)[0][:name]
368
+ assert_equal "Boxing Day", Date.civil(2016, 12, 26).holidays(:au_nt)[0][:name]
369
+ assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_vic)[0][:name]
370
+ assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_nt)[0][:name]