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
File without changes
@@ -38,5 +38,5 @@ tests: |
38
38
  assert_equal name, (Holidays.on(date, :ecb_target)[0] || {})[:name]
39
39
  end
40
40
 
41
- assert_equal 'Good Friday', Date.civil(2013,3,29).holidays(:ecb_target)[0][:name]
42
- assert_equal 'Easter Monday', Date.civil(2013,4,1).holidays(:ecb_target)[0][:name]
41
+ assert_equal 'Good Friday', Holidays.on(Date.civil(2013,3,29), :ecb_target)[0][:name]
42
+ assert_equal 'Easter Monday', Holidays.on(Date.civil(2013,4,1), :ecb_target)[0][:name]
File without changes
@@ -13,7 +13,7 @@
13
13
  months:
14
14
  0:
15
15
  - name: Jueves Santo
16
- regions: [es_pv, es_ct, es_na, es_v, es_vc, es_an]
16
+ regions: [es_pv, es_na, es_an, es_ib, es_cm, es_mu, es_m, es_ar, es_cl, es_cn, es_lo, es_ga, es_ce, es_o, es_ex]
17
17
  function: easter(year)-3
18
18
  - name: Viernes Santo
19
19
  regions: [es]
@@ -45,11 +45,11 @@ months:
45
45
  mday: 19
46
46
  observed: to_monday_if_sunday
47
47
  4:
48
- - name: San Jorge
49
- regions: [es_ar, es_cl]
48
+ - name: Día de Castilla y León
49
+ regions: [es_cl]
50
50
  mday: 23
51
51
  observed: to_monday_if_sunday
52
- - name: Día de Aragón
52
+ - name: San Jorge, Día de Aragón
53
53
  regions: [es_ar]
54
54
  mday: 23
55
55
  observed: to_monday_if_sunday
@@ -150,40 +150,51 @@ tests: |
150
150
  assert_equal name, (Holidays.on(date, :es, :informal)[0] || {})[:name]
151
151
  end
152
152
 
153
+ [:es_pv, :es_na, :es_an, :es_ib, :es_cm, :es_mu, :es_m, :es_ar, :es_cl, :es_cn, :es_lo, :es_ga, :es_ce, :es_o, :es_ex, :es_].each do |r|
154
+ assert_equal 'Jueves Santo', Holidays.on(Date.civil(2009,4,9), r)[0][:name]
155
+ end
153
156
  [:es_pv, :es_ct, :es_na, :es_v, :es_vc, :es_].each do |r|
154
- assert_equal 'Jueves Santo', Date.civil(2009,4,9).holidays(r)[0][:name]
155
- assert_equal 'Lunes de Pascua', Date.civil(2009,4,13).holidays(r)[0][:name]
157
+ assert_equal 'Lunes de Pascua', Holidays.on(Date.civil(2009,4,13), r)[0][:name]
156
158
  end
157
159
 
158
- assert_equal 'Jueves Santo', Date.civil(2009,4,9).holidays(:es_an)[0][:name]
160
+ assert_equal 'Jueves Santo', Holidays.on(Date.civil(2009,4,9), :es_an)[0][:name]
159
161
 
160
162
  [:es_v, :es_vc, :es_cm, :es_mu, :es_m, :es_].each do |r|
161
- assert_equal 'San José', Date.civil(2009,3,19).holidays(r)[0][:name]
163
+ assert_equal 'San José', Holidays.on(Date.civil(2009,3,19), r)[0][:name]
164
+ end
165
+
166
+ [:es_cl].each do |r|
167
+ assert_equal 'Día de Castilla y León', Holidays.on(Date.civil(2009,4,23), r)[0][:name]
168
+ end
169
+
170
+ [:es_ar].each do |r|
171
+ assert_equal 'San Jorge, Día de Aragón', Holidays.on(Date.civil(2009,4,23), r)[0][:name]
162
172
  end
163
173
 
