holidays 2.2.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/README.md +22 -8
  4. data/Rakefile +26 -8
  5. data/bin/console +7 -0
  6. data/bin/setup +5 -0
  7. data/{data → definitions}/SYNTAX.rdoc +0 -0
  8. data/{data → definitions}/ar.yaml +0 -0
  9. data/{data → definitions}/at.yaml +1 -1
  10. data/{data → definitions}/au.yaml +80 -51
  11. data/{data → definitions}/be.yaml +0 -0
  12. data/{data → definitions}/br.yaml +0 -0
  13. data/{data → definitions}/ca.yaml +0 -0
  14. data/{data → definitions}/ch.yaml +0 -0
  15. data/{data → definitions}/cl.yaml +0 -0
  16. data/{data → definitions}/cr.yaml +0 -0
  17. data/{data → definitions}/cz.yaml +0 -0
  18. data/{data → definitions}/de.yaml +25 -34
  19. data/{data → definitions}/dk.yaml +0 -0
  20. data/{data → definitions}/ecb_target.yaml +2 -2
  21. data/{data → definitions}/el.yaml +0 -0
  22. data/{data → definitions}/es.yaml +37 -26
  23. data/{data → definitions}/federal_reserve.yaml +0 -0
  24. data/{data → definitions}/fedex.yaml +9 -3
  25. data/{data → definitions}/fi.yaml +0 -0
  26. data/{data → definitions}/fr.yaml +0 -0
  27. data/{data → definitions}/gb.yaml +19 -19
  28. data/{data → definitions}/hr.yaml +0 -0
  29. data/{data → definitions}/hu.yaml +1 -1
  30. data/{data → definitions}/ie.yaml +0 -0
  31. data/{data → definitions}/index.yaml +0 -0
  32. data/{data → definitions}/is.yaml +0 -0
  33. data/{data → definitions}/it.yaml +0 -0
  34. data/{data → definitions}/jp.yaml +3 -3
  35. data/{data → definitions}/li.yaml +3 -3
  36. data/{data → definitions}/lt.yaml +0 -0
  37. data/{data → definitions}/ma.yaml +0 -0
  38. data/{data → definitions}/mx.yaml +0 -0
  39. data/{data → definitions}/nerc.yaml +0 -0
  40. data/{data → definitions}/nl.yaml +0 -0
  41. data/{data → definitions}/no.yaml +0 -0
  42. data/{data → definitions}/north_america_informal.yaml +0 -0
  43. data/{data → definitions}/nyse.yaml +0 -0
  44. data/{data → definitions}/nz.yaml +21 -10
  45. data/{data → definitions}/ph.yaml +0 -0
  46. data/{data → definitions}/pl.yaml +0 -0
  47. data/{data → definitions}/pt.yaml +0 -0
  48. data/{data → definitions}/ro.yaml +1 -2
  49. data/{data → definitions}/se.yaml +0 -0
  50. data/{data → definitions}/sg.yaml +0 -0
  51. data/{data → definitions}/si.yaml +6 -6
  52. data/{data → definitions}/sk.yaml +0 -0
  53. data/{data → definitions}/united_nations.yaml +0 -0
  54. data/{data → definitions}/ups.yaml +17 -11
  55. data/{data → definitions}/us.yaml +20 -15
  56. data/{data → definitions}/ve.yaml +0 -0
  57. data/{data → definitions}/vi.yaml +0 -0
  58. data/{data → definitions}/za.yaml +0 -0
  59. data/holidays.gemspec +2 -1
  60. data/lib/generated_definitions/MANIFEST +56 -0
  61. data/lib/generated_definitions/REGIONS.rb +4 -0
  62. data/lib/{holidays → generated_definitions}/ar.rb +2 -2
  63. data/lib/{holidays → generated_definitions}/at.rb +2 -2
  64. data/lib/{holidays → generated_definitions}/au.rb +19 -10
  65. data/lib/{holidays → generated_definitions}/be.rb +2 -2
  66. data/lib/{holidays → generated_definitions}/br.rb +2 -2
  67. data/lib/{holidays → generated_definitions}/ca.rb +2 -2
  68. data/lib/{holidays → generated_definitions}/ch.rb +2 -2
  69. data/lib/{holidays → generated_definitions}/cl.rb +2 -2
  70. data/lib/{holidays → generated_definitions}/cr.rb +2 -2
  71. data/lib/{holidays → generated_definitions}/cz.rb +2 -2
  72. data/lib/{holidays → generated_definitions}/de.rb +5 -4
  73. data/lib/{holidays → generated_definitions}/dk.rb +2 -2
  74. data/lib/{holidays → generated_definitions}/ecb_target.rb +2 -2
  75. data/lib/{holidays → generated_definitions}/el.rb +2 -2
  76. data/lib/{holidays → generated_definitions}/es.rb +6 -6
  77. data/lib/{holidays → generated_definitions}/europe.rb +7 -6
  78. data/lib/{holidays → generated_definitions}/fed_ex.rb +8 -3
  79. data/lib/{holidays → generated_definitions}/federal_reserve.rb +2 -2
  80. data/lib/{holidays → generated_definitions}/fi.rb +2 -2
  81. data/lib/{holidays → generated_definitions}/fr.rb +2 -2
  82. data/lib/{holidays → generated_definitions}/gb.rb +2 -2
  83. data/lib/{holidays → generated_definitions}/hr.rb +2 -2
  84. data/lib/{holidays → generated_definitions}/hu.rb +2 -2
  85. data/lib/{holidays → generated_definitions}/ie.rb +2 -2
  86. data/lib/{holidays → generated_definitions}/is.rb +2 -2
  87. data/lib/{holidays → generated_definitions}/it.rb +2 -2
  88. data/lib/{holidays → generated_definitions}/jp.rb +5 -5
  89. data/lib/{holidays → generated_definitions}/li.rb +2 -2
  90. data/lib/{holidays → generated_definitions}/lt.rb +2 -2
  91. data/lib/{holidays → generated_definitions}/ma.rb +2 -2
  92. data/lib/{holidays → generated_definitions}/mx.rb +2 -2
  93. data/lib/{holidays → generated_definitions}/nerc.rb +2 -2
  94. data/lib/{holidays → generated_definitions}/nl.rb +2 -2
  95. data/lib/{holidays → generated_definitions}/no.rb +2 -2
  96. data/lib/{holidays → generated_definitions}/north_america.rb +8 -3
  97. data/lib/{holidays → generated_definitions}/nyse.rb +2 -2
  98. data/lib/{holidays → generated_definitions}/nz.rb +5 -5
  99. data/lib/{holidays → generated_definitions}/ph.rb +2 -2
  100. data/lib/{holidays → generated_definitions}/pl.rb +2 -2
  101. data/lib/{holidays → generated_definitions}/pt.rb +2 -2
  102. data/lib/{holidays → generated_definitions}/ro.rb +2 -2
  103. data/lib/{holidays → generated_definitions}/scandinavia.rb +2 -2
  104. data/lib/{holidays → generated_definitions}/se.rb +2 -2
  105. data/lib/{holidays → generated_definitions}/sg.rb +2 -2
  106. data/lib/{holidays → generated_definitions}/si.rb +2 -2
  107. data/lib/{holidays → generated_definitions}/sk.rb +2 -2
  108. data/lib/{holidays → generated_definitions}/united_nations.rb +2 -2
  109. data/lib/{holidays → generated_definitions}/ups.rb +8 -3
  110. data/lib/{holidays → generated_definitions}/us.rb +8 -3
  111. data/lib/{holidays → generated_definitions}/ve.rb +2 -2
  112. data/lib/{holidays → generated_definitions}/vi.rb +2 -2
  113. data/lib/{holidays → generated_definitions}/za.rb +2 -2
  114. data/lib/holidays.rb +120 -665
  115. data/lib/holidays/core_extensions/date.rb +39 -0
  116. data/lib/holidays/date_calculator/day_of_month.rb +68 -0
  117. data/lib/holidays/date_calculator/easter.rb +58 -0
  118. data/lib/holidays/date_calculator/weekend_modifier.rb +49 -0
  119. data/lib/holidays/date_calculator_factory.rb +21 -0
  120. data/lib/holidays/definition/context/generator.rb +216 -0
  121. data/lib/holidays/definition/context/merger.rb +26 -0
  122. data/lib/holidays/definition/repository/cache.rb +33 -0
  123. data/lib/holidays/definition/repository/holidays_by_month.rb +49 -0
  124. data/lib/holidays/definition/repository/proc_cache.rb +36 -0
  125. data/lib/holidays/definition/repository/regions.rb +36 -0
  126. data/lib/holidays/definition/validator/region.rb +45 -0
  127. data/lib/holidays/definition_factory.rb +50 -0
  128. data/lib/holidays/option/context/parse_options.rb +96 -0
  129. data/lib/holidays/option_factory.rb +14 -0
  130. data/lib/holidays/use_case/context/between.rb +105 -0
  131. data/lib/holidays/use_case/context/dates_driver_builder.rb +64 -0
  132. data/lib/holidays/use_case_factory.rb +20 -0
  133. data/lib/holidays/version.rb +1 -1
  134. data/test/defs/test_defs_ar.rb +1 -1
  135. data/test/defs/test_defs_at.rb +2 -2
  136. data/test/defs/test_defs_au.rb +61 -43
  137. data/test/defs/test_defs_be.rb +1 -1
  138. data/test/defs/test_defs_br.rb +1 -1
  139. data/test/defs/test_defs_ca.rb +1 -1
  140. data/test/defs/test_defs_ch.rb +1 -1
  141. data/test/defs/test_defs_cl.rb +1 -1
  142. data/test/defs/test_defs_cr.rb +1 -1
  143. data/test/defs/test_defs_cz.rb +1 -1
  144. data/test/defs/test_defs_de.rb +18 -30
  145. data/test/defs/test_defs_dk.rb +1 -1
  146. data/test/defs/test_defs_ecb_target.rb +3 -3
  147. data/test/defs/test_defs_el.rb +1 -1
  148. data/test/defs/test_defs_es.rb +36 -25
  149. data/test/defs/test_defs_europe.rb +82 -84
  150. data/test/defs/test_defs_fed_ex.rb +4 -1
  151. data/test/defs/test_defs_federal_reserve.rb +1 -1
  152. data/test/defs/test_defs_fi.rb +1 -1
  153. data/test/defs/test_defs_fr.rb +1 -1
  154. data/test/defs/test_defs_gb.rb +20 -20
  155. data/test/defs/test_defs_hr.rb +1 -1
  156. data/test/defs/test_defs_hu.rb +2 -2
  157. data/test/defs/test_defs_ie.rb +1 -1
  158. data/test/defs/test_defs_is.rb +1 -1
  159. data/test/defs/test_defs_it.rb +1 -1
  160. data/test/defs/test_defs_jp.rb +1 -1
  161. data/test/defs/test_defs_li.rb +4 -4
  162. data/test/defs/test_defs_lt.rb +1 -1
  163. data/test/defs/test_defs_ma.rb +1 -1
  164. data/test/defs/test_defs_mx.rb +1 -1
  165. data/test/defs/test_defs_nerc.rb +1 -1
  166. data/test/defs/test_defs_nl.rb +1 -1
  167. data/test/defs/test_defs_no.rb +1 -1
  168. data/test/defs/test_defs_north_america.rb +5 -3
  169. data/test/defs/test_defs_nyse.rb +1 -1
  170. data/test/defs/test_defs_nz.rb +19 -9
  171. data/test/defs/test_defs_ph.rb +1 -1
  172. data/test/defs/test_defs_pl.rb +1 -1
  173. data/test/defs/test_defs_pt.rb +1 -1
  174. data/test/defs/test_defs_ro.rb +2 -3
  175. data/test/defs/test_defs_scandinavia.rb +1 -1
  176. data/test/defs/test_defs_se.rb +1 -1
  177. data/test/defs/test_defs_sg.rb +1 -1
  178. data/test/defs/test_defs_si.rb +7 -7
  179. data/test/defs/test_defs_sk.rb +1 -1
  180. data/test/defs/test_defs_united_nations.rb +1 -1
  181. data/test/defs/test_defs_ups.rb +5 -2
  182. data/test/defs/test_defs_us.rb +5 -3
  183. data/test/defs/test_defs_ve.rb +1 -1
  184. data/test/defs/test_defs_vi.rb +1 -1
  185. data/test/defs/test_defs_za.rb +1 -1
  186. data/test/{test_date.rb → holidays/core_extensions/test_date.rb} +8 -2
  187. data/test/holidays/date_calculator/test_day_of_month.rb +27 -0
  188. data/test/holidays/date_calculator/test_easter.rb +29 -0
  189. data/test/holidays/date_calculator/test_weekend_modifier.rb +33 -0
  190. data/test/holidays/definition/context/test_generator.rb +84 -0
  191. data/test/holidays/definition/context/test_merger.rb +22 -0
  192. data/test/holidays/definition/repository/test_cache.rb +82 -0
  193. data/test/holidays/definition/repository/test_holidays_by_month.rb +187 -0
  194. data/test/holidays/definition/repository/test_proc_cache.rb +29 -0
  195. data/test/holidays/definition/repository/test_regions.rb +86 -0
  196. data/test/holidays/definition/validator/test_region.rb +50 -0
  197. data/test/holidays/option/context/test_parse_options.rb +69 -0
  198. data/test/holidays/test_date_calculator_factory.rb +21 -0
  199. data/test/holidays/test_definition_factory.rb +34 -0
  200. data/test/holidays/test_option_factory.rb +9 -0
  201. data/test/holidays/test_use_case_factory.rb +13 -0
  202. data/test/holidays/use_case/context/test_between.rb +75 -0
  203. data/test/holidays/use_case/context/test_dates_driver_builder.rb +91 -0
  204. data/test/test_all_regions.rb +14 -3
  205. data/test/test_helper.rb +2 -1
  206. data/test/test_holidays.rb +19 -24
  207. data/test/test_holidays_between.rb +85 -0
  208. data/test/test_multiple_regions.rb +2 -2
  209. data/test/test_parse_definitions.rb +10 -4
  210. metadata +181 -111
  211. data/.coveralls.yml +0 -1
  212. data/lib/holidays/MANIFEST +0 -55
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3c8c7e2a83586d68dc3539c6dc0361b7e540849
4
- data.tar.gz: 937727211a7563a4b79999ff674356facf6e26c1
3
+ metadata.gz: c7e0cde948514ce3a0059bae0b9e4272407b316a
4
+ data.tar.gz: 77b744846d522777de4f300ef353c955572e743e
5
5
  SHA512:
