holidays 4.2.0 → 8.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (330) hide show
  1. checksums.yaml +5 -5
  2. data/.gitmodules +3 -0
  3. data/CHANGELOG.md +195 -0
  4. data/Makefile +45 -0
  5. data/README.md +253 -77
  6. data/Rakefile +10 -11
  7. data/bin/console +0 -0
  8. data/bin/setup +1 -0
  9. data/doc/CONTRIBUTING.md +72 -0
  10. data/doc/MAINTAINERS.md +81 -0
  11. data/{REFERENCES → doc/REFERENCES} +0 -0
  12. data/holidays.gemspec +9 -9
  13. data/lib/generated_definitions/MANIFEST +26 -4
  14. data/lib/generated_definitions/REGIONS.rb +3 -1
  15. data/lib/generated_definitions/ar.rb +4 -10
  16. data/lib/generated_definitions/at.rb +3 -9
  17. data/lib/generated_definitions/au.rb +32 -25
  18. data/lib/generated_definitions/be_fr.rb +2 -8
  19. data/lib/generated_definitions/be_nl.rb +2 -8
  20. data/lib/generated_definitions/bg.rb +2 -8
  21. data/lib/generated_definitions/br.rb +2 -8
  22. data/lib/generated_definitions/ca.rb +33 -32
  23. data/lib/generated_definitions/ch.rb +17 -11
  24. data/lib/generated_definitions/cl.rb +38 -12
  25. data/lib/generated_definitions/co.rb +121 -0
  26. data/lib/generated_definitions/cr.rb +2 -8
  27. data/lib/generated_definitions/cz.rb +2 -8
  28. data/lib/generated_definitions/de.rb +11 -14
  29. data/lib/generated_definitions/dk.rb +2 -8
  30. data/lib/generated_definitions/{ecb_target.rb → ecbtarget.rb} +10 -16
  31. data/lib/generated_definitions/ee.rb +36 -0
  32. data/lib/generated_definitions/el.rb +2 -8
  33. data/lib/generated_definitions/es.rb +8 -11
  34. data/lib/generated_definitions/europe.rb +121 -51
  35. data/lib/generated_definitions/federalreserve.rb +34 -0
  36. data/lib/generated_definitions/{federal_reserve.rb → federalreservebanks.rb} +14 -20
  37. data/lib/generated_definitions/fedex.rb +3 -9
  38. data/lib/generated_definitions/fi.rb +2 -8
  39. data/lib/generated_definitions/fr.rb +6 -10
  40. data/lib/generated_definitions/gb.rb +12 -16
  41. data/lib/generated_definitions/ge.rb +41 -0
  42. data/lib/generated_definitions/hk.rb +106 -0
  43. data/lib/generated_definitions/hr.rb +10 -14
  44. data/lib/generated_definitions/hu.rb +4 -9
  45. data/lib/generated_definitions/ie.rb +3 -17
  46. data/lib/generated_definitions/is.rb +3 -9
  47. data/lib/generated_definitions/it.rb +16 -13
  48. data/lib/generated_definitions/jp.rb +47 -36
  49. data/lib/generated_definitions/kr.rb +40 -0
  50. data/lib/generated_definitions/kz.rb +38 -0
  51. data/lib/generated_definitions/li.rb +2 -8
  52. data/lib/generated_definitions/lt.rb +2 -8
  53. data/lib/generated_definitions/lu.rb +35 -0
  54. data/lib/generated_definitions/lv.rb +52 -0
  55. data/lib/generated_definitions/ma.rb +2 -8
  56. data/lib/generated_definitions/mt_en.rb +38 -0
  57. data/lib/generated_definitions/mt_mt.rb +38 -0
  58. data/lib/generated_definitions/mx.rb +6 -12
  59. data/lib/generated_definitions/my.rb +30 -0
  60. data/lib/generated_definitions/nerc.rb +2 -8
  61. data/lib/generated_definitions/ng.rb +33 -0
  62. data/lib/generated_definitions/nl.rb +2 -8
  63. data/lib/generated_definitions/no.rb +2 -8
  64. data/lib/generated_definitions/northamerica.rb +223 -0
  65. data/lib/generated_definitions/nyse.rb +3 -9
  66. data/lib/generated_definitions/nz.rb +2 -9
  67. data/lib/generated_definitions/pe.rb +43 -0
  68. data/lib/generated_definitions/ph.rb +4 -10
  69. data/lib/generated_definitions/pl.rb +2 -8
  70. data/lib/generated_definitions/pt.rb +12 -12
  71. data/lib/generated_definitions/ro.rb +6 -9
  72. data/lib/generated_definitions/rs_cyrl.rb +39 -0
  73. data/lib/generated_definitions/rs_la.rb +39 -0
  74. data/lib/generated_definitions/ru.rb +37 -0
  75. data/lib/generated_definitions/scandinavia.rb +3 -9
  76. data/lib/generated_definitions/se.rb +2 -8
  77. data/lib/generated_definitions/sg.rb +2 -8
  78. data/lib/generated_definitions/si.rb +2 -8
  79. data/lib/generated_definitions/sk.rb +2 -8
  80. data/lib/generated_definitions/southamerica.rb +228 -0
  81. data/lib/generated_definitions/th.rb +36 -0
  82. data/lib/generated_definitions/tn.rb +32 -0
  83. data/lib/generated_definitions/tr.rb +64 -0
  84. data/lib/generated_definitions/ua.rb +37 -0
  85. data/lib/generated_definitions/{united_nations.rb → unitednations.rb} +61 -67
  86. data/lib/generated_definitions/ups.rb +3 -9
  87. data/lib/generated_definitions/us.rb +113 -23
  88. data/lib/generated_definitions/ve.rb +2 -8
  89. data/lib/generated_definitions/vi.rb +6 -11
  90. data/lib/generated_definitions/za.rb +2 -8
  91. data/lib/holidays/core_extensions/date.rb +21 -3
  92. data/lib/holidays/core_extensions/time.rb +23 -0
  93. data/lib/holidays/date_calculator/day_of_month.rb +3 -3
  94. data/lib/holidays/date_calculator/lunar_date.rb +371 -0
  95. data/lib/holidays/date_calculator/weekend_modifier.rb +0 -7
  96. data/lib/holidays/definition/context/function_processor.rb +91 -0
  97. data/lib/holidays/definition/context/generator.rb +37 -96
  98. data/lib/holidays/definition/context/load.rb +29 -0
  99. data/lib/holidays/definition/context/merger.rb +0 -4
  100. data/lib/holidays/definition/decorator/test.rb +37 -0
  101. data/lib/holidays/definition/entity/test.rb +11 -0
  102. data/lib/holidays/definition/generator/module.rb +54 -0
  103. data/lib/holidays/definition/generator/regions.rb +55 -0
  104. data/lib/holidays/definition/generator/test.rb +51 -0
  105. data/lib/holidays/definition/parser/custom_method.rb +3 -5
  106. data/lib/holidays/definition/parser/test.rb +86 -0
  107. data/lib/holidays/definition/repository/cache.rb +23 -9
  108. data/lib/holidays/definition/repository/holidays_by_month.rb +10 -2
  109. data/lib/holidays/definition/repository/proc_result_cache.rb +1 -1
  110. data/lib/holidays/definition/repository/regions.rb +23 -13
  111. data/lib/holidays/definition/validator/custom_method.rb +1 -1
  112. data/lib/holidays/definition/validator/region.rb +2 -11
  113. data/lib/holidays/definition/validator/test.rb +71 -0
  114. data/lib/holidays/errors.rb +5 -0
  115. data/lib/holidays/factory/date_calculator.rb +42 -0
  116. data/lib/holidays/factory/definition.rb +143 -0
  117. data/lib/holidays/factory/finder.rb +70 -0
  118. data/lib/holidays/finder/context/between.rb +45 -0
  119. data/lib/holidays/{use_case → finder}/context/dates_driver_builder.rb +11 -15
  120. data/lib/holidays/finder/context/next_holiday.rb +57 -0
  121. data/lib/holidays/finder/context/parse_options.rb +104 -0
  122. data/lib/holidays/finder/context/search.rb +110 -0
  123. data/lib/holidays/finder/context/year_holiday.rb +57 -0
  124. data/lib/holidays/finder/rules/in_region.rb +31 -0
  125. data/lib/holidays/finder/rules/year_range.rb +58 -0
  126. data/lib/holidays/load_all_definitions.rb +16 -17
  127. data/lib/holidays/version.rb +1 -1
  128. data/lib/holidays.rb +50 -125
  129. data/test/coverage_report.rb +26 -0
  130. data/test/data/test_custom_informal_holidays_defs.yaml +11 -0
  131. data/test/data/test_custom_year_range_holiday_defs.yaml +13 -10
  132. data/test/data/test_invalid_region.rb +15 -0
  133. data/test/data/test_multiple_custom_holiday_defs.yaml +7 -4
  134. data/test/data/test_multiple_regions_with_conflicts_region_1.yaml +38 -0
  135. data/test/data/test_multiple_regions_with_conflicts_region_2.yaml +38 -0
  136. data/test/data/test_region.rb +15 -0
  137. data/test/data/test_single_custom_holiday_defs.yaml +7 -4
  138. data/test/data/test_single_custom_holiday_with_custom_procs.yaml +11 -7
  139. data/test/defs/test_defs_ar.rb +41 -19
  140. data/test/defs/test_defs_at.rb +18 -11
  141. data/test/defs/test_defs_au.rb +185 -126
  142. data/test/defs/test_defs_be_fr.rb +33 -14
  143. data/test/defs/test_defs_be_nl.rb +33 -14
  144. data/test/defs/test_defs_bg.rb +29 -17
  145. data/test/defs/test_defs_br.rb +33 -19
  146. data/test/defs/test_defs_ca.rb +246 -136
  147. data/test/defs/test_defs_ch.rb +35 -23
  148. data/test/defs/test_defs_cl.rb +57 -27
  149. data/test/defs/test_defs_co.rb +113 -0
  150. data/test/defs/test_defs_cr.rb +17 -11
  151. data/test/defs/test_defs_cz.rb +25 -15
  152. data/test/defs/test_defs_de.rb +60 -59
  153. data/test/defs/test_defs_dk.rb +31 -19
  154. data/test/defs/test_defs_ecbtarget.rb +27 -0
  155. data/test/defs/test_defs_ee.rb +41 -0
  156. data/test/defs/test_defs_el.rb +29 -17
  157. data/test/defs/test_defs_es.rb +116 -52
  158. data/test/defs/test_defs_europe.rb +1382 -701
  159. data/test/defs/test_defs_federalreserve.rb +113 -0
  160. data/test/defs/test_defs_federalreservebanks.rb +247 -0
  161. data/test/defs/test_defs_fedex.rb +19 -12
  162. data/test/defs/test_defs_fi.rb +47 -27
  163. data/test/defs/test_defs_fr.rb +31 -18
  164. data/test/defs/test_defs_gb.rb +120 -51
  165. data/test/defs/test_defs_ge.rb +53 -0
  166. data/test/defs/test_defs_hk.rb +59 -0
  167. data/test/defs/test_defs_hr.rb +32 -18
  168. data/test/defs/test_defs_hu.rb +34 -16
  169. data/test/defs/test_defs_ie.rb +41 -25
  170. data/test/defs/test_defs_is.rb +39 -22
  171. data/test/defs/test_defs_it.rb +43 -14
  172. data/test/defs/test_defs_jp.rb +141 -55
  173. data/test/defs/test_defs_kr.rb +37 -0
  174. data/test/defs/test_defs_kz.rb +39 -0
  175. data/test/defs/test_defs_li.rb +20 -20
  176. data/test/defs/test_defs_lt.rb +51 -30
  177. data/test/defs/test_defs_lu.rb +35 -0
  178. data/test/defs/test_defs_lv.rb +90 -0
  179. data/test/defs/test_defs_ma.rb +17 -11
  180. data/test/defs/test_defs_mt_en.rb +41 -0
  181. data/test/defs/test_defs_mt_mt.rb +41 -0
  182. data/test/defs/test_defs_mx.rb +34 -23
  183. data/test/defs/test_defs_my.rb +23 -0
  184. data/test/defs/test_defs_nerc.rb +17 -11
  185. data/test/defs/test_defs_ng.rb +29 -0
  186. data/test/defs/test_defs_nl.rb +21 -13
  187. data/test/defs/test_defs_no.rb +31 -18
  188. data/test/defs/test_defs_northamerica.rb +644 -0
  189. data/test/defs/test_defs_nyse.rb +27 -11
  190. data/test/defs/test_defs_nz.rb +47 -28
  191. data/test/defs/test_defs_pe.rb +47 -0
  192. data/test/defs/test_defs_ph.rb +17 -13
  193. data/test/defs/test_defs_pl.rb +200 -119
  194. data/test/defs/test_defs_pt.rb +35 -15
  195. data/test/defs/test_defs_ro.rb +53 -24
  196. data/test/defs/test_defs_rs_cyrl.rb +46 -0
  197. data/test/defs/test_defs_rs_la.rb +46 -0
  198. data/test/defs/test_defs_ru.rb +34 -0
  199. data/test/defs/test_defs_scandinavia.rb +193 -116
  200. data/test/defs/test_defs_se.rb +47 -28
  201. data/test/defs/test_defs_sg.rb +13 -9
  202. data/test/defs/test_defs_si.rb +93 -24
  203. data/test/defs/test_defs_sk.rb +29 -17
  204. data/test/defs/test_defs_southamerica.rb +307 -0
  205. data/test/defs/test_defs_th.rb +33 -0
  206. data/test/defs/test_defs_tn.rb +27 -0
  207. data/test/defs/test_defs_tr.rb +60 -0
  208. data/test/defs/test_defs_ua.rb +41 -0
  209. data/test/defs/{test_defs_united_nations.rb → test_defs_unitednations.rb} +3 -4
  210. data/test/defs/test_defs_ups.rb +19 -12
  211. data/test/defs/test_defs_us.rb +370 -30
  212. data/test/defs/test_defs_ve.rb +23 -16
  213. data/test/defs/test_defs_vi.rb +10 -6
  214. data/test/defs/test_defs_za.rb +23 -14
  215. data/test/holidays/core_extensions/test_date.rb +3 -2
  216. data/test/holidays/core_extensions/test_date_time.rb +60 -0
  217. data/test/holidays/date_calculator/test_lunar_date.rb +89 -0
  218. data/test/holidays/definition/context/test_function_processor.rb +199 -0
  219. data/test/holidays/definition/context/test_generator.rb +66 -35
  220. data/test/holidays/definition/context/test_load.rb +37 -0
  221. data/test/holidays/definition/decorator/test_test.rb +123 -0
  222. data/test/holidays/definition/generator/test_module.rb +268 -0
  223. data/test/holidays/definition/generator/test_regions.rb +97 -0
  224. data/test/holidays/definition/generator/test_test.rb +113 -0
  225. data/test/holidays/definition/parser/test_custom_method.rb +6 -6
  226. data/test/holidays/definition/parser/test_test.rb +142 -0
  227. data/test/holidays/definition/repository/test_cache.rb +47 -6
  228. data/test/holidays/definition/repository/test_holidays_by_month.rb +121 -1
  229. data/test/holidays/definition/repository/test_proc_result_cache.rb +8 -1
  230. data/test/holidays/definition/repository/test_regions.rb +31 -13
  231. data/test/holidays/definition/validator/test_custom_method.rb +5 -0
  232. data/test/holidays/definition/validator/test_region.rb +16 -12
  233. data/test/holidays/definition/validator/test_test.rb +60 -0
  234. data/test/holidays/finder/context/test_between.rb +172 -0
  235. data/test/holidays/{use_case → finder}/context/test_dates_driver_builder.rb +2 -2
  236. data/test/holidays/finder/context/test_next_holiday.rb +156 -0
  237. data/test/holidays/finder/context/test_parse_options.rb +141 -0
  238. data/test/holidays/finder/context/test_search.rb +232 -0
  239. data/test/holidays/finder/context/test_year_holiday.rb +202 -0
  240. data/test/holidays/finder/rules/test_in_region.rb +42 -0
  241. data/test/holidays/finder/rules/test_year_range.rb +166 -0
  242. data/test/integration/README.md +9 -0
  243. data/test/{test_all_regions.rb → integration/test_all_regions.rb} +18 -4
  244. data/test/integration/test_any_holidays_during_work_week.rb +90 -0
  245. data/test/integration/test_available_regions.rb +23 -0
  246. data/test/{test_custom_holidays.rb → integration/test_custom_holidays.rb} +6 -6
  247. data/test/integration/test_custom_informal_holidays.rb +15 -0
  248. data/test/{test_custom_year_range_holidays.rb → integration/test_custom_year_range_holidays.rb} +1 -9
  249. data/test/{test_holidays.rb → integration/test_holidays.rb} +100 -69
  250. data/test/{test_holidays_between.rb → integration/test_holidays_between.rb} +19 -17
  251. data/test/integration/test_multiple_regions.rb +71 -0
  252. data/test/integration/test_multiple_regions_with_conflict.rb +29 -0
  253. data/test/integration/test_nonstandard_regions.rb +25 -0
  254. data/test/test_helper.rb +7 -3
  255. metadata +204 -132
  256. data/CONTRIBUTING.md +0 -41
  257. data/benchmark.rb +0 -8
  258. data/definitions/README.md +0 -353
  259. data/definitions/ar.yaml +0 -93
  260. data/definitions/at.yaml +0 -72
  261. data/definitions/au.yaml +0 -375
  262. data/definitions/be_fr.yaml +0 -69
  263. data/definitions/be_nl.yaml +0 -69
  264. data/definitions/bg.yaml +0 -127
  265. data/definitions/br.yaml +0 -77
  266. data/definitions/ca.yaml +0 -302
  267. data/definitions/ch.yaml +0 -193
  268. data/definitions/cl.yaml +0 -94
  269. data/definitions/cr.yaml +0 -65
  270. data/definitions/cz.yaml +0 -73
  271. data/definitions/de.yaml +0 -209
  272. data/definitions/dk.yaml +0 -130
  273. data/definitions/ecb_target.yaml +0 -44
  274. data/definitions/el.yaml +0 -84
  275. data/definitions/es.yaml +0 -203
  276. data/definitions/federal_reserve.yaml +0 -114
  277. data/definitions/fedex.yaml +0 -62
  278. data/definitions/fi.yaml +0 -115
  279. data/definitions/fr.yaml +0 -79
  280. data/definitions/gb.yaml +0 -151
  281. data/definitions/hr.yaml +0 -79
  282. data/definitions/hu.yaml +0 -63
  283. data/definitions/ie.yaml +0 -89
  284. data/definitions/index.yaml +0 -57
  285. data/definitions/is.yaml +0 -146
  286. data/definitions/it.yaml +0 -67
  287. data/definitions/jp.yaml +0 -316
  288. data/definitions/li.yaml +0 -107
  289. data/definitions/lt.yaml +0 -89
  290. data/definitions/ma.yaml +0 -52
  291. data/definitions/mx.yaml +0 -106
  292. data/definitions/nerc.yaml +0 -51
  293. data/definitions/nl.yaml +0 -73
  294. data/definitions/no.yaml +0 -90
  295. data/definitions/north_america_informal.yaml +0 -61
  296. data/definitions/nyse.yaml +0 -64
  297. data/definitions/nz.yaml +0 -163
  298. data/definitions/ph.yaml +0 -94
  299. data/definitions/pl.yaml +0 -320
  300. data/definitions/pt.yaml +0 -69
  301. data/definitions/ro.yaml +0 -78
  302. data/definitions/se.yaml +0 -120
  303. data/definitions/sg.yaml +0 -56
  304. data/definitions/si.yaml +0 -86
  305. data/definitions/sk.yaml +0 -80
  306. data/definitions/united_nations.yaml +0 -189
  307. data/definitions/ups.yaml +0 -62
  308. data/definitions/us.yaml +0 -103
  309. data/definitions/ve.yaml +0 -74
  310. data/definitions/vi.yaml +0 -29
  311. data/definitions/za.yaml +0 -80
  312. data/lib/generated_definitions/north_america.rb +0 -126
  313. data/lib/holidays/date_calculator_factory.rb +0 -35
  314. data/lib/holidays/definition_factory.rb +0 -86
  315. data/lib/holidays/option/context/parse_options.rb +0 -106
  316. data/lib/holidays/option_factory.rb +0 -15
  317. data/lib/holidays/use_case/context/between.rb +0 -45
  318. data/lib/holidays/use_case/context/context_common.rb +0 -123
  319. data/lib/holidays/use_case/context/next_holiday.rb +0 -54
  320. data/lib/holidays/use_case_factory.rb +0 -31
  321. data/test/defs/test_defs_ecb_target.rb +0 -23
  322. data/test/defs/test_defs_federal_reserve.rb +0 -69
  323. data/test/defs/test_defs_north_america.rb +0 -195
  324. data/test/holidays/option/context/test_parse_options.rb +0 -74
  325. data/test/holidays/test_date_calculator_factory.rb +0 -27
  326. data/test/holidays/test_definition_factory.rb +0 -49
  327. data/test/holidays/test_option_factory.rb +0 -9
  328. data/test/holidays/test_use_case_factory.rb +0 -13
  329. data/test/holidays/use_case/context/test_between.rb +0 -77
  330. data/test/test_multiple_regions.rb +0 -24