164
- [:es_ar, :es_cl, :es_].each do |r|
165
- assert_equal 'San Jorge', Date.civil(2009,4,23).holidays(r)[0][:name]
174
+ [:es_].each do |r|
175
+ assert_equal 'Día de Castilla y León', Holidays.on(Date.civil(2009,4,23), r)[0][:name]
176
+ assert_equal 'San Jorge, Día de Aragón', Holidays.on(Date.civil(2009,4,23), r)[1][:name]
166
177
  end
167
178
 
168
179
  [:es_vc, :es_v, :es_].each do |r|
169
- assert_equal 'Día de Valencia', Date.civil(2009,10,9).holidays(r)[0][:name]
180
+ assert_equal 'Día de Valencia', Holidays.on(Date.civil(2009,10,9), r)[0][:name]
170
181
  end
171
182
 
172
183
  [:es_ib, :es_ct, :es_].each do |r|
173
- assert_equal 'San Esteban', Date.civil(2009,12,26).holidays(r)[0][:name]
184
+ assert_equal 'San Esteban', Holidays.on(Date.civil(2009,12,26), r)[0][:name]
174
185
  end
175
186
 
176
- assert_equal 'Año Nuevo', Date.civil(2012,1,1).holidays(:es)[0][:name]
177
- assert_equal 'Año Nuevo', Date.civil(2012,1,2).holidays(:es, :observed)[0][:name]
178
- assert_equal 'Día de Andalucía', Date.civil(2009,2,28).holidays(:es_an)[0][:name]
179
- assert_equal 'Día de las Islas Baleares', Date.civil(2009,3,1).holidays(:es_ib)[0][:name]
180
- assert_equal 'Fiesta de la Comunidad', Date.civil(2006,5,2).holidays(:es_m)[0][:name]
181
- assert_equal 'Día de las Canarias', Date.civil(2006,5,30).holidays(:es_cn)[0][:name]
182
- assert_equal 'Día de la Región Castilla-La Mancha', Date.civil(2009,5,31).holidays(:es_cm)[0][:name]
183
- assert_equal 'Día de la Región de Murcia', Date.civil(2009,6,9).holidays(:es_mu)[0][:name]
184
- assert_equal 'Día de La Rioja', Date.civil(2009,6,9).holidays(:es_lo)[0][:name]
185
- assert_equal 'Santiago Apostol', Date.civil(2009,7,23).holidays(:es_ga)[0][:name]
186
- assert_equal 'Día de Ceuta', Date.civil(2009,9,2).holidays(:es_ce)[0][:name]
187
- assert_equal 'Día de Asturias', Date.civil(2009,9,8).holidays(:es_o)[0][:name]
188
- assert_equal 'Día de Extremadura', Date.civil(2009,9,8).holidays(:es_ex)[0][:name]
189
- assert_equal 'Fiesta Nacional de Cataluña', Date.civil(2009,9,11).holidays(:es_ct)[0][:name]
187
+ assert_equal 'Año Nuevo', Holidays.on(Date.civil(2012,1,1), :es)[0][:name]
188
+ assert_equal 'Año Nuevo', Holidays.on(Date.civil(2012,1,2), :es, :observed)[0][:name]
189
+ assert_equal 'Día de Andalucía', Holidays.on(Date.civil(2009,2,28), :es_an)[0][:name]
190
+ assert_equal 'Día de las Islas Baleares', Holidays.on(Date.civil(2009,3,1), :es_ib)[0][:name]
191
+ assert_equal 'Fiesta de la Comunidad', Holidays.on(Date.civil(2006,5,2), :es_m)[0][:name]
192
+ assert_equal 'Día de las Canarias', Holidays.on(Date.civil(2006,5,30), :es_cn)[0][:name]
193
+ assert_equal 'Día de la Región Castilla-La Mancha', Holidays.on(Date.civil(2009,5,31), :es_cm)[0][:name]
194
+ assert_equal 'Día de la Región de Murcia', Holidays.on(Date.civil(2009,6,9), :es_mu)[0][:name]
195
+ assert_equal 'Día de La Rioja', Holidays.on(Date.civil(2009,6,9), :es_lo)[0][:name]
196
+ assert_equal 'Santiago Apostol', Holidays.on(Date.civil(2009,7,23), :es_ga)[0][:name]
197
+ assert_equal 'Día de Ceuta', Holidays.on(Date.civil(2009,9,2), :es_ce)[0][:name]
198
+ assert_equal 'Día de Asturias', Holidays.on(Date.civil(2009,9,8), :es_o)[0][:name]
199
+ assert_equal 'Día de Extremadura', Holidays.on(Date.civil(2009,9,8), :es_ex)[0][:name]
200
+ assert_equal 'Fiesta Nacional de Cataluña', Holidays.on(Date.civil(2009,9,11), :es_ct)[0][:name]
File without changes
@@ -32,9 +32,8 @@ months:
32
32
  regions: [fedex]