6
- metadata.gz: aa97db7271f924548252559fb1e139c71773c8c0750cd269936577555e25f86a334840a6d8fb38f3d5d4a310b4c7c9d3456e25a0201a2c7a32126020abe1bda2
7
- data.tar.gz: c0c169a10a3dda81385cfc7655d20080e507bc7495b63f702f76dd67f4896a8be003435a91badbce140b0aa9f9e0dfda952c7714bc6604b1fc8c4b33e40fff88
6
+ metadata.gz: 2adfd091ee9a1c5990a1bd1f618df081bd70b90f58b3bd9326a00d0e360a8362f70f66b89830bc1ed444c5b799aac7fb23e711f31a2166f5244cfaaa5b5d75f9
7
+ data.tar.gz: 42b2a8e201304ecbefb934e7366225eaa17821b123f99be18ac5f3fba5ed7aa8812f4214e205bd1069fe14025ac5baff8fee09a403ead09830c4629fd648da47
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Ruby Holidays Gem CHANGELOG
2
2
 
3
+ ## 3.0.0
4
+
5
+ * Major refactor! Lots of code moved around and some methods were removed from the public api (they were never intended to be public).
6
+ * Only supports ruby 2.0.0 and up. Travis config has been updated to reflect this.
7
+ * Moves 'date' monkeypatching out of main lib and makes it a core extension. See README for usage.
8
+ * Fixes remote execution bug in issue-86 (thanks to https://github.com/Intrepidd for reporting)
9
+ * No region definition changes.
10
+
11
+ I decided to make this a major version bump due to how much I changed. I truly hope no one will notice.
12
+ See the README for the usage. It has, except for the date core extension, not changed.
13
+
3
14
  ## 2.2.0
4
15
 
5
16
  * Correct 'informal' type for Dodenherdenking holiday in NL definitions (https://github.com/MathijsK93)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Ruby Holidays Gem [![Build Status](https://travis-ci.org/alexdunae/holidays.svg?branch=master)](https://travis-ci.org/alexdunae/holidays) [![Coverage Status](https://coveralls.io/repos/alexdunae/holidays/badge.svg)](https://coveralls.io/r/alexdunae/holidays)
1
+ # Ruby Holidays Gem [![Build Status](https://travis-ci.org/holidays/holidays.svg?branch=master)](https://travis-ci.org/holidays/holidays) [![Coverage Status](https://coveralls.io/repos/holidays/holidays/badge.svg)](https://coveralls.io/r/holidays/holidays)
2
2
 
3
3
  A set of functions to deal with holidays in Ruby.
4
4
 
@@ -12,7 +12,7 @@ To install the gem from RubyGems:
12
12
 
13
13
  gem install holidays
14
14
 
15
- The Holidays gem is tested on Ruby 1.9.2, 1.9.3, 2.0.0, 2.1.0, 2.2.0 and JRuby.
15
+ The Holidays gem is tested on Ruby 2.0.0, 2.1.0, 2.2.0 and JRuby.
16
16
 
17
17
  ## Time zones
18
18
 
@@ -68,7 +68,7 @@ Load custom 'Company Founding' holiday on June 1st:
68
68
  Holidays.on(date, :my_custom_region)
69
69
  => [{:name => 'Company Founding',...}]
70
70
 
71
- Custom definition files must match the format of the existing definition YAML files location in the 'data' directory.
71
+ Custom definition files must match the format of the existing definition YAML files location in the 'definitions' directory.
72
72
 
73
73
  Multiple files can also be passed:
74
74
 
@@ -76,14 +76,21 @@ Multiple files can also be passed:
76
76
 
77
77
  ### Extending Ruby's Date class
78
78
 
79
- Check which holidays occur in Iceland on January 1, 2008.
79
+ To extend the 'Date' class:
80
+
81
+ require 'holidays/core_extensions/date'
82
+ class Date
83
+ include Holidays::CoreExtensions::Date
84
+ end
85
+
86
+ Now you can check which holidays occur in Iceland on January 1, 2008:
80
87
 
81
88
  d = Date.civil(2008,7,1)
82
89
 
83
90
  d.holidays(:is)
84
91
  => [{:name => 'Nýársdagur'}...]
85
92
 
86
- Lookup Canada Day in different regions.
93
+ Or lookup Canada Day in different regions:
87
94
 
88
95
  d = Date.civil(2008,7,1)
89
96
 
@@ -96,6 +103,11 @@ Lookup Canada Day in different regions.
96
103
  d.holiday?(:fr) # France
97
104
  => false
98
105
 
106
+ Or you can calculate the day of the month:
107
+
108
+ Date.calculate_mday(2015, 4, :first, 2)
109
+ => 7
110
+
99
111
  ### Caching Holiday Lookups
100
112
 
101
113
  If you are checking holidays regularly you can cache your results for improved performance. Run this before looking up a holiday (eg. in an initializer):
@@ -108,14 +120,16 @@ See the [original pull request](https://github.com/alexdunae/holidays/pull/36) f
108
120
 
109
121
  ### How to contribute
110
122
 
111
- To make changes to any of the definitions, edit the YAML files only.
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.
112
124
 
113
- Tests are also added at the end of the YAML files. Please add tests, it makes the pull requests go around.
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.
114
126
 
115
- After you're satisfied with the YAML file, edit the index.yaml file, run `rake generate`, which will generate the Ruby files that make up the actual code as well as the tests. Then run `rake test`.
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.
116
128
 
117
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.
118
130
 
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.
132
+
119
133
  ### Credits and code
120
134
 
121
135
  * Started by [Alex Dunae](http://dunae.ca) (e-mail 'code' at the same domain), 2007-12
data/Rakefile CHANGED
@@ -15,7 +15,8 @@ end
15
15
  task :default => :test
16
16
 
17
17
  namespace :generate do
18
- DATA_PATH = 'data'
18
+ DATA_PATH = 'definitions'
19
+ TEST_DEFS_PATH = 'test/defs'
19
20
 
20
21
  desc 'Generate the holiday definition files'
21
22
  task :definitions do
@@ -23,34 +24,52 @@ namespace :generate do
23
24
  def_index = YAML.load_file("#{DATA_PATH}/index.yaml")
24
25
 
25
26
  # create a dir for the generated tests
26
- FileUtils.mkdir_p('test/defs')
27
+ FileUtils.mkdir_p(TEST_DEFS_PATH)
28
+
29
+ all_regions = []
27
30
 
28
31
  def_index['defs'].each do |region, files|
29
32
  puts "Building #{region} definition module:"
30
33
  files = files.collect { |f| "#{DATA_PATH}/#{f}" }.uniq
31
34
 
32
- module_src, test_src = Holidays.parse_definition_files_and_return_source(region, files)
33
- File.open("lib/holidays/#{region.downcase.to_s}.rb","w") do |file|
35
+ module_src, test_src, regions = Holidays.parse_definition_files_and_return_source(region, files)
36
+ File.open("lib/#{Holidays::DEFINITIONS_PATH}/#{region.downcase.to_s}.rb","w") do |file|
34
37
  file.puts module_src
35
38
  end
36
39
  unless test_src.empty?
37
- File.open("test/defs/test_defs_#{region.downcase.to_s}.rb","w") do |file|
40
+ File.open("#{TEST_DEFS_PATH}/test_defs_#{region.downcase.to_s}.rb","w") do |file|
38
41
  file.puts test_src
39
42
  end
40
43
  end
44
+
45
+ all_regions << regions
46
+
41
47
  puts "Done.\n\n"
42
48
  end
49
+
50
+ puts "Building regions master file for later validation:"
51
+
52
+ File.open("lib/#{Holidays::DEFINITIONS_PATH}/REGIONS.rb","w") do |file|
53
+ file.puts <<-EOR
54
+ # encoding: utf-8
55
+ module Holidays
56
+ REGIONS = [:#{all_regions.join(', :')}]
57
+ end
58
+ EOR
59
+ end
60
+
61
+ puts "Done.\n\n"
43
62
  end
44
63
 
45
64
  desc 'Build the definition manifest'
46
65
  task :manifest do
47
- File.open("lib/holidays/MANIFEST","w") do |file|
66
+ File.open("lib/#{Holidays::DEFINITIONS_PATH}/MANIFEST","w") do |file|
48
67
  file.puts <<-EOH
49
68
  ==== Regional definitions
50
69
  The following definition files are included in this installation:
51
70
 
52
71
  EOH
53
- FileList.new('lib/holidays/*.rb').exclude(/version/).each do |str|
72
+ FileList.new("lib/#{Holidays::DEFINITIONS_PATH}/*.rb").exclude(/version/).each do |str|
54
73
  file.puts('* ' + str.gsub(/^lib\/|\.rb$/, ''))
55
74
  end
56
75
  end
@@ -59,4 +78,3 @@ The following definition files are included in this installation:
59
78
  end
60
79
 
61
80
  task :generate => ['generate:definitions', 'generate:manifest']
62
-
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "holidays"
5
+
6
+ require "irb"
7
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
File without changes
File without changes
@@ -65,4 +65,4 @@ tests: |
65
65
  assert_equal name, (Holidays.on(date, :at, :informal)[0] || {})[:name]
66
66
  end
67
67
 
68
- assert !Date.civil(2010,5,8).holiday?(:at), '2010-05-08 is not a holiday in Austria'
68
+ assert_equal [], Holidays.on(Date.civil(2010,5,8), :at), '2010-05-08 is not a holiday in Austria'
@@ -12,7 +12,7 @@ months:
12
12
  regions: [au]
13
13
  function: easter(year)-2
14
14
  - name: Easter Saturday
15
- regions: [au_nsw, au_vic, au_qld, au_nt, au_act, au_sa, au_qld_brisbane, au_qld_cairns]
15
+ regions: [au_nsw, au_vic, au_qld, au_nt, au_act, au_sa]
16
16
  function: easter(year)-1
17
17
  - name: Easter Sunday
18
18
  regions: [au_nsw, au_vic]
@@ -105,7 +105,10 @@ months:
105
105
  regions: [au_act]
106
106
  week: -1
107
107
  wday: 1
108
- 10:
108
+ 10:
109
+ - name: Friday before the AFL Grand Final
110
+ regions: [au_vic]
111
+ function: afl_grand_final(year)
109
112
  - name: Labour Day
110
113
  regions: [au_act, au_nsw, au_sa]
111
114
  week: 1
@@ -130,7 +133,7 @@ months:
130
133
  wday: 1
131
134
  week: 1
132
135
  - name: Melbourne Cup Day
133
- regions: [au_vic]
136
+ regions: [au_vic_melbourne]
134
137
  week: 1
135
138
  wday: 2
136
139
  12:
@@ -139,10 +142,19 @@ months:
139
142
  mday: 25
140
143
  observed: to_monday_if_weekend
141
144
  - name: Boxing Day
142
- regions: [au]
145
+ regions: [au_nsw, au_vic, au_qld, au_act, au_wa]
143
146
  mday: 26
144
147
  observed: to_weekday_if_boxing_weekend
148
+ - name: Boxing Day
149
+ regions: [au_sa, au_tas, au_nt]
150
+ function: to_weekday_if_boxing_weekend_from_year(year)
145
151
  methods:
152
+ afl_grand_final: |
153
+ def self.afl_grand_final(year)
154
+ if year == 2015
155
+ Date.civil(2015, 10, 2)
156
+ end
157
+ end
146
158
  qld_queens_bday_october: |
147
159
  # http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
148
160
  # celebrated twice in 2012
@@ -153,13 +165,13 @@ methods:
153
165
  # http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
154
166
  # changed from may to october after 2012
155
167
  def self.qld_labour_day_may(year)
156
- year <= 2012 ? Date.calculate_mday(year, 5, 1, 1) : nil
168
+ year <= 2012 ? Holidays.calculate_day_of_month(year, 5, 1, 1) : nil
157
169
  end
158
170
  qld_labour_day_october: |
159
171
  # http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
160
172
  # changed from may to october after 2012
161
173
  def self.qld_labour_day_october(year)
162
- year <= 2012 ? nil : Date.calculate_mday(year, 10, 1, 1)
174
+ year <= 2012 ? nil : Holidays.calculate_day_of_month(year, 10, 1, 1)
163
175
  end
164
176
  g20_day_2014_only: |
165
177
  # http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
@@ -171,7 +183,7 @@ methods:
171
183
  # http://worksafe.tas.gov.au/__data/assets/pdf_file/0008/287036/Public_Holidays_2014.pdf
172
184
  # The Thursday before the fourth Saturday in October.
173
185
  def self.hobart_show_day(year)
174
- fourth_sat_in_oct = Date.civil(year, 10, Date.calculate_mday(year, 10, 4, :saturday))
186
+ fourth_sat_in_oct = Date.civil(year, 10, Holidays.calculate_day_of_month(year, 10, 4, :saturday))
175
187
  fourth_sat_in_oct - 2 # the thursday before
176
188
  end
177
189
  march_pub_hol_sa: |
@@ -200,71 +212,67 @@ tests: |
200
212
  Date.civil(2007,4,6) => 'Good Friday',
201
213
  Date.civil(2007,4,9) => 'Easter Monday',
202
214
  Date.civil(2007,4,25) => 'ANZAC Day',
203
- Date.civil(2007,12,25) => 'Christmas Day',
204
- Date.civil(2007,12,26) => 'Boxing Day'}.each do |date, name|
215
+ Date.civil(2007,12,25) => 'Christmas Day'}.each do |date, name|
205
216
  assert_equal name, (Holidays.on(date, :au, :informal)[0] || {})[:name]
206
217
  end
207
218
 
208
219
  [:au_sa, :au_act, :au_nsw, :au_].each do |r|
209
- assert_equal 'Labour Day', Date.civil(2007,10,1).holidays(r)[0][:name]
220
+ assert_equal 'Labour Day', Holidays.on(Date.civil(2007,10,1), r)[0][:name]
210
221
  end
211
222
 
212
223
  [:au_sa, :au_act, :au_nsw, :au_vic, :au_tas, :au_qld, :au_nt, :au_].each do |r|
213
- assert_equal 'Queen\'s Birthday', Date.civil(2007,6,11).holidays(r)[0][:name]
224
+ assert_equal 'Queen\'s Birthday', Holidays.on(Date.civil(2007,6,11), r)[0][:name]
214
225
  end
215
226
 
216
- assert_equal 'Labour Day', Date.civil(2007,3,5).holidays(:au_wa)[0][:name]
217
- assert_equal 'Labour Day', Date.civil(2007,3,12).holidays(:au_vic)[0][:name]
218
- assert_equal 'Labour Day', Date.civil(2007,5,7).holidays(:au_qld)[0][:name]
227
+ assert_equal 'Labour Day', Holidays.on(Date.civil(2007,3,5), :au_wa)[0][:name]
228
+ assert_equal 'Labour Day', Holidays.on(Date.civil(2007,3,12), :au_vic)[0][:name]
229
+ assert_equal 'Labour Day', Holidays.on(Date.civil(2007,5,7), :au_qld)[0][:name]
219
230
 
220
- assert_equal 'Easter Sunday', Date.civil(2007,4,8).holidays(:au_nsw)[0][:name]
231
+ assert_equal 'Easter Sunday', Holidays.on(Date.civil(2007,4,8), :au_nsw)[0][:name]
221
232
 
222
- assert_equal 'May Day', Date.civil(2007,5,7).holidays(:au_nt)[0][:name]
223
-
224
- assert_equal 'Eight Hours Day', Date.civil(2007,3,12).holidays(:au_tas)[0][:name]
233
+ assert_equal 'May Day', Holidays.on(Date.civil(2007,5,7), :au_nt)[0][:name]
225
234
 
226
- assert_equal 'Labour Day', Date.civil(2013,10,7).holidays(:au_qld)[0][:name]
227
- assert_equal 'Labour Day', Date.civil(2012,5,7).holidays(:au_qld)[0][:name]
235
+ assert_equal 'Eight Hours Day', Holidays.on(Date.civil(2007,3,12), :au_tas)[0][:name]
228
236
 
229
- assert_equal "Queen's Birthday", Date.civil(2012,6,11).holidays(:au_qld)[0][:name]
230
- assert_equal "Queen's Birthday", Date.civil(2012,10,1).holidays(:au_qld)[0][:name]
231
- assert_equal "Queen's Birthday", Date.civil(2013,6,10).holidays(:au_qld)[0][:name]
237
+ assert_equal 'Labour Day', Holidays.on(Date.civil(2013,10,7), :au_qld)[0][:name]
238
+ assert_equal 'Labour Day', Holidays.on(Date.civil(2012,5,7), :au_qld)[0][:name]
232
239
 
233
- assert_equal "Queen's Birthday", Date.civil(2014, 9, 29).holidays(:au_wa)[0][:name]
234
- assert_equal "Queen's Birthday", Date.civil(2015, 9, 28).holidays(:au_wa)[0][:name]
235
- assert_equal "Queen's Birthday", Date.civil(2016, 9, 26).holidays(:au_wa)[0][:name]
240
+ assert_equal "Queen's Birthday", Holidays.on(Date.civil(2012,6,11), :au_qld)[0][:name]
241
+ assert_equal "Queen's Birthday", Holidays.on(Date.civil(2012,10,1), :au_qld)[0][:name]
242
+ assert_equal "Queen's Birthday", Holidays.on(Date.civil(2013,6,10), :au_qld)[0][:name]
236
243
 
237
- assert_equal "Family & Community Day", Date.civil(2014, 9, 29).holidays(:au_act)[0][:name]
238
- assert_equal "Family & Community Day", Date.civil(2015, 9, 28).holidays(:au_act)[0][:name]
239
- assert_equal "Family & Community Day", Date.civil(2016, 9, 26).holidays(:au_act)[0][:name]
244
+ assert_equal "Queen's Birthday", Holidays.on(Date.civil(2014, 9, 29), :au_wa)[0][:name]
245
+ assert_equal "Queen's Birthday", Holidays.on(Date.civil(2015, 9, 28), :au_wa)[0][:name]
246
+ assert_equal "Queen's Birthday", Holidays.on(Date.civil(2016, 9, 26), :au_wa)[0][:name]
240
247
 
241
- assert_equal 'Australia Day', Date.civil(2014,1,26).holidays(:au_qld)[0][:name]
242
- assert_equal 'Australia Day', Date.civil(2014,1,27).holidays(:au_qld, :observed)[0][:name]
248
+ assert_equal "Family & Community Day", Holidays.on(Date.civil(2014, 9, 29), :au_act)[0][:name]
249
+ assert_equal "Family & Community Day", Holidays.on(Date.civil(2015, 9, 28), :au_act)[0][:name]
250
+ assert_equal "Family & Community Day", Holidays.on(Date.civil(2016, 9, 26), :au_act)[0][:name]
243
251
 
244
- assert_equal 'Cairns Show', Date.civil(2014,7,18).holidays(:au_qld_cairns)[0][:name]
245
- assert_equal 'Cairns Show', Date.civil(2013,7,19).holidays(:au_qld_cairns)[0][:name]
252
+ assert_equal 'Australia Day', Holidays.on(Date.civil(2014,1,26), :au_qld)[0][:name]
253
+ assert_equal 'Australia Day', Holidays.on(Date.civil(2014,1,27), :au_qld, :observed)[0][:name]
246
254
 
247
- assert_equal 'Royal Hobart Show', Date.civil(2013, 10, 24).holidays(:au_tas_south)[0][:name]
248
- assert_equal 'Royal Hobart Show', Date.civil(2014, 10, 23).holidays(:au_tas_south)[0][:name]
249
- assert_equal 'Royal Hobart Show', Date.civil(2015, 10, 22).holidays(:au_tas_south)[0][:name]
250
- assert_equal 'Royal Hobart Show', Date.civil(2016, 10, 20).holidays(:au_tas_south)[0][:name]
255
+ assert_equal 'Cairns Show', Holidays.on(Date.civil(2014,7,18), :au_qld_cairns)[0][:name]
256
+ assert_equal 'Cairns Show', Holidays.on(Date.civil(2013,7,19), :au_qld_cairns)[0][:name]
251
257
 
252
- assert_equal 'Recreation Day', Date.civil(2013, 11, 4).holidays(:au_tas_north)[0][:name]
253
- assert_equal 'Recreation Day', Date.civil(2014, 11, 3).holidays(:au_tas_north)[0][:name]
254
- assert_equal 'Recreation Day', Date.civil(2015, 11, 2).holidays(:au_tas_north)[0][:name]
255
- assert_equal 'Recreation Day', Date.civil(2016, 11, 7).holidays(:au_tas_north)[0][:name]
258
+ assert_equal 'Royal Hobart Show', Holidays.on(Date.civil(2013, 10, 24), :au_tas_south)[0][:name]
259
+ assert_equal 'Royal Hobart Show', Holidays.on(Date.civil(2014, 10, 23), :au_tas_south)[0][:name]
260
+ assert_equal 'Royal Hobart Show', Holidays.on(Date.civil(2015, 10, 22), :au_tas_south)[0][:name]
261
+ assert_equal 'Royal Hobart Show', Holidays.on(Date.civil(2016, 10, 20), :au_tas_south)[0][:name]
256
262
 
257
- assert_equal 'G20 Day', Date.civil(2014,11,14).holidays(:au_qld_brisbane)[0][:name]
258
- assert_equal [], Date.civil(2014,11,14).holidays(:au_qld)
259
- assert_equal [], Date.civil(2015,11,14).holidays(:au_qld_brisbane)
263
+ assert_equal 'Recreation Day', Holidays.on(Date.civil(2013, 11, 4), :au_tas_north)[0][:name]
264
+ assert_equal 'Recreation Day', Holidays.on(Date.civil(2014, 11, 3), :au_tas_north)[0][:name]
265
+ assert_equal 'Recreation Day', Holidays.on(Date.civil(2015, 11, 2), :au_tas_north)[0][:name]
266
+ assert_equal 'Recreation Day', Holidays.on(Date.civil(2016, 11, 7), :au_tas_north)[0][:name]
260
267
 
261
- assert_equal 'Melbourne Cup Day', Date.civil(2014,11,4).holidays(:au_vic)[0][:name]
262
- assert_equal 'Melbourne Cup Day', Date.civil(2015,11,3).holidays(:au_vic)[0][:name]
268
+ assert_nil Date.civil(2014,11,4).holidays(:au_vic)[0]
269
+ assert_nil Date.civil(2015,11,3).holidays(:au_vic)[0]
263
270
 
264
- assert_equal 'Royal Hobart Regatta', Date.civil(2012, 2, 13).holidays(:au_tas_south)[0][:name]
265
- assert_equal 'Royal Hobart Regatta', Date.civil(2014, 2, 10).holidays(:au_tas_south)[0][:name]
266
- assert_equal 'Royal Hobart Regatta', Date.civil(2015, 2, 9).holidays(:au_tas_south)[0][:name]
267
- assert_equal 'Royal Hobart Regatta', Date.civil(2016, 2, 8).holidays(:au_tas_south)[0][:name]
271
+ assert_equal 'Melbourne Cup Day', Holidays.on(Date.civil(2014,11,4), :au_vic_melbourne)[0][:name]
272
+ assert_equal 'Melbourne Cup Day', Holidays.on(Date.civil(2015,11,3), :au_vic_melbourne)[0][:name]
273
+
274
+ assert_equal 'Friday before the AFL Grand Final', Date.civil(2015,10,2).holidays(:au_vic)[0][:name]
275
+ assert_nil Date.civil(2016,10,2).holidays(:au_vic)[0]
268
276
 
269
277
  assert_equal "May Public Holiday", Date.civil(2005, 5, 16).holidays(:au_sa)[0][:name]
270
278
  assert_equal [], Date.civil(2014, 5, 19).holidays(:au_sa)
@@ -278,4 +286,25 @@ tests: |
278
286
  assert_equal "ANZAC Day", Date.civil(2015, 4, 25).holidays(:au_qld)[0][:name]
279
287
  assert_equal "ANZAC Day", Date.civil(2015, 4, 25).holidays(:au_wa)[0][:name]
280
288
  assert_equal [], Date.civil(2015, 4, 27).holidays(:au_qld, :observed)
281
- assert_equal "ANZAC Day", Date.civil(2015, 4, 27).holidays(:au_wa, :observed)[0][:name]
289
+ assert_equal "ANZAC Day", Date.civil(2015, 4, 27).holidays(:au_wa, :observed)[0][:name]
290
+
291
+ # BOXING DAY - QLD observes weekend and monday
292
+ assert_equal "Boxing Day", Date.civil(2015, 12, 26).holidays(:au_qld)[0][:name]
293
+ assert_equal "Boxing Day", Date.civil(2015, 12, 28).holidays(:au_qld, :observed)[0][:name]
294
+
295
+ # BOXING DAY - SA gets monday only. same for TAS and NT.
296
+ assert_nil Date.civil(2015, 12, 26).holidays(:au_sa)[0]
297
+ assert_equal "Boxing Day", Date.civil(2015, 12, 28).holidays(:au_sa)[0][:name]
298
+ assert_nil Date.civil(2015, 12, 26).holidays(:au_tas)[0]
299
+ assert_equal "Boxing Day", Date.civil(2015, 12, 28).holidays(:au_tas)[0][:name]
300
+ assert_nil Date.civil(2015, 12, 26).holidays(:au_nt)[0]
301
+ assert_equal "Boxing Day", Date.civil(2015, 12, 28).holidays(:au_nt)[0][:name]
302
+
303
+ assert_equal 'G20 Day', Holidays.on(Date.civil(2014,11,14), :au_qld_brisbane)[0][:name]
304
+ assert_equal [], Holidays.on(Date.civil(2014,11,14), :au_qld)
305
+ assert_equal [], Holidays.on(Date.civil(2015,11,14), :au_qld_brisbane)
306
+
307
+ assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2012, 2, 13), :au_tas_south)[0][:name]
308
+ assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2014, 2, 10), :au_tas_south)[0][:name]
309
+ assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2015, 2, 9), :au_tas_south)[0][:name]
310
+ assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2016, 2, 8), :au_tas_south)[0][:name]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -7,7 +7,7 @@
7
7
  # - http://www.germany.info/relaunch/welcome/travel/holidays.html