data/Rakefile CHANGED
@@ -41,7 +41,7 @@ end
41
41
 
42
42
  desc 'Launch IRB session'
43
43
  task :console do
44
- sh "irb -rubygems -I lib -r holidays.rb"
44
+ sh "irb -r rubygems -I lib -r holidays.rb"
45
45
  end
46
46
 
47
47
  desc 'Generate definitions and tests used in main holiday logic based on raw YAML definitions'
@@ -54,14 +54,17 @@ namespace :generate do
54
54
  # create a dir for the generated tests
55
55
  FileUtils.mkdir_p(DEFINITION_TESTS_PATH)
56
56
 
57
- all_regions = []
57
+ #TODO This entire section should be moved into '/lib/holidays/definition'. I don't think such an
58
+ # important part of the gem should be left in the Rakefile and without unit tests. There's no
59
+ # reason we can't move it.
60
+ all_regions = {}
58
61
 
59
62
  def_index['defs'].each do |region, files|
60
63
  puts "Building #{region} definition module:"
61
64
  files = files.collect { |f| "#{DEFINITION_PATH}/#{f}" }.uniq
62
65
 
63
- regions, rules_by_month, custom_methods, tests = Holidays::DefinitionFactory.file_parser.parse_definition_files(files)
64
- module_src, test_src = Holidays::DefinitionFactory.source_generator.generate_definition_source(region, files, regions, rules_by_month, custom_methods, tests)
66
+ regions, rules_by_month, custom_methods, tests = Holidays::Factory::Definition.file_parser.parse_definition_files(files)
67
+ module_src, test_src = Holidays::Factory::Definition.source_generator.generate_definition_source(region, files, regions, rules_by_month, custom_methods, tests)
65
68
 