33
33
  wday: 4
34
34
  - name: Day After Thanksgiving
35
- week: 4
35
+ function: day_after_thanksgiving(year)
36
36
  regions: [fedex]
37
- wday: 5
38
37
  12:
39
38
  - name: Christmas Day
40
39
  regions: [fedex]
@@ -43,6 +42,11 @@ months:
43
42
  - name: New Year's Eve
44
43
  regions: [fedex]
45
44
  mday: 31
45
+ methods:
46
+ day_after_thanksgiving: |
47
+ def self.day_after_thanksgiving(year)
48
+ Date.calculate_mday(year, 11, 4, 4) + 1
49
+ end
46
50
  tests: |
47
51
  {Date.civil(2015,1,1) => 'New Year\'s Day',
48
52
  Date.civil(2015,5,25) => 'Memorial Day',
@@ -50,7 +54,9 @@ tests: |
50
54
  Date.civil(2015,9,7) => 'Labor Day',
51
55
  Date.civil(2015,11,26) => 'Thanksgiving',
52
56
  Date.civil(2015,11,27) => 'Day After Thanksgiving',
57
+ Date.civil(2013,11,28) => 'Thanksgiving',
58
+ Date.civil(2013,11,29) => 'Day After Thanksgiving',
53
59
  Date.civil(2015,12,25) => 'Christmas Day',
54
60
  Date.civil(2015,12,31) => 'New Year\'s Eve',}.each do |date, name|
55
61
  assert_equal name, (Holidays.on(date, :ups)[0] || {})[:name]
56
- end
62
+ end
File without changes
File without changes
@@ -96,29 +96,29 @@ tests: |
96
96
  assert_equal name, (Holidays.on(date, :gb, :informal)[0] || {})[:name]
97
97
  end
98
98
 
99
- assert_equal 'St. Patrick\'s Day', Date.civil(2008,3,17).holidays(:gb_nir, :informal)[0][:name]
100
- assert_equal 'St. Andrew\'s Day', Date.civil(2008,11,30).holidays(:gb_sct, :informal)[0][:name]
99
+ assert_equal 'St. Patrick\'s Day', Holidays.on(Date.civil(2008,3,17), :gb_nir, :informal)[0][:name]
100
+ assert_equal 'St. Andrew\'s Day', Holidays.on(Date.civil(2008,11,30), :gb_sct, :informal)[0][:name]
101
101
 
102
- assert_equal 'Christmas Day', Date.civil(2008,12,25).holidays(:gb_, :observed)[0][:name]
103
- assert_equal 'Christmas Day', Date.civil(2009,12,25).holidays(:gb_, :observed)[0][:name]
104
- assert_equal 'Christmas Day', Date.civil(2010,12,27).holidays(:gb_, :observed)[0][:name]
102
+ assert_equal 'Christmas Day', Holidays.on(Date.civil(2008,12,25), :gb_, :observed)[0][:name]
103
+ assert_equal 'Christmas Day', Holidays.on(Date.civil(2009,12,25), :gb_, :observed)[0][:name]
104
+ assert_equal 'Christmas Day', Holidays.on(Date.civil(2010,12,27), :gb_, :observed)[0][:name]
105
105
 