8
8
  ---
9
9
  months:
10
- 0:
10
+ 0:
11
11
  - name: Karfreitag
12
12
  regions: [de]
13
13
  function: easter(year)-2
@@ -23,22 +23,25 @@ months:
23
23
  - name: Fronleichnam
24
24
  regions: [de_bw, de_by, de_he, de_nw, de_rp, de_sl]
25
25
  function: easter(year)+60
26
- 1:
26
+ 1:
27
27
  - name: Neujahrstag
28
28
  regions: [de]
29
29
  mday: 1
30
30
  - name: Heilige Drei Könige
31
31
  regions: [de_bw, de_by, de_st]
32
32
  mday: 6
33
- 5:
33
+ 5:
34
34
  - name: Tag der Arbeit
35
35
  regions: [de]
36
36
  mday: 1
37
- 8:
37
+ 8:
38
38
  - name: Mariä Himmelfahrt
39
39
  regions: [de_by, de_sl]
40
40
  mday: 15
41
- 10:
41
+ - name: Friedensfest
42
+ regions: [de_by_aux]
43
+ mday: 8
44
+ 10:
42
45
  - name: Tag der Deutschen Einheit
43
46
  regions: [de]
44
47
  mday: 3
@@ -85,53 +88,41 @@ tests: |
85
88
  end