66
69
  File.open("lib/#{Holidays::DEFINITIONS_PATH}/#{region.downcase.to_s}.rb","w") do |file|
67
70
  file.puts module_src
@@ -72,7 +75,7 @@ namespace :generate do
72
75
  end
73
76
  end
74
77
 
75
- all_regions << regions
78
+ all_regions[region.downcase.to_sym] = regions
76
79
 
77
80
  puts "Done.\n\n"
78
81
  end
@@ -80,12 +83,7 @@ namespace :generate do
80
83
  puts "Building regions master file for later validation:"
81
84
 
82
85
  File.open("lib/#{Holidays::DEFINITIONS_PATH}/REGIONS.rb","w") do |file|
83
- file.puts <<-EOR
84
- # encoding: utf-8
85
- module Holidays
86
- REGIONS = [:#{all_regions.join(', :')}]
87
- end
88
- EOR
86
+ file.puts Holidays::Factory::Definition.regions_generator.call(all_regions)
89
87
  end
90
88
 
91
89
  puts "Done.\n\n"
@@ -94,6 +92,7 @@ end
94
92
  desc 'Build the definition manifest'
95
93
  task :manifest do
96
94
  File.open("lib/#{Holidays::DEFINITIONS_PATH}/MANIFEST","w") do |file|
95
+ #TODO Generating the file source should be done interally, in the /lib dir, not in the Rakefile
97
96
  file.puts <<-EOH
98
97
  ==== Regional definitions
99
98
  The following definition files are included in this installation:
data/bin/console CHANGED
File without changes
data/bin/setup CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/bin/bash
2
2
  set -euo pipefail
3
3
  IFS=$'\n\t'
4
+ set -vx
4
5
 
5
6
  bundle install
@@ -0,0 +1,72 @@
1
+ # How to contribute
2
+
3
+ There are multiple ways to help! We rely on users around the world to help keep our definitions accurate and up to date. In addition, pull requests to address bugs or implement new features are always welcome.
4
+
5
+ ## Code of Conduct
6
+
7
+ Please read our [Code of Conduct](../CODE_OF_CONDUCT.md) before contributing. Everyone interacting with this project (or associated projects) is expected to abide by its terms.
8
+
9
+ ## General note
10
+
11
+ The definitions for this project are housed in a submodule. When pulling this repo please make sure to run `git clone --recursive git@github.com/holidays/holidays`
12
+ or, if you forgot to do so, run `make update-defs` so that all of the submodule data is pulled correctly.
13
+
14
+ ## For definition updates
15
+
16
+ Our definitions are written in YAML. They are housed in a [separate repository](https://github.com/holidays/definitions) so that they can be used by tools written in other languages. You can find a complete guide to our format in the [definitions SYNTAX guide](https://github.com/holidays/definitions/blob/master/doc/SYNTAX.md).
17
+
18
+ In this ruby project we take the YAML definitions and generate final ruby classes that are loaded at runtime for fast calculations.
19
+
20
+ Once you have a good idea on what you want to change, please see the [CONTRIBUTING guide](https://github.com/holidays/definitions/blob/master/doc/CONTRIBUTING.md) in the `definitions` repository.
21
+
22
+ The idea is that if the validation passes on the other repo then you shouldn't have to worry about generating and testing here. We'll see how that goes!
23
+
24
+ Once that PR is accepted the maintainers of this project will be responsible for generating the updated definitions here and releasing a new gem. Don't worry about versioning, we'll take care of it!
25
+
26
+ #### Testing out your definitions locally
27
+
28
+ As mentioned above we use a git submodule for the definitions. Sometimes you might want to manually test out how this ruby project will behave with your changes. To facilitate that we provide some commands for pointing the definitions submodule to your fork/branch.
29
+
30
+ To point at your fork/branch:
31
+
32
+ ```sh
33
+ make clean-defs
34
+ BRANCH=<branch-name> USER=<user> make point-to-defs-branch
35
+ ```
36
+
37
+ Example:
38
+
39
+ ```sh
40
+ make clean-defs
41
+ BRANCH=issue-24 USER=ppeble make point-to-defs-branch
42
+ ```
43
+
44
+ This will pull everything down for the latest commit on that fork/branch. When you are done testing and want to point back at the master definitions:
45
+
46
+ ```sh
47
+ make clean-defs
48
+ make point-to-defs-master
49
+ ```
50
+
51
+ ## For non-definition functionality
52
+
53
+ * Fork this repository
54
+ * Make your changes. Don't forget to run `make test` to execute the test suite!
55
+ * Create a PR pointing back to `master`
56
+
57
+ Don't worry about versioning, we'll handle it on our end.
58
+
59
+ *Tests are required*. If your PR results in lower test coverage then it will not be accepted.
60
+
61
+ ## Local development helpers
62
+
63
+ We have included a few handy tasks to help you troubleshoot and test:
64
+
65
+ * `make test` - runs the entire suite
66
+ * `bundle exec ruby <test-file-to-run>` - runs just the tests in the specified file
67
+ * `REGION=<region> make test-region` - runs the tests for just that region
68
+ * `make console` - launches an IRB session with the 'holidays' gem loaded for quick testing
69
+ * `make update-defs` - runs the appropriate git submodule commands to pull the latest definitions
70
+ * `make clean-defs` - removes the definitions submodule, useful for switching between a fork and the main definitions repository
71
+ * `BRANCH=<branch> USER=<user> make point-to-defs-branch` - updates your definitions submodule to point at a fork/branch
72
+ * `make point-to-defs-master` - updates your definitions submodule to point back at the `holidays/definitions` repo and master branch
@@ -0,0 +1,81 @@
1
+ # Maintainers guide
2
+
3
+ This document outlines the process of releasing an update to the `holidays` gem. This update could
4
+ include any (or a combination of) the following:
5
+
6
+ * definition updates from the [definitions](https://github.com/holidays/definitions) repository
7
+ * bug fixes
8
+ * additional functionality
9
+
10
+ ### semver
11
+
12
+ This gem operates under the rules of [semver](http://semver.org/). The decisions on what constitutes a major,
13
+ minor, or patch version update fall on the maintainer. If in doubt, follow these rules:
14
+
15
+ * Will this change mean that users will be REQUIRED to make a code change? If so then it is a major version bump. This includes dropping supported versions of ruby!
16
+ * Will this change mean that users might see a definition/behavior change but won't need to modify their own code? If so then it is as minor version bump
17
+ * Will this change mean that a bug, either in code or definitions, will be fixed? If so then it is a patch version bump
18
+
19
+ *@ppeble editor note*: I am pretty aggressive when it comes to version bumps! If the slightest functionality has changed then
20
+ I consider it a minor version bump, if ANY consumer code has to change then I consider it a major version bump. I don't care
21
+ if we get up to version 250, the version number doesn't matter. Communicating the effort required in updating is what matters!
22
+
23
+ ### Who this document is for
24
+
25
+ This document is for maintainers that have merge access to this repository. These maintainers may or may not have access to the upstream
26
+ [definitions](https://github.com/holidays/definitions) repository.
27
+
28
+ Please note that a core contributor must provide the relevant Github access so that you can perform merges. If you have any issues
29
+ please contact the [core members](https://github.com/orgs/holidays/teams/core/members) for assistance.
30
+
31
+ ### Setup
32
+
33
+ This guide assumes that you have forked the repository in Github. If you require assistance in this please contact the core members listed above.
34
+
35
+ You will need upload access to rubygems.org in order to publish gems. Contact a [core member](https://github.com/orgs/holidays/teams/core/members) for assistance.
36
+
37
+ ### Release Overview
38
+
39
+ A release could contain one or more of the following:
40
+
41
+ * definition updates - these are rule updates pulled from https://github.com/holidays/definitions. These changes are not
42
+ language specific and will most likely require local regeneration of compiled rules.
43
+ * functionality additions - this is new functionality in this repository that uses the existing definitions
44
+ * bug fixes - these are bug fixes in this repository
45
+
46
+ It is up to the maintainer to determine what needs to be updated. We will attempt to outline the various scenarios in the
47
+ sections below.
48
+
49
+ ### Release flow
50
+
51
+ * Does this update require definition updates? If YES, then:
52
+ * Pull the latest `master` version of this ruby repository and run `make update-defs`. This will grab the latest version from the [definitions](https://github.com/holidays/definitions) repository. Run `git diff` to verify that the version of the submodule for the definitions matches the latest commit in the [definitions](https://github.com/holidays/definitions) repo.
53
+ * Run the `make generate` command. This will 'recompile' the ruby sources with the latest definitions.
54
+ * Run `make test` and ensure that all of the tests pass. If any tests fail then do *not* merge and contact a [core member](https://github.com/orgs/holidays/teams/core/members) for assistance.
55
+ * If all of the tests pass, update the `lib/holidays/version.rb` file to the new version. Reference the above [semver](http://semver.org/) rules for how to update versions.
56
+ * Make a branch on your fork and update the [CHANGELOG](../CHANGELOG.md) to reflect the latest changes. You do not need to put in all of the definition changes in this update, you can simply reference the other repository. See other entries in the CHANGELOG for examples.
57
+ * Open a PR against the new branch and merge it (another maintainer will need to review before you can merge)
58
+ * Once the branch is merged, pull down the latest master from Github and run `make build`. This will generate a new `gem` file with the new version. The new version number is pulled from the above `version.rb` update.
59
+ * If the build was successful then you can run the following to push up to rubygems.org: `GEM=<gem> make push`. Example: `GEM=holidays-6.2.0.gem make push`
60
+ * Does this update require functionality additions or bug fixes? If YES, then:
61
+ * Run `make test` and ensure that all of the tests pass. If any tests fail then do *not* merge and contact a [core member](https://github.com/orgs/holidays/teams/core/members) for assistance.
62
+ * If all of the tests pass, make a branch on your fork and update the [CHANGELOG](../CHANGELOG.md) to reflect the latest changes.
63
+ * Update the `lib/holidays/version.rb` file to the new version. Reference the above [semver](http://semver.org/) rules for how to update versions.
64
+ * Open a PR against the new branch and merge it (another maintainer will need to review before you can merge)
65
+ * Once the branch is merged, pull down the latest master from Github and run `make build`. This will generate a new `gem` file with the new version. The new version number is pulled from the above `version.rb` update.
66
+ * If the build was successful then you can run the following to push up to rubygems.org: `GEM=<gem> make push`. Example: `GEM=holidays-6.2.0.gem make push`
67
+
68
+ You are done! The latest version should be uploaded to rubygems.org. You can go to view the [holidays page](https://rubygems.org/gems/holidays) to verify that the latest version is available.
69
+
70
+ It is totally acceptable to do both functionality AND definition updates in a single release. Simply combine both sets of rules into a single branch for your update.
71
+
72
+ ### Troubleshooting
73
+
74
+ The biggest hurdle in this repository is that [upstream definition](https://github.com/holidays/definitions) changes will
75
+ result in failures in existing tests and it will not be because of ruby issues but rather upstream issues. If you notice any test failures
76
+ that seem to be specific to certain regions then look at recent changes in that other repository. If there were changes there then the odds
77
+ are that there are issues in the definition-specific tests. This is most likely not a language (i.e. ruby) specific issue.
78
+
79
+ It is a known issue that the definitions do not have a good set of self-tests to ensure that they are internally consistent. This means that a failure in this
80
+ repository could NOT be related to ruby specifically. It could be that the 'tests' specified in in the YAML files are incorrect! If you encounter errors here
81
+ make sure that you don't assume that it is just a ruby error that is causing the issues!
File without changes
data/holidays.gemspec CHANGED
@@ -7,20 +7,20 @@ require 'holidays/version'
7
7
  Gem::Specification.new do |gem|
8
8
  gem.name = 'holidays'
9
9
  gem.version = Holidays::VERSION
10
- gem.authors = ['Alex Dunae', 'Phil Trimble']
10
+ gem.authors = ['Alex Dunae', 'Phil Peble']
11
11
  gem.email = ['holidaysgem@gmail.com']
12
12
  gem.homepage = 'https://github.com/holidays/holidays'
13
13
  gem.description = %q(A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!)
14
14
  gem.summary = %q(A collection of Ruby methods to deal with statutory and other holidays.)
15
- gem.files = `git ls-files`.split("\n") - ['.gitignore', '.travis.yml', '.coveralls.yml']
15
+ gem.files = `git ls-files`.split("\n") - ['.gitignore', '.travis.yml']
16
16
  gem.test_files = gem.files.grep(/^test/)
17
17
  gem.require_paths = ['lib']
18
18
  gem.licenses = ['MIT']
19
- gem.required_ruby_version = '~> 2.0'
20
- gem.add_development_dependency 'bundler'
21
- gem.add_development_dependency 'rake'
22
- gem.add_development_dependency 'coveralls'
23
- gem.add_development_dependency 'test-unit'
24
- gem.add_development_dependency 'mocha', '~>1.0'
25
- gem.add_development_dependency 'pry', '~>0.10'
19
+ gem.required_ruby_version = '>= 2.4'
20
+ gem.add_development_dependency 'bundler', '~> 2'
21
+ gem.add_development_dependency 'rake', '~> 12'
22
+ gem.add_development_dependency 'simplecov', '~> 0.16'
23
+ gem.add_development_dependency 'test-unit', '~> 3'
24
+ gem.add_development_dependency 'mocha', '~> 1'
25
+ gem.add_development_dependency 'pry', '~> 0.12'
26
26
  end
@@ -13,45 +13,67 @@ The following definition files are included in this installation:
13
13
  * generated_definitions/ca
14
14
  * generated_definitions/ch
15
15
  * generated_definitions/cl
16
+ * generated_definitions/co
16
17
  * generated_definitions/cr
17
18
  * generated_definitions/cz
18
19
  * generated_definitions/de
19
20
  * generated_definitions/dk
20
- * generated_definitions/ecb_target
21
+ * generated_definitions/ecbtarget
22
+ * generated_definitions/ee
21
23
  * generated_definitions/el
22
24
  * generated_definitions/es
23
25
  * generated_definitions/europe
24
- * generated_definitions/federal_reserve
26
+ * generated_definitions/federalreserve
27
+ * generated_definitions/federalreservebanks
25
28
  * generated_definitions/fedex
26
29
  * generated_definitions/fi
27
30
  * generated_definitions/fr
28
31
  * generated_definitions/gb
32
+ * generated_definitions/ge
33
+ * generated_definitions/hk
29
34
  * generated_definitions/hr
30
35
  * generated_definitions/hu
31
36
  * generated_definitions/ie
32
37
  * generated_definitions/is
33
38
  * generated_definitions/it
34
39
  * generated_definitions/jp
40
+ * generated_definitions/kr
41
+ * generated_definitions/kz
35
42
  * generated_definitions/li
36
43
  * generated_definitions/lt
44
+ * generated_definitions/lu
45
+ * generated_definitions/lv
37
46
  * generated_definitions/ma
47
+ * generated_definitions/mt_en
48
+ * generated_definitions/mt_mt
38
49
  * generated_definitions/mx
50
+ * generated_definitions/my
39
51
  * generated_definitions/nerc
52
+ * generated_definitions/ng
40
53
  * generated_definitions/nl
41
54
  * generated_definitions/no
42
- * generated_definitions/north_america
55
+ * generated_definitions/northamerica
43
56
  * generated_definitions/nyse
44
57
  * generated_definitions/nz
58
+ * generated_definitions/pe
45
59
  * generated_definitions/ph
46
60
  * generated_definitions/pl
47
61
  * generated_definitions/pt
48
62
  * generated_definitions/ro
63
+ * generated_definitions/rs_cyrl
64
+ * generated_definitions/rs_la
65
+ * generated_definitions/ru
49
66
  * generated_definitions/scandinavia
50
67
  * generated_definitions/se
51
68
  * generated_definitions/sg
52
69
  * generated_definitions/si
53
70
  * generated_definitions/sk
54
- * generated_definitions/united_nations
71
+ * generated_definitions/southamerica
72
+ * generated_definitions/th
73
+ * generated_definitions/tn
74
+ * generated_definitions/tr
75
+ * generated_definitions/ua
76
+ * generated_definitions/unitednations
55
77
  * generated_definitions/ups
56
78
  * generated_definitions/us
57
79
  * generated_definitions/ve
@@ -1,4 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Holidays
3
- REGIONS = [:ar, :at, :au, :au_nsw, :au_vic, :au_qld, :au_nt, :au_act, :au_sa, :au_tas_south, :au_wa, :au_tas, :au_qld_cairns, :au_qld_brisbane, :au_tas_north, :au_vic_melbourne, :be_fr, :be_nl, :br, :bg_en, :bg_bg, :ca, :ca_qc, :ca_ab, :ca_sk, :ca_on, :ca_bc, :ca_mb, :ca_ns, :ca_pe, :ca_nf, :ca_nt, :ca_nu, :ca_nb, :ca_yk, :us, :ch_zh, :ch_be, :ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_gl, :ch_zg, :ch_fr, :ch_so, :ch_bs, :ch_bl, :ch_sh, :ch_ar, :ch_ai, :ch_sg, :ch_gr, :ch_ag, :ch_tg, :ch_ti, :ch_vd, :ch_ne, :ch_ge, :ch_ju, :ch_vs, :ch, :cl, :cr, :cz, :dk, :de, :de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn_aux, :de_th_aux, :de_sn, :de_st, :de_by_aux, :de_bb, :de_mv, :de_th, :ecb_target, :el, :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, :es_ct, :es_v, :es_vc, :federal_reserve, :fedex, :fi, :fr, :gb, :gb_eng, :gb_wls, :gb_eaw, :gb_nir, :gb_sct, :gb_con, :je, :gb_jsy, :gg, :gb_gsy, :im, :gb_iom, :hr, :hu, :ie, :is, :it, :li, :lt, :ma, :mx, :mx_pue, :us, :ca, :nerc, :nl, :no, :nyse, :nz, :nz_sl, :nz_we, :nz_ak, :nz_nl, :nz_ne, :nz_ot, :nz_ta, :nz_sc, :nz_hb, :nz_mb, :nz_ca, :nz_ch, :nz_wl, :ph, :pl, :pt, :ro, :se, :us, :us_dc, :us_ca, :ca, :united_nations, :ups, :za, :ca, :ca_qc, :ca_ab, :ca_sk, :ca_on, :ca_bc, :ca_mb, :ca_ns, :ca_pe, :ca_nf, :ca_nt, :ca_nu, :ca_nb, :ca_yk, :mx, :mx_pue, :us, :us_dc, :us_ca, :dk, :is, :no, :se, :fi, :at, :be_fr, :be_nl, :ch_zh, :ch_be, :ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_gl, :ch_zg, :ch_fr, :ch_so, :ch_bs, :ch_bl, :ch_sh, :ch_ar, :ch_ai, :ch_sg, :ch_gr, :ch_ag, :ch_tg, :ch_ti, :ch_vd, :ch_ne, :ch_ge, :ch_ju, :ch_vs, :ch, :cz, :dk, :de, :de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn_aux, :de_th_aux, :de_sn, :de_st, :de_by_aux, :de_bb, :de_mv, :de_th, :el, :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, :es_ct, :es_v, :es_vc, :fr, :gb, :gb_eng, :gb_wls, :gb_eaw, :gb_nir, :gb_sct, :gb_con, :je, :gb_jsy, :gg, :gb_gsy, :im, :gb_iom, :hr, :hu, :ie, :is, :it, :li, :lt, :nl, :no, :pl, :pt, :ro, :sk, :si, :bg_en, :bg_bg, :jp, :ve, :vi, :sk, :si, :sg]
3
+ REGIONS = [:ar, :at, :au, :au_nsw, :au_vic, :au_qld, :au_nt, :au_act, :au_sa, :au_wa, :au_tas, :au_tas_south, :au_qld_cairns, :au_qld_brisbane, :au_tas_north, :au_vic_melbourne, :be_fr, :be_nl, :br, :bg_en, :bg_bg, :ca, :ca_qc, :ca_ab, :ca_sk, :ca_on, :ca_bc, :ca_nb, :ca_mb, :ca_ns, :ca_pe, :ca_nl, :ca_nt, :ca_nu, :ca_yt, :us, :ch_zh, :ch_be, :ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_gl, :ch_zg, :ch_fr, :ch_so, :ch_bs, :ch_bl, :ch_sh, :ch_ar, :ch_ai, :ch_sg, :ch_gr, :ch_ag, :ch_tg, :ch_ti, :ch_vd, :ch_ne, :ch_ge, :ch_ju, :ch_vs, :ch, :cl, :co, :cr, :cz, :dk, :de, :de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn_sorbian, :de_th_cath, :de_sn, :de_st, :de_be, :de_by_cath, :de_by_augsburg, :de_bb, :de_mv, :de_th, :de_hb, :de_hh, :de_ni, :de_sh, :ecbtarget, :ee, :el, :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, :es_ct, :es_v, :es_vc, :federalreserve, :federalreservebanks, :fedex, :fi, :fr_a, :fr_m, :fr, :gb, :gb_eng, :gb_wls, :gb_eaw, :gb_nir, :je, :gb_jsy, :gg, :gb_gsy, :gb_sct, :gb_con, :im, :gb_iom, :ge, :hr, :hk, :hu, :ie, :is, :it, :it_ve, :it_tv, :it_vr, :it_pd, :it_fi, :it_ge, :it_to, :it_rm, :it_vi, :it_bl, :it_ro, :kr, :kz, :li, :lt, :lv, :ma, :mt_mt, :mt_en, :mx, :mx_pue, :nerc, :nl, :lu, :no, :nyse, :nz, :nz_sl, :nz_we, :nz_ak, :nz_nl, :nz_ne, :nz_ot, :nz_ta, :nz_sc, :nz_hb, :nz_mb, :nz_ca, :nz_ch, :nz_wl, :pe, :ph, :pl, :pt, :pt_li, :pt_po, :ro, :rs_cyrl, :rs_la, :ru, :se, :tn, :tr, :ua, :us_fl, :us_la, :us_ct, :us_de, :us_gu, :us_hi, :us_in, :us_ky, :us_nj, :us_nc, :us_nd, :us_pr, :us_tn, :us_ms, :us_id, :us_ar, :us_tx, :us_dc, :us_md, :us_va, :us_vt, :us_ak, :us_ca, :us_me, :us_ma, :us_al, :us_ga, :us_ne, :us_mo, :us_sc, :us_wv, :us_vi, :us_ut, :us_ri, :us_az, :us_co, :us_il, :us_mt, :us_nm, :us_ny, :us_oh, :us_pa, :us_mi, :us_mn, :us_nv, :us_or, :us_sd, :us_wa, :us_wi, :us_wy, :us_ia, :us_ks, :us_nh, :us_ok, :unitednations, :ups, :za, :ve, :sk, :si, :jp, :vi, :sg, :my, :th, :ng]
4
+
5
+ PARENT_REGION_LOOKUP = {:ar=>:ar, :at=>:at, :au=>:au, :au_nsw=>:au, :au_vic=>:au, :au_qld=>:au, :au_nt=>:au, :au_act=>:au, :au_sa=>:au, :au_wa=>:au, :au_tas=>:au, :au_tas_south=>:au, :au_qld_cairns=>:au, :au_qld_brisbane=>:au, :au_tas_north=>:au, :au_vic_melbourne=>:au, :be_fr=>:be_fr, :be_nl=>:be_nl, :br=>:br, :bg_en=>:bg, :bg_bg=>:bg, :ca=>:ca, :ca_qc=>:ca, :ca_ab=>:ca, :ca_sk=>:ca, :ca_on=>:ca, :ca_bc=>:ca, :ca_nb=>:ca, :ca_mb=>:ca, :ca_ns=>:ca, :ca_pe=>:ca, :ca_nl=>:ca, :ca_nt=>:ca, :ca_nu=>:ca, :ca_yt=>:ca, :us=>:us, :ch_zh=>:ch, :ch_be=>:ch, :ch_lu=>:ch, :ch_ur=>:ch, :ch_sz=>:ch, :ch_ow=>:ch, :ch_nw=>:ch, :ch_gl=>:ch, :ch_zg=>:ch, :ch_fr=>:ch, :ch_so=>:ch, :ch_bs=>:ch, :ch_bl=>:ch, :ch_sh=>:ch, :ch_ar=>:ch, :ch_ai=>:ch, :ch_sg=>:ch, :ch_gr=>:ch, :ch_ag=>:ch, :ch_tg=>:ch, :ch_ti=>:ch, :ch_vd=>:ch, :ch_ne=>:ch, :ch_ge=>:ch, :ch_ju=>:ch, :ch_vs=>:ch, :ch=>:ch, :cl=>:cl, :co=>:co, :cr=>:cr, :cz=>:cz, :dk=>:dk, :de=>:de, :de_bw=>:de, :de_by=>:de, :de_he=>:de, :de_nw=>:de, :de_rp=>:de, :de_sl=>:de, :de_sn_sorbian=>:de, :de_th_cath=>:de, :de_sn=>:de, :de_st=>:de, :de_be=>:de, :de_by_cath=>:de, :de_by_augsburg=>:de, :de_bb=>:de, :de_mv=>:de, :de_th=>:de, :de_hb=>:de, :de_hh=>:de, :de_ni=>:de, :de_sh=>:de, :ecbtarget=>:ecbtarget, :ee=>:ee, :el=>:el, :es_pv=>:es, :es_na=>:es, :es_an=>:es, :es_ib=>:es, :es_cm=>:es, :es_mu=>:es, :es_m=>:es, :es_ar=>:es, :es_cl=>:es, :es_cn=>:es, :es_lo=>:es, :es_ga=>:es, :es_ce=>:es, :es_o=>:es, :es_ex=>:es, :es=>:es, :es_ct=>:es, :es_v=>:es, :es_vc=>:es, :federalreserve=>:federalreserve, :federalreservebanks=>:federalreservebanks, :fedex=>:fedex, :fi=>:fi, :fr_a=>:fr, :fr_m=>:fr, :fr=>:fr, :gb=>:gb, :gb_eng=>:gb, :gb_wls=>:gb, :gb_eaw=>:gb, :gb_nir=>:gb, :je=>:gb, :gb_jsy=>:gb, :gg=>:gb, :gb_gsy=>:gb, :gb_sct=>:gb, :gb_con=>:gb, :im=>:gb, :gb_iom=>:gb, :ge=>:ge, :hr=>:hr, :hk=>:hk, :hu=>:hu, :ie=>:ie, :is=>:is, :it=>:it, :it_ve=>:it, :it_tv=>:it, :it_vr=>:it, :it_pd=>:it, :it_fi=>:it, :it_ge=>:it, :it_to=>:it, :it_rm=>:it, :it_vi=>:it, :it_bl=>:it, :it_ro=>:it, :kr=>:kr, :kz=>:kz, :li=>:li, :lt=>:lt, :lv=>:lv, :ma=>:ma, :mt_mt=>:mt_mt, :mt_en=>:mt_en, :mx=>:mx, :mx_pue=>:mx, :nerc=>:nerc, :nl=>:nl, :lu=>:lu, :no=>:no, :nyse=>:nyse, :nz=>:nz, :nz_sl=>:nz, :nz_we=>:nz, :nz_ak=>:nz, :nz_nl=>:nz, :nz_ne=>:nz, :nz_ot=>:nz, :nz_ta=>:nz, :nz_sc=>:nz, :nz_hb=>:nz, :nz_mb=>:nz, :nz_ca=>:nz, :nz_ch=>:nz, :nz_wl=>:nz, :pe=>:pe, :ph=>:ph, :pl=>:pl, :pt=>:pt, :pt_li=>:pt, :pt_po=>:pt, :ro=>:ro, :rs_cyrl=>:rs_cyrl, :rs_la=>:rs_la, :ru=>:ru, :se=>:se, :tn=>:tn, :tr=>:tr, :ua=>:ua, :us_fl=>:us, :us_la=>:us, :us_ct=>:us, :us_de=>:us, :us_gu=>:us, :us_hi=>:us, :us_in=>:us, :us_ky=>:us, :us_nj=>:us, :us_nc=>:us, :us_nd=>:us, :us_pr=>:us, :us_tn=>:us, :us_ms=>:us, :us_id=>:us, :us_ar=>:us, :us_tx=>:us, :us_dc=>:us, :us_md=>:us, :us_va=>:us, :us_vt=>:us, :us_ak=>:us, :us_ca=>:us, :us_me=>:us, :us_ma=>:us, :us_al=>:us, :us_ga=>:us, :us_ne=>:us, :us_mo=>:us, :us_sc=>:us, :us_wv=>:us, :us_vi=>:us, :us_ut=>:us, :us_ri=>:us, :us_az=>:us, :us_co=>:us, :us_il=>:us, :us_mt=>:us, :us_nm=>:us, :us_ny=>:us, :us_oh=>:us, :us_pa=>:us, :us_mi=>:us, :us_mn=>:us, :us_nv=>:us, :us_or=>:us, :us_sd=>:us, :us_wa=>:us, :us_wi=>:us, :us_wy=>:us, :us_ia=>:us, :us_ks=>:us, :us_nh=>:us, :us_ok=>:us, :unitednations=>:unitednations, :ups=>:ups, :za=>:za, :ve=>:southamerica, :sk=>:europe, :si=>:europe, :jp=>:jp, :vi=>:vi, :sg=>:sg, :my=>:my, :th=>:th, :ng=>:ng}
4
6
  end
@@ -4,12 +4,6 @@ module Holidays
4
4
  #
5
5
  # Definitions loaded: definitions/ar.yaml
6
6
  #
7
- # To use the definitions in this file, load it right after you load the
8
- # Holiday gem:
9
- #
10
- # require 'holidays'
11
- # require 'generated_definitions/ar'
12
- #
13
7
  # All the definitions are available at https://github.com/holidays/holidays
14
8
  module AR # :nodoc:
15
9
  def self.defined_regions
@@ -18,10 +12,10 @@ module Holidays
18
12
 
19
13
  def self.holidays_by_month
20
14
  {
21
- 0 => [{:function => "easter(year)", :function_arguments => [:year], :function_modifier => -2, :name => "Viernes Santo", :regions => [:ar]}],
15
+ 0 => [{:function => "easter(year)", :function_arguments => [:year], :function_modifier => -2, :name => "Viernes Santo", :regions => [:ar]},
16
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -48, :name => "Carnaval Lunes", :regions => [:ar]},
17
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -47, :name => "Carnaval Martes", :regions => [:ar]}],
22
18
  1 => [{:mday => 1, :name => "Año Nuevo", :regions => [:ar]}],
23
- 2 => [{:mday => 8, :name => "Carnaval", :regions => [:ar]},
24
- {:mday => 9, :name => "Carnaval", :regions => [:ar]}],
25
19
  3 => [{:mday => 24, :name => "Día Nacional de la Memoria por la Verdad y la Justicia", :regions => [:ar]}],
26
20
  4 => [{:mday => 2, :name => "Día del Veterano y de los Caídos en la Guerra de Malvinas", :regions => [:ar]}],
27
21
  5 => [{:mday => 1, :name => "Día del Trabajador", :regions => [:ar]},
@@ -40,7 +34,7 @@ module Holidays
40
34
 
41
35
  def self.custom_methods
42
36
  {
43
-
37
+
44
38
  }
45
39
  end
46
40
  end
@@ -4,12 +4,6 @@ module Holidays
4
4
  #
5
5
  # Definitions loaded: definitions/at.yaml
6
6
  #
7
- # To use the definitions in this file, load it right after you load the
8
- # Holiday gem:
9
- #
10
- # require 'holidays'
11
- # require 'generated_definitions/at'
12
- #
13
7
  # All the definitions are available at https://github.com/holidays/holidays
14
8
  module AT # :nodoc:
15
9
  def self.defined_regions
@@ -18,7 +12,7 @@ module Holidays
18
12
 
19
13
  def self.holidays_by_month
20
14
  {
21
- 0 => [{:function => "easter(year)", :function_arguments => [:year], :function_modifier => 1, :name => "Ostermontag", :regions => [:at]},
15
+ 0 => [{:function => "easter(year)", :function_arguments => [:year], :function_modifier => 1, :name => "Ostermontag", :regions => [:at]},
22
16
  {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 39, :name => "Christi Himmelfahrt", :regions => [:at]},
23
17
  {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 50, :name => "Pfingstmontag", :regions => [:at]},
24
18
  {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 60, :name => "Fronleichnam", :regions => [:at]}],
@@ -28,7 +22,7 @@ module Holidays
28
22
  8 => [{:mday => 15, :name => "Mariä Himmelfahrt", :regions => [:at]}],
29
23
  10 => [{:mday => 26, :name => "Nationalfeiertag", :regions => [:at]}],
30
24
  11 => [{:mday => 1, :name => "Allerheiligen", :regions => [:at]}],
31
- 12 => [{:mday => 8, :name => "Mariä Empfägnis", :regions => [:at]},
25
+ 12 => [{:mday => 8, :name => "Mariä Empfängnis", :regions => [:at]},
32
26
  {:mday => 25, :name => "1. Weihnachtstag", :regions => [:at]},
33
27
  {:mday => 26, :name => "2. Weihnachtstag", :regions => [:at]}]
34
28
  }
@@ -36,7 +30,7 @@ module Holidays
36
30
 
37
31
  def self.custom_methods
38
32
  {
39
-
33
+
40
34
  }
41
35
  end
42
36
  end
@@ -4,38 +4,35 @@ module Holidays
4
4
  #
5
5
  # Definitions loaded: definitions/au.yaml
6
6
  #
7
- # To use the definitions in this file, load it right after you load the
8
- # Holiday gem:
9
- #
10
- # require 'holidays'
11
- # require 'generated_definitions/au'
12
- #
13
7
  # All the definitions are available at https://github.com/holidays/holidays
14
8
  module AU # :nodoc:
15
9
  def self.defined_regions
16
- [:au, :au_nsw, :au_vic, :au_qld, :au_nt, :au_act, :au_sa, :au_tas_south, :au_wa, :au_tas, :au_qld_cairns, :au_qld_brisbane, :au_tas_north, :au_vic_melbourne]
10
+ [:au, :au_nsw, :au_vic, :au_qld, :au_nt, :au_act, :au_sa, :au_wa, :au_tas, :au_tas_south, :au_qld_cairns, :au_qld_brisbane, :au_tas_north, :au_vic_melbourne]
17
11
  end
18
12
 
19
13
  def self.holidays_by_month
20
14
  {
21
- 0 => [{:function => "easter(year)", :function_arguments => [:year], :function_modifier => -2, :name => "Good Friday", :regions => [:au]},
15
+ 0 => [{:function => "easter(year)", :function_arguments => [:year], :function_modifier => -2, :name => "Good Friday", :regions => [:au]},
22
16
  {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -1, :name => "Easter Saturday", :regions => [:au_nsw, :au_vic, :au_qld, :au_nt, :au_act, :au_sa]},
23
17
  {:function => "easter(year)", :function_arguments => [:year], :name => "Easter Sunday", :regions => [:au_nsw, :au_vic]},
18
+ {:function => "easter(year)", :function_arguments => [:year], :year_ranges => { :from => 2017 },:name => "Easter Sunday", :regions => [:au_qld, :au_act]},
24
19
  {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 1, :name => "Easter Monday", :regions => [:au]}],
25
- 1 => [{:mday => 1, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "New Year's Day", :regions => [:au]},
20
+ 1 => [{:mday => 1, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "New Year's Day", :regions => [:au, :au_nsw, :au_vic, :au_act, :au_sa, :au_wa, :au_nt, :au_qld]},
21
+ {:mday => 1, :function => "to_monday_if_weekend(date)", :function_arguments => [:date], :name => "New Year's Day", :regions => [:au_tas]},
26
22
  {:mday => 26, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "Australia Day", :regions => [:au]}],
27
23
  2 => [{:wday => 1, :week => 2, :name => "Royal Hobart Regatta", :regions => [:au_tas_south]}],
28
24
  3 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_wa]},
29
25
  {:wday => 1, :week => 2, :name => "Eight Hours Day", :regions => [:au_tas]},
30
26
  {:wday => 1, :week => 2, :name => "Labour Day", :regions => [:au_vic]},
31
- {:function => "march_pub_hol_sa(year)", :function_arguments => [:year], :name => "March Public Holiday", :regions => [:au_sa]}],
27
+ {:function => "march_pub_hol_sa(year)", :function_arguments => [:year], :name => "March Public Holiday", :regions => [:au_sa]},
28
+ {:wday => 1, :week => 2, :name => "Canberra Day", :regions => [:au_act]}],
32
29
  4 => [{:mday => 25, :name => "ANZAC Day", :regions => [:au]},
33
30
  {:mday => 25, :observed => "to_monday_if_sunday(date)", :observed_arguments => [:date], :name => "ANZAC Day", :regions => [:au_nsw, :au_vic, :au_qld, :au_nt, :au_act, :au_sa, :au_tas]},
34
31
  {:mday => 25, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "ANZAC Day", :regions => [:au_wa]}],
35
32
  5 => [{:function => "qld_labour_day_may(year)", :function_arguments => [:year], :name => "Labour Day", :regions => [:au_qld]},
36
33
  {:wday => 1, :week => 1, :name => "May Day", :regions => [:au_nt]},
37
34
  {:function => "may_pub_hol_sa(year)", :function_arguments => [:year], :name => "May Public Holiday", :regions => [:au_sa]}],
38
- 6 => [{:wday => 1, :week => 1, :name => "Foundation Day", :regions => [:au_wa]},
35
+ 6 => [{:wday => 1, :week => 1, :name => "Western Australia Day", :regions => [:au_wa]},
39
36
  {:wday => 1, :week => 2, :name => "Queen's Birthday", :regions => [:au_act, :au_nsw, :au_sa, :au_tas, :au_nt, :au_vic]},
40
37
  {:function => "qld_queens_birthday_june(year)", :function_arguments => [:year], :name => "Queen's Birthday", :regions => [:au_qld]},
41
38
  {:mday => 6, :type => :informal, :name => "Queensland Day", :regions => [:au_qld]}],
@@ -51,26 +48,36 @@ module Holidays
51
48
  11 => [{:function => "g20_day_2014_only(year)", :function_arguments => [:year], :name => "G20 Day", :regions => [:au_qld_brisbane]},
52
49
  {:wday => 1, :week => 1, :name => "Recreation Day", :regions => [:au_tas_north]},
53
50
  {:wday => 2, :week => 1, :name => "Melbourne Cup Day", :regions => [:au_vic_melbourne]}],
54
- 12 => [{:mday => 25, :observed => "to_tuesday_if_sunday_or_monday_if_saturday(date)", :observed_arguments => [:date], :name => "Christmas Day", :regions => [:au_qld, :au_nsw, :au_act, :au_tas, :au_wa]},
55
- {:mday => 25, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "Christmas Day", :regions => [:au_sa]},
56
- {:function => "xmas_to_weekday_if_weekend(year)", :function_arguments => [:year], :name => "Christmas Day", :regions => [:au_vic, :au_nt]},
51
+ 12 => [{:mday => 25, :observed => "to_tuesday_if_sunday_or_monday_if_saturday(date)", :observed_arguments => [:date], :name => "Christmas Day", :regions => [:au_qld, :au_nsw, :au_act, :au_tas, :au_wa, :au_vic, :au_nt]},
57
52
  {:mday => 26, :observed => "to_tuesday_if_sunday_or_monday_if_saturday(date)", :observed_arguments => [:date], :name => "Boxing Day", :regions => [:au_nsw, :au_vic, :au_qld, :au_act, :au_wa]},
58
- {:function => "to_weekday_if_boxing_weekend_from_year_or_to_tuesday_if_monday(year)", :function_arguments => [:year], :name => "Boxing Day", :regions => [:au_sa]},
59
- {:function => "to_weekday_if_boxing_weekend_from_year(year)", :function_arguments => [:year], :name => "Boxing Day", :regions => [:au_tas, :au_nt]}]
53
+ {:function => "to_weekday_if_boxing_weekend_from_year(year)", :function_arguments => [:year], :name => "Boxing Day", :regions => [:au_tas, :au_nt]},
54
+ {:function => "to_weekday_if_boxing_weekend_from_year_or_to_tuesday_if_monday(year)", :function_arguments => [:year], :name => "Proclamation Day", :regions => [:au_sa]},
55
+ {:mday => 25, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "Christmas Day", :regions => [:au_sa]}]
60
56
  }
61
57
  end
62
58
 
63
59
  def self.custom_methods
64
60
  {
65
- "afl_grand_final(year)" => Proc.new { |year|
66
- if year == 2015
61
+ "afl_grand_final(year)" => Proc.new { |year|
62
+ case year
63
+ when 2015
67
64
  Date.civil(2015, 10, 2)
65
+ when 2016
66
+ Date.civil(2016, 9, 30)
67
+ when 2017
68
+ Date.civil(2017, 9, 29)
69
+ when 2018
70
+ Date.civil(2018, 9, 28)
71
+ when 2019
72
+ Date.civil(2019,9, 27)
73
+ when 2020
74
+ Date.civil(2020, 10, 23)
68
75
  end
69
76
  },
70
77
 
71
78
  "qld_queens_bday_october(year)" => Proc.new { |year|
72
79
  if year >= 2016
73
- DateCalculatorFactory.day_of_month_calculator.call(year, 10, 1, 1)
80
+ Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 1, 1)
74
81
  elsif year == 2012
75
82
  1
76
83
  else
@@ -80,19 +87,19 @@ end
80
87
 
81
88
  "qld_queens_birthday_june(year)" => Proc.new { |year|
82
89
  if year <= 2015
83
- DateCalculatorFactory.day_of_month_calculator.call(year, 6, 2, 1)
90
+ Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 6, 2, 1)
84
91
  end
85
92
  },
86
93
 
87
94
  "qld_labour_day_may(year)" => Proc.new { |year|
88
95
  if year < 2013 || year >= 2016
89
- DateCalculatorFactory.day_of_month_calculator.call(year, 5, 1, 1)
96
+ Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 5, 1, 1)
90
97
  end
91
98
  },
92
99
 
93
100
  "qld_labour_day_october(year)" => Proc.new { |year|
94
101
  if year >= 2013 && year < 2016
95
- DateCalculatorFactory.day_of_month_calculator.call(year, 10, 1, 1)
102
+ Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 1, 1)
96
103
  end
97
104
  },
98
105
 
@@ -101,7 +108,7 @@ year == 2014 ? 14 : nil
101
108
  },
102
109
 
103
110
  "hobart_show_day(year)" => Proc.new { |year|
104
- fourth_sat_in_oct = Date.civil(year, 10, Holidays::DateCalculatorFactory.day_of_month_calculator.call(year, 10, 4, :saturday))
111
+ fourth_sat_in_oct = Date.civil(year, 10, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 4, :saturday))
105
112
  fourth_sat_in_oct - 2 # the thursday before
106
113
  },
107
114
 
@@ -109,7 +116,7 @@ fourth_sat_in_oct - 2 # the thursday before
109
116
  if year < 2006
110
117
  nil
111
118
  else
112
- Date.civil(year, 3, Holidays::DateCalculatorFactory.day_of_month_calculator.call(year, 3, :second, :monday))
119
+ Date.civil(year, 3, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 3, :second, :monday))
113
120
  end
114
121
  },
115
122
 
@@ -117,7 +124,7 @@ end
117
124
  if year >= 2006
118
125
  nil
119
126
  else
120
- Date.civil(year, 5, Holidays::DateCalculatorFactory.day_of_month_calculator.call(year, 5, :third, :monday))
127
+ Date.civil(year, 5, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 5, :third, :monday))
121
128
  end
122
129
  },
123
130
 
@@ -4,12 +4,6 @@ module Holidays
4
4
  #
5
5
  # Definitions loaded: definitions/be_fr.yaml
6
6
  #
7
- # To use the definitions in this file, load it right after you load the
8
- # Holiday gem:
9
- #
10
- # require 'holidays'
11
- # require 'generated_definitions/be_fr'
12
- #
13
7
  # All the definitions are available at https://github.com/holidays/holidays
14
8
  module BE_FR # :nodoc:
15
9
  def self.defined_regions
@@ -18,7 +12,7 @@ module Holidays
18
12
 
19
13
  def self.holidays_by_month
20
14
  {
21
- 0 => [{:function => "easter(year)", :function_arguments => [:year], :name => "Pâques", :regions => [:be_fr]},
15
+ 0 => [{:function => "easter(year)", :function_arguments => [:year], :name => "Pâques", :regions => [:be_fr]},
22
16
  {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 1, :name => "Lundi de Pâques", :regions => [:be_fr]},
23
17
  {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 39, :name => "Ascension", :regions => [:be_fr]},
24
18
  {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 49, :name => "Pentecôte", :regions => [:be_fr]},
@@ -35,7 +29,7 @@ module Holidays
35
29
 
36
30
  def self.custom_methods
37
31
  {
38
-
32
+
39
33
  }
40
34
  end
41
35
  end
@@ -4,12 +4,6 @@ module Holidays
4
4
  #
5
5
  # Definitions loaded: definitions/be_nl.yaml
6
6
  #
7
- # To use the definitions in this file, load it right after you load the
8
- # Holiday gem:
9
- #
10
- # require 'holidays'
11
- # require 'generated_definitions/be_nl'
12
- #
13
7
  # All the definitions are available at https://github.com/holidays/holidays
14
8
  module BE_NL # :nodoc:
15
9
  def self.defined_regions
@@ -18,7 +12,7 @@ module Holidays
18
12
 
19
13
  def self.holidays_by_month
20
14
  {
21
- 0 => [{:function => "easter(year)", :function_arguments => [:year], :name => "Pasen", :regions => [:be_nl]},
15
+ 0 => [{:function => "easter(year)", :function_arguments => [:year], :name => "Pasen", :regions => [:be_nl]},
22
16
  {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 1, :name => "Paasmaandag", :regions => [:be_nl]},
23
17
  {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 39, :name => "O.H. Hemelvaart", :regions => [:be_nl]},
24
18
  {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 49, :name => "Pinksteren", :regions => [:be_nl]},
@@ -35,7 +29,7 @@ module Holidays
35
29
 
36
30
  def self.custom_methods
37
31
  {
38
-
32
+
39
33
  }
40
34
  end
41
35
  end