106
- assert_equal 'Boxing Day', Date.civil(2008,12,26).holidays(:gb_, :observed)[0][:name]
107
- assert_equal 'Boxing Day', Date.civil(2009,12,28).holidays(:gb_, :observed)[0][:name]
108
- assert_equal 'Boxing Day', Date.civil(2010,12,28).holidays(:gb_, :observed)[0][:name]
109
- assert_equal 'Boxing Day', Date.civil(2011,12,27).holidays(:gb_, :observed)[0][:name]
106
+ assert_equal 'Boxing Day', Holidays.on(Date.civil(2008,12,26), :gb_, :observed)[0][:name]
107
+ assert_equal 'Boxing Day', Holidays.on(Date.civil(2009,12,28), :gb_, :observed)[0][:name]
108
+ assert_equal 'Boxing Day', Holidays.on(Date.civil(2010,12,28), :gb_, :observed)[0][:name]
109
+ assert_equal 'Boxing Day', Holidays.on(Date.civil(2011,12,27), :gb_, :observed)[0][:name]
110
110
 
111
- assert_equal 'New Year\'s Day', Date.civil(2010,1,1).holidays(:gb, :observed)[0][:name]
112
- assert_equal 'New Year\'s Day', Date.civil(2011,1,3).holidays(:gb, :observed)[0][:name]
113
- assert_equal 'New Year\'s Day', Date.civil(2012,1,2).holidays(:gb, :observed)[0][:name]
111
+ assert_equal 'New Year\'s Day', Holidays.on(Date.civil(2010,1,1), :gb, :observed)[0][:name]
112
+ assert_equal 'New Year\'s Day', Holidays.on(Date.civil(2011,1,3), :gb, :observed)[0][:name]
113
+ assert_equal 'New Year\'s Day', Holidays.on(Date.civil(2012,1,2), :gb, :observed)[0][:name]
114
114
 
115
- assert_equal '2nd January', Date.civil(2010,1,4).holidays(:gb_sct, :observed)[0][:name]
116
- assert_equal '2nd January', Date.civil(2011,1,4).holidays(:gb_sct, :observed)[0][:name]
117
- assert_equal '2nd January', Date.civil(2012,1,3).holidays(:gb_sct, :observed)[0][:name]
118
- assert_equal '2nd January', Date.civil(2013,1,2).holidays(:gb_sct, :observed)[0][:name]
119
- assert_equal '2nd January', Date.civil(2014,1,2).holidays(:gb_sct, :observed)[0][:name]
115
+ assert_equal '2nd January', Holidays.on(Date.civil(2010,1,4), :gb_sct, :observed)[0][:name]
116
+ assert_equal '2nd January', Holidays.on(Date.civil(2011,1,4), :gb_sct, :observed)[0][:name]
117
+ assert_equal '2nd January', Holidays.on(Date.civil(2012,1,3), :gb_sct, :observed)[0][:name]
118
+ assert_equal '2nd January', Holidays.on(Date.civil(2013,1,2), :gb_sct, :observed)[0][:name]
119
+ assert_equal '2nd January', Holidays.on(Date.civil(2014,1,2), :gb_sct, :observed)[0][:name]
120
120
 
121
121
  [:gb_wls, :gb_eng, :gb_nir, :gb_eaw, :gb_].each do |r|
122
- assert_equal 'Easter Monday', Date.civil(2008,3,24).holidays(r)[0][:name]
123
- assert_equal 'Bank Holiday', Date.civil(2008,8,25).holidays(r)[0][:name]
122
+ assert_equal 'Easter Monday', Holidays.on(Date.civil(2008,3,24), r)[0][:name]
123
+ assert_equal 'Bank Holiday', Holidays.on(Date.civil(2008,8,25), r)[0][:name]
124
124
  end
File without changes
@@ -58,4 +58,4 @@ tests: |
58
58
  assert_equal name, (Holidays.on(date, :hu, :informal)[0] || {})[:name]
59
59
  end
60
60
 
61
- assert !Date.civil(2012,3,14).holiday?(:hu), '2012-03-14 is not a holiday in Hungary'
61
+ assert_equal [], Holidays.on(Date.civil(2012,3,14), :hu), '2012-03-14 is not a holiday in Hungary'
File without changes
File without changes
File without changes
File without changes
@@ -71,7 +71,7 @@ months:
71
71
  week: 3