86
89
 
87
90
  [:de_bw, :de_by, :de_st, :de_].each do |r|
88
- assert_equal 'Heilige Drei Könige', Date.civil(2009,1,6).holidays(r)[0][:name]
91
+ assert_equal 'Heilige Drei Könige', Holidays.on(Date.civil(2009,1,6), r)[0][:name]
89
92
  end
90
93
 
91
94
  [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_].each do |r|
92
- assert_equal 'Fronleichnam', Date.civil(2009,6,11).holidays(r)[0][:name]
95
+ assert_equal 'Fronleichnam', Holidays.on(Date.civil(2009,6,11), r)[0][:name]
93
96
  end
94
97
 
95
98
  [:de_by, :de_sl, :de_].each do |r|
96
- assert_equal 'Mariä Himmelfahrt', Date.civil(2009,8,15).holidays(r)[0][:name]
99
+ assert_equal 'Mariä Himmelfahrt', Holidays.on(Date.civil(2009,8,15), r)[0][:name]
97
100
  end
98
101
 
99
102
  [:de_bb, :de_mv, :de_sn, :de_st, :de_th, :de_].each do |r|
100
- assert_equal 'Reformationstag', Date.civil(2009,10,31).holidays(r)[0][:name]
103
+ assert_equal 'Reformationstag', Holidays.on(Date.civil(2009,10,31), r)[0][:name]
101
104
  end