72
72
  - name: 振替休日
73
73
  regions: [jp]
74
- function: jp_substitute_holiday(year, 7, Date.calculate_mday(year, 7, 3, 1))
74
+ function: jp_substitute_holiday(year, 7, Holidays.calculate_day_of_month(year, 7, 3, 1))
75
75
  9:
76
76
  - name: 敬老の日
77
77
  regions: [jp]
@@ -79,7 +79,7 @@ months:
79
79
  week: 3
80
80
  - name: 振替休日
81
81
  regions: [jp]
82
- function: jp_substitute_holiday(year, 9, Date.calculate_mday(year, 9, 3, 1))
82
+ function: jp_substitute_holiday(year, 9, Holidays.calculate_day_of_month(year, 9, 3, 1))
83
83
  - name: 国民の休日
84
84
  regions: [jp]
85
85
  function: jp_citizons_holiday(year)
@@ -96,7 +96,7 @@ months:
96
96
  week: 2
97
97
  - name: 振替休日
98
98
  regions: [jp]
99
- function: jp_substitute_holiday(year, 10, Date.calculate_mday(year, 10, 2, 1))
99
+ function: jp_substitute_holiday(year, 10, Holidays.calculate_day_of_month(year, 10, 2, 1))
100
100
  11:
101
101
  - name: 文化の日
102
102
  regions: [jp]
@@ -89,14 +89,14 @@ tests: |
89
89
  end
90
90
 
91
91
  [:li].each do |r|
92
- assert_equal 'Fronleichnam', Date.civil(2009,6,11).holidays(r)[0][:name]
92
+ assert_equal 'Fronleichnam', Holidays.on(Date.civil(2009,6,11), r)[0][:name]
93
93
  end
94
94
 
95
95
  [:li].each do |r|
96
- assert_equal 'Staatsfeiertag', Date.civil(2009,8,15).holidays(r)[0][:name]
96
+ assert_equal 'Staatsfeiertag', Holidays.on(Date.civil(2009,8,15), r)[0][:name]
97
97
  end
98
98
 
99
99
  [:li].each do |r|
100
- assert_equal 'Allerheiligen', Date.civil(2009,11,1).holidays(r)[0][:name]
100
+ assert_equal 'Allerheiligen', Holidays.on(Date.civil(2009,11,1), r)[0][:name]
101
101
  end
102
102
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -40,7 +40,7 @@ months:
40
40
  observed: closest_monday
41
41
  2:
42
42
  - name: Nelson Anniversary Day
43
- regions: [nz_ak]
43
+ regions: [nz_ne]
44
44
  mday: 1
45
45
  observed: closest_monday
46
46
  - name: Waitangi Day
@@ -53,9 +53,10 @@ months:
53
53
  mday: 23
54
54
  observed: closest_monday
55
55
  - name: Taranaki Anniversary Day
56
- regions: [nz_ak]
56
+ regions: [nz_ta]
57
57
  week: 2
58
58
  wday: 1
59
+ observed: closest_monday
59
60
  4:
60
61
  - name: ANZAC Day
61
62
  regions: [nz]
@@ -119,14 +120,24 @@ tests: |
119
120
  Date.civil(2007,12,26) => 'Boxing Day'}.each do |date, name|
120
121
  assert_equal name, (Holidays.on(date, :nz, :informal)[0] || {})[:name]
121
122
  end
122
- assert_equal 'ANZAC Day', Date.civil(2015, 4, 25).holidays(:nz)[0][:name]
123
- assert_equal 'ANZAC Day', Date.civil(2015, 4, 27).holidays(:nz, :observed)[0][:name]
124
- assert_equal 'ANZAC Day', Date.civil(2016, 4, 25).holidays(:nz)[0][:name]
125
- assert_equal 'ANZAC Day', Date.civil(2016, 4, 25).holidays(:nz, :observed)[0][:name]
126
- assert_equal 'Waitangi Day', Date.civil(2015, 2, 6).holidays(:nz)[0][:name]
127
- assert_equal 'Waitangi Day', Date.civil(2015, 2, 6).holidays(:nz, :observed)[0][:name]
128
- assert_equal 'Waitangi Day', Date.civil(2016, 2, 6).holidays(:nz)[0][:name]
129
- assert_equal 'Waitangi Day', Date.civil(2016, 2, 8).holidays(:nz, :observed)[0][:name]
123
+ assert_equal 'ANZAC Day', Holidays.on(Date.civil(2015, 4, 25), :nz)[0][:name]
124
+ assert_equal 'ANZAC Day', Holidays.on(Date.civil(2015, 4, 27), :nz, :observed)[0][:name]
125
+ assert_equal 'ANZAC Day', Holidays.on(Date.civil(2016, 4, 25), :nz)[0][:name]
126
+ assert_equal 'ANZAC Day', Holidays.on(Date.civil(2016, 4, 25), :nz, :observed)[0][:name]
127
+ assert_equal 'Waitangi Day', Holidays.on(Date.civil(2015, 2, 6), :nz)[0][:name]
128
+ assert_equal 'Waitangi Day', Holidays.on(Date.civil(2015, 2, 6), :nz, :observed)[0][:name]
129
+ assert_equal 'Waitangi Day', Holidays.on(Date.civil(2016, 2, 6), :nz)[0][:name]
130
+ assert_equal 'Waitangi Day', Holidays.on(Date.civil(2016, 2, 8), :nz, :observed)[0][:name]
131
+
132
+ assert_equal 'Nelson Anniversary Day', Holidays.on(Date.civil(2016, 2, 1), :nz_ne, :observed)[0][:name]
133
+ assert_equal 'Nelson Anniversary Day', Holidays.on(Date.civil(2017, 1, 30), :nz_ne, :observed)[0][:name]
134
+ assert_equal 'Nelson Anniversary Day', Holidays.on(Date.civil(2018, 1, 29), :nz_ne, :observed)[0][:name]
135
+ assert_equal 'Nelson Anniversary Day', Holidays.on(Date.civil(2019, 2, 4), :nz_ne, :observed)[0][:name]
136
+
137
+ assert_equal 'Taranaki Anniversary Day', Holidays.on(Date.civil(2016, 3, 14), :nz_ta, :observed)[0][:name]
138
+ assert_equal 'Taranaki Anniversary Day', Holidays.on(Date.civil(2017, 3, 13), :nz_ta, :observed)[0][:name]
139
+ assert_equal 'Taranaki Anniversary Day', Holidays.on(Date.civil(2018, 3, 12), :nz_ta, :observed)[0][:name]
140
+ assert_equal 'Taranaki Anniversary Day', Holidays.on(Date.civil(2019, 3, 11), :nz_ta, :observed)[0][:name]
130
141
  methods:
131
142
  closest_monday: |
132
143
  def self.closest_monday(date)
File without changes
File without changes
File without changes
@@ -72,5 +72,4 @@ tests: |
72
72
  assert_equal name, (Holidays.on(date, :ro, :informal)[0] || {})[:name]
73
73
  end
74
74
 
75
- assert !Date.civil(2013,7,23).holiday?(:ro), '2010-07-23 is not a holiday in Romania'
76
- assert !Date.civil(2013,7,23).holiday?(:ro), '2010-07-23 is not a holiday in Romania'
75
+ assert_equal [], Holidays.on(Date.civil(2013,7,23), :ro), '2013-07-23 is not a holiday in Romania'
File without changes
File without changes
@@ -58,14 +58,14 @@ months:
58
58
  regions: [si]
59
59
  mday: 26
60
60
  tests: |
61
- assert_equal 'velikonočna nedelja', Date.civil(2015,4,5).holidays(:si)[0][:name]
62
- assert_equal 'velikonočna nedelja', Date.civil(2016,3,27).holidays(:si)[0][:name]
61
+ assert_equal 'velikonočna nedelja', Holidays.on(Date.civil(2015,4,5), :si)[0][:name]
62
+ assert_equal 'velikonočna nedelja', Holidays.on(Date.civil(2016,3,27), :si)[0][:name]
63
63
 