102
105
 
103
106
  [:de_bw, :de_by, :de_nw, :de_rp, :de_sl, :de_].each do |r|
104
- assert_equal 'Allerheiligen', Date.civil(2009,11,1).holidays(r)[0][:name]
105
- end
106
-
107
- [:de_be, :de_hb, :de_hh, :de_ni, :de_sh].each do |r|
108
- assert_equal 'Tag der Deutschen Einheit', Date.civil(2009,10,3).holidays(r)[0][:name]
109
- end
110
-
111
- [:de_be, :de_hb, :de_hh, :de_ni, :de_sh].each do |r|
112
- assert !Date.civil(2009,1,6).holiday?(r), "Heilige Drei Könige is not a holiday in #{r}"
107
+ assert_equal 'Allerheiligen', Holidays.on(Date.civil(2009,11,1), r)[0][:name]
113
108
  end
114
109
 
115
- [:de_be, :de_hb, :de_hh, :de_ni, :de_sh].each do |r|
116
- assert !Date.civil(2009,6,11).holiday?(r), "Fronleichnam is not a holiday in #{r}"
110
+ [:de_by_aux].each do |r|
111
+ assert_equal 'Friedensfest', Date.civil(2015,8,8).holidays(r)[0][:name]
117
112
  end
118
113
 
119
- [:de_be, :de_hb, :de_hh, :de_ni, :de_sh].each do |r|
120
- assert !Date.civil(2009,8,15).holiday?(r), "Mariä Himmelfahrt is not a holiday in #{r}"
114
+ [:de,
115
+ :de_bw, :de_by, :de_bb, :de_he, :de_mv,
116
+ :de_nw, :de_rp, :de_sl, :de_sn, :de_st, :de_th].each do |r|
117
+ assert_equal [], Holidays.on(Date.civil(2015,8,8), r), "Friedensfest is not a holiday in #{r}"
121
118
  end
122
119
 
123
- [:de_be, :de_hb, :de_hh, :de_ni, :de_sh].each do |r|
124
- assert !Date.civil(2009,10,31).holiday?(r), 'Reformationstag is not a holiday in #{r}'
125
- end
126
-
127
- [:de_be, :de_hb, :de_hh, :de_ni, :de_sh].each do |r|
128
- assert !Date.civil(2009,11,1).holiday?(r), "Allerheiligen is not a holiday in #{r}"
129
- end
120
+ assert_equal [], Holidays.on(Date.civil(2010,5,8), :de), '2010-05-08 is not a holiday in Germany'
130
121
 
131
- assert !Date.civil(2010,5,8).holiday?(:de), '2010-05-08 is not a holiday in Germany'
122
+ assert_equal [], Holidays.on(Date.civil(2010,8,8), :de), '2010-08-08 is not a holiday in Germany'
132
123
 
133
124
  # Repentance Day
134
- assert_equal 'Buß- und Bettag', Date.civil(2004,11,17).holidays(:de_sn)[0][:name]
135
- assert_equal 'Buß- und Bettag', Date.civil(2005,11,16).holidays(:de_sn)[0][:name]
136
- assert_equal 'Buß- und Bettag', Date.civil(2006,11,22).holidays(:de_sn)[0][:name]
137
- assert_equal 'Buß- und Bettag', Date.civil(2009,11,18).holidays(:de_sn)[0][:name]
125
+ assert_equal 'Buß- und Bettag', Holidays.on(Date.civil(2004,11,17), :de_sn)[0][:name]
126
+ assert_equal 'Buß- und Bettag', Holidays.on(Date.civil(2005,11,16), :de_sn)[0][:name]
127
+ assert_equal 'Buß- und Bettag', Holidays.on(Date.civil(2006,11,22), :de_sn)[0][:name]
128
+ assert_equal 'Buß- und Bettag', Holidays.on(Date.civil(2009,11,18), :de_sn)[0][:name]