64
- assert_equal 'velikonočni ponedeljek', Date.civil(2015,4,6).holidays(:si)[0][:name]
65
- assert_equal 'velikonočni ponedeljek', Date.civil(2016,3,28).holidays(:si)[0][:name]
64
+ assert_equal 'velikonočni ponedeljek', Holidays.on(Date.civil(2015,4,6), :si)[0][:name]
65
+ assert_equal 'velikonočni ponedeljek', Holidays.on(Date.civil(2016,3,28), :si)[0][:name]
66
66
 
67
- assert_equal 'binkošti', Date.civil(2015,5,24).holidays(:si)[0][:name]
68
- assert_equal 'binkošti', Date.civil(2016,5,15).holidays(:si)[0][:name]
67
+ assert_equal 'binkošti', Holidays.on(Date.civil(2015,5,24), :si)[0][:name]
68
+ assert_equal 'binkošti', Holidays.on(Date.civil(2016,5,15), :si)[0][:name]
69
69
 
70
70
  (2014..2020).each do |year|
71
71
  {Date.civil(year,1,1) => 'novo leto',
File without changes
File without changes
@@ -4,38 +4,37 @@
4
4
  #
5
5
  # Updated: 2008-09-23.
6
6
  # Source: http://www.ups.com/content/us/en/resources/ship/imp_exp/operation.html
7
- ---
7
+ ---
8
8
  months:
9
- 1:
9
+ 1:
10
10
  - name: New Year's Day
11
11
  regions: [ups]
12
12
  mday: 1
13
13
  observed: to_weekday_if_weekend
14
- 5:
14
+ 5:
15
15
  - name: Memorial Day
16
16
  week: -1
17
17
  regions: [ups]
18
18
  wday: 1
19
- 7:
19
+ 7:
20
20
  - name: Independence Day
21
21
  regions: [ups]
22
22
  mday: 4
23
23
  observed: to_weekday_if_weekend
24
- 9:
24
+ 9:
25
25
  - name: Labor Day
26
26
  week: 1
27
27
  regions: [ups]
28
28
  wday: 1
29
- 11:
29
+ 11:
30
30
  - name: Thanksgiving
31
31
  week: 4
32
32
  regions: [ups]
33
33
  wday: 4
34
34
  - name: Day After Thanksgiving
35
- week: 4
35
+ function: day_after_thanksgiving(year)
36
36
  regions: [ups]
37
- wday: 5
38
- 12:
37
+ 12:
39
38
  - name: Christmas Day
40
39
  regions: [ups]
41
40
  mday: 25
@@ -43,14 +42,21 @@ months:
43
42
  - name: New Year's Eve
44
43
  regions: [ups]
45
44
  mday: 31
45
+ methods:
46
+ day_after_thanksgiving: |
47
+ def self.day_after_thanksgiving(year)
48
+ Date.calculate_mday(year, 11, 4, 4) + 1
49
+ end
46
50
  tests: |
47
- {Date.civil(2008,1,1) => 'New Year\'s Day',
51
+ {Date.civil(2008,1,1) => 'New Year\'s Day',
48
52
  Date.civil(2008,5,26) => 'Memorial Day',
49
53
  Date.civil(2008,7,4) => 'Independence Day',
50
54
  Date.civil(2008,9,1) => 'Labor Day',
51
55
  Date.civil(2008,11,27) => 'Thanksgiving',
52
56
  Date.civil(2008,11,28) => 'Day After Thanksgiving',
57
+ Date.civil(2013,11,28) => 'Thanksgiving',
58
+ Date.civil(2013,11,29) => 'Day After Thanksgiving',
53
59
  Date.civil(2008,12,25) => 'Christmas Day',
54
60
  Date.civil(2008,12,31) => 'New Year\'s Eve',}.each do |date, name|
55
61
  assert_equal name, (Holidays.on(date, :ups)[0] || {})[:name]
56
- end
62
+ end