holidays 4.6.0 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/CONTRIBUTING.md +5 -5
  4. data/Makefile +29 -0
  5. data/README.md +13 -1
  6. data/Rakefile +2 -2
  7. data/definitions/au.yaml +12 -9
  8. data/definitions/ca.yaml +17 -2
  9. data/definitions/ch.yaml +1 -1
  10. data/definitions/index.yaml +3 -0
  11. data/definitions/is.yaml +1 -1
  12. data/definitions/jp.yaml +19 -14
  13. data/definitions/kr.yaml +282 -0
  14. data/definitions/lu.yaml +56 -0
  15. data/definitions/my.yaml +51 -0
  16. data/definitions/ups.yaml +1 -1
  17. data/definitions/us.yaml +1 -1
  18. data/lib/generated_definitions/MANIFEST +3 -0
  19. data/lib/generated_definitions/REGIONS.rb +1 -1
  20. data/lib/generated_definitions/au.rb +11 -8
  21. data/lib/generated_definitions/ca.rb +1 -1
  22. data/lib/generated_definitions/ch.rb +1 -1
  23. data/lib/generated_definitions/europe.rb +2 -2
  24. data/lib/generated_definitions/is.rb +1 -1
  25. data/lib/generated_definitions/jp.rb +13 -15
  26. data/lib/generated_definitions/kr.rb +248 -0
  27. data/lib/generated_definitions/lu.rb +39 -0
  28. data/lib/generated_definitions/my.rb +36 -0
  29. data/lib/generated_definitions/north_america.rb +2 -2
  30. data/lib/generated_definitions/scandinavia.rb +1 -1
  31. data/lib/generated_definitions/ups.rb +1 -1
  32. data/lib/generated_definitions/us.rb +1 -1
  33. data/lib/holidays.rb +29 -51
  34. data/lib/holidays/core_extensions/date.rb +1 -1
  35. data/lib/holidays/definition/context/function_processor.rb +86 -0
  36. data/lib/holidays/definition/context/generator.rb +31 -6
  37. data/lib/holidays/definition/parser/custom_method.rb +1 -3
  38. data/lib/holidays/definition/repository/holidays_by_month.rb +1 -1
  39. data/lib/holidays/definition/validator/region.rb +1 -3
  40. data/lib/holidays/errors.rb +1 -0
  41. data/lib/holidays/factory/date_calculator.rb +37 -0
  42. data/lib/holidays/factory/definition.rb +96 -0
  43. data/lib/holidays/factory/finder.rb +70 -0
  44. data/lib/holidays/finder/context/between.rb +43 -0
  45. data/lib/holidays/{use_case → finder}/context/dates_driver_builder.rb +6 -4
  46. data/lib/holidays/finder/context/next_holiday.rb +57 -0
  47. data/lib/holidays/{option → finder}/context/parse_options.rb +6 -8
  48. data/lib/holidays/finder/context/search.rb +86 -0
  49. data/lib/holidays/finder/context/year_holiday.rb +57 -0
  50. data/lib/holidays/finder/rules/in_region.rb +23 -0
  51. data/lib/holidays/finder/rules/year_range.rb +82 -0
  52. data/lib/holidays/load_all_definitions.rb +7 -5
  53. data/lib/holidays/version.rb +1 -1
  54. data/test/coverage_report.rb +7 -0
  55. data/test/defs/test_defs_au.rb +1 -1
  56. data/test/defs/test_defs_ca.rb +16 -1
  57. data/test/defs/test_defs_jp.rb +4 -0
  58. data/test/defs/test_defs_kr.rb +26 -0
  59. data/test/defs/test_defs_lu.rb +24 -0
  60. data/test/defs/test_defs_my.rb +20 -0
  61. data/test/defs/test_defs_north_america.rb +16 -1
  62. data/test/holidays/core_extensions/test_date_time.rb +7 -7
  63. data/test/holidays/definition/context/test_function_processor.rb +175 -0
  64. data/test/holidays/definition/context/test_generator.rb +18 -11
  65. data/test/holidays/definition/parser/test_custom_method.rb +2 -2
  66. data/test/holidays/definition/repository/test_proc_result_cache.rb +1 -1
  67. data/test/holidays/{test_date_calculator_factory.rb → factory/test_date_calculator.rb} +3 -3
  68. data/test/holidays/factory/test_definition.rb +53 -0
  69. data/test/holidays/factory/test_finder.rb +25 -0
  70. data/test/holidays/finder/context/test_between.rb +172 -0
  71. data/test/holidays/{use_case → finder}/context/test_dates_driver_builder.rb +2 -2
  72. data/test/holidays/finder/context/test_next_holiday.rb +156 -0
  73. data/test/holidays/{option → finder}/context/test_parse_options.rb +9 -9
  74. data/test/holidays/finder/context/test_search.rb +203 -0
  75. data/test/holidays/finder/context/test_year_holiday.rb +202 -0
  76. data/test/holidays/finder/rules/test_in_region.rb +38 -0
  77. data/test/holidays/finder/rules/test_year_range.rb +170 -0
  78. data/test/integration/README.md +9 -0
  79. data/test/{test_all_regions.rb → integration/test_all_regions.rb} +16 -2
  80. data/test/{test_custom_holidays.rb → integration/test_custom_holidays.rb} +2 -2
  81. data/test/{test_custom_year_range_holidays.rb → integration/test_custom_year_range_holidays.rb} +1 -1
  82. data/test/{test_holidays.rb → integration/test_holidays.rb} +43 -32
  83. data/test/{test_holidays_between.rb → integration/test_holidays_between.rb} +8 -16
  84. data/test/{test_multiple_regions.rb → integration/test_multiple_regions.rb} +1 -1
  85. data/test/test_helper.rb +3 -4
  86. metadata +67 -39
  87. data/benchmark.rb +0 -8
  88. data/lib/holidays/date_calculator_factory.rb +0 -35
  89. data/lib/holidays/definition_factory.rb +0 -86
  90. data/lib/holidays/option_factory.rb +0 -15
  91. data/lib/holidays/use_case/context/between.rb +0 -45
  92. data/lib/holidays/use_case/context/context_common.rb +0 -123
  93. data/lib/holidays/use_case/context/next_holiday.rb +0 -54
  94. data/lib/holidays/use_case/context/year_holiday.rb +0 -51
  95. data/lib/holidays/use_case_factory.rb +0 -41
  96. data/test/holidays/test_definition_factory.rb +0 -49
  97. data/test/holidays/test_option_factory.rb +0 -9
  98. data/test/holidays/test_use_case_factory.rb +0 -13
  99. data/test/holidays/use_case/context/test_between.rb +0 -77
@@ -0,0 +1,56 @@
1
+ # Luxembourg holiday definitions for the Ruby Holiday gem.
2
+ #
3
+ # Updated: 2019-07-19.
4
+ # Sources:
5
+ # - https://en.wikipedia.org/wiki/Public_holidays_in_Luxembourg
6
+ ---
7
+ months:
8
+ 0:
9
+ - name: Ouschterméindeg
10
+ regions: [lu]
11
+ function: easter(year)
12
+ function_modifier: 1
13
+ - name: Christi Himmelfaart
14
+ regions: [lu]
15
+ function: easter(year)
16
+ function_modifier: 39
17
+ - name: Péngschtméindeg
18
+ regions: [lu]
19
+ function: easter(year)
20
+ function_modifier: 49
21
+ 1:
22
+ - name: Neijoerschdag
23
+ regions: [lu]
24
+ mday: 1
25
+ 6:
26
+ - name: Nationalfeierdag
27
+ regions: [lu]
28
+ mday: 23
29
+ 8:
30
+ - name: Léiffrawëschdag
31
+ regions: [lu]
32
+ mday: 15
33
+ 11:
34
+ - name: Allerhellgen
35
+ regions: [lu]
36
+ mday: 1
37
+ 12:
38
+ - name: Chrëschtdag
39
+ regions: [lu]
40
+ mday: 25
41
+ - name: Stiefesdag
42
+ regions: [lu]
43
+ mday: 26
44
+ tests: |
45
+ {Date.civil(2008,1,1) => 'Neijoerschdag',
46
+ Date.civil(2008,3,24) => 'Ouschterméindeg',
47
+ Date.civil(2008,5,1) => 'Christi Himmelfaart', # Ascension, Easter+39
48
+ Date.civil(2008,6,23) => 'Nationalfeierdag',
49
+ Date.civil(2008,8,15) => 'Léiffrawëschdag',
50
+ Date.civil(2008,11,1) => 'Allerhellgen',
51
+ Date.civil(2008,12,25) => 'Chrëschtdag',
52
+ Date.civil(2008,12,26) => 'Stiefesdag',
53
+ Date.civil(2008,5,11) => 'Péngschtméindeg'
54
+ }.each do |date, name|
55
+ assert_equal name, (Holidays.on(date, :lu, :informal)[0] || {})[:name]
56
+ end
@@ -0,0 +1,51 @@
1
+ # Malaysia holiday definitions for the Holidays gem!
2
+
3
+ # Days not included in the definitions (yet):
4
+ # Vesak Day (falls on the first full moon in May)
5
+ # Lunar New Year (falls on the first day of the Lunar Calendar)
6
+ # Hari Raya Puasa and Hari Raya Haji (based on moon sightings, Islamic Calendar)
7
+ # Deepavali (15th Day of September or October, based on the Hindu Calendar)
8
+
9
+ # Source:
10
+ # http://publicholidays.com.my/
11
+
12
+ months:
13
+ 1:
14
+ - name: New Year's Day
15
+ regions: [my]
16
+ mday: 1
17
+ observed: to_weekday_if_weekend(date)
18
+ 5:
19
+ - name: Labour Day
20
+ regions: [my]
21
+ mday: 1
22
+ 6:
23
+ - name: Agong's Birthday
24
+ regions: [my]
25
+ mday: 4
26
+ observed: to_weekday_if_weekend(date)
27
+ 8:
28
+ - name: Independence Day
29
+ regions: [my]
30
+ mday: 31
31
+ observed: to_weekday_if_weekend(date)
32
+ 9:
33
+ - name: Malaysia Day
34
+ regions: [my]
35
+ mday: 16
36
+ observed: to_weekday_if_weekend(date)
37
+ 12:
38
+ - name: Christmas Day
39
+ regions: [my]
40
+ mday: 25
41
+ observed: to_weekday_if_weekend(date)
42
+
43
+ tests: |
44
+ {Date.civil(2016,1,1) => "New Year's Day",
45
+ Date.civil(2016,5,1) => 'Labour Day',
46
+ Date.civil(2016,6,4) => "Agong's Birthday",
47
+ Date.civil(2016,8,31) => 'Independence Day',
48
+ Date.civil(2016,9,16) => 'Malaysia Day',
49
+ Date.civil(2016,12,25) => 'Christmas Day'}.each do |date, name|
50
+ assert_equal name, (Holidays.on(date, :my, :informal)[0] || {})[:name]
51
+ end
@@ -46,7 +46,7 @@ methods:
46
46
  day_after_thanksgiving:
47
47
  arguments: year
48
48
  source: |
49
- Holidays::DateCalculatorFactory.day_of_month_calculator.call(year, 11, 4, 4) + 1
49
+ Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 11, 4, 4) + 1
50
50
  tests: |
51
51
  {Date.civil(2008,1,1) => 'New Year\'s Day',
52
52
  Date.civil(2008,5,26) => 'Memorial Day',
@@ -81,7 +81,7 @@ methods:
81
81
  day_after_thanksgiving:
82
82
  arguments: year
83
83
  source: |
84
- Holidays::DateCalculatorFactory.day_of_month_calculator.call(year, 11, 4, 4) + 1
84
+ Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 11, 4, 4) + 1
85
85
  tests: |
86
86
  {Date.civil(2008,1,1) => 'New Year\'s Day',
87
87
  Date.civil(2008,1,21) => 'Martin Luther King, Jr. Day',
@@ -32,10 +32,13 @@ The following definition files are included in this installation:
32
32
  * generated_definitions/is
33
33
  * generated_definitions/it
34
34
  * generated_definitions/jp
35
+ * generated_definitions/kr
35
36
  * generated_definitions/li
36
37
  * generated_definitions/lt
38
+ * generated_definitions/lu
37
39
  * generated_definitions/ma
38
40
  * generated_definitions/mx
41
+ * generated_definitions/my
39
42
  * generated_definitions/nerc
40
43
  * generated_definitions/nl
41
44
  * generated_definitions/no
@@ -1,4 +1,4 @@
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, :pe, :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_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, :kr, :li, :lt, :ma, :mx, :mx_pue, :us, :ca, :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, :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, :my]
4
4
  end
@@ -63,14 +63,17 @@ module Holidays
63
63
  def self.custom_methods
64
64
  {
65
65
  "afl_grand_final(year)" => Proc.new { |year|
66
- if year == 2015
66
+ case year
67
+ when 2015
67
68
  Date.civil(2015, 10, 2)
69
+ when 2016
70
+ Date.civil(2017, 9, 30)
68
71
  end
69
72
  },
70
73
 
71
74
  "qld_queens_bday_october(year)" => Proc.new { |year|
72
75
  if year >= 2016
73
- DateCalculatorFactory.day_of_month_calculator.call(year, 10, 1, 1)
76
+ Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 1, 1)
74
77
  elsif year == 2012
75
78
  1
76
79
  else
@@ -80,19 +83,19 @@ end
80
83
 
81
84
  "qld_queens_birthday_june(year)" => Proc.new { |year|
82
85
  if year <= 2015
83
- DateCalculatorFactory.day_of_month_calculator.call(year, 6, 2, 1)
86
+ Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 6, 2, 1)
84
87
  end
85
88
  },
86
89
 
87
90
  "qld_labour_day_may(year)" => Proc.new { |year|
88
91
  if year < 2013 || year >= 2016
89
- DateCalculatorFactory.day_of_month_calculator.call(year, 5, 1, 1)
92
+ Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 5, 1, 1)
90
93
  end
91
94
  },
92
95
 
93
96
  "qld_labour_day_october(year)" => Proc.new { |year|
94
97
  if year >= 2013 && year < 2016
95
- DateCalculatorFactory.day_of_month_calculator.call(year, 10, 1, 1)
98
+ Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 1, 1)
96
99
  end
97
100
  },
98
101
 
@@ -101,7 +104,7 @@ year == 2014 ? 14 : nil
101
104
  },
102
105
 
103
106
  "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))
107
+ fourth_sat_in_oct = Date.civil(year, 10, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 4, :saturday))
105
108
  fourth_sat_in_oct - 2 # the thursday before
106
109
  },
107
110
 
@@ -109,7 +112,7 @@ fourth_sat_in_oct - 2 # the thursday before
109
112
  if year < 2006
110
113
  nil
111
114
  else
112
- Date.civil(year, 3, Holidays::DateCalculatorFactory.day_of_month_calculator.call(year, 3, :second, :monday))
115
+ Date.civil(year, 3, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 3, :second, :monday))
113
116
  end
114
117
  },
115
118
 
@@ -117,7 +120,7 @@ end
117
120
  if year >= 2006
118
121
  nil
119
122
  else
120
- Date.civil(year, 5, Holidays::DateCalculatorFactory.day_of_month_calculator.call(year, 5, :third, :monday))
123
+ Date.civil(year, 5, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 5, :third, :monday))
121
124
  end
122
125
  },
123
126
 
@@ -55,7 +55,7 @@ module Holidays
55
55
  9 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:ca]}],
56
56
  10 => [{:wday => 1, :week => 2, :name => "Thanksgiving", :regions => [:ca]},
57
57
  {:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]}],
58
- 11 => [{:mday => 11, :name => "Remembrance Day", :regions => [:ca]}],
58
+ 11 => [{:mday => 11, :name => "Remembrance Day", :regions => [:ca_ab, :ca_sk, :ca_bc, :ca_pe, :ca_nf, :ca_nt, :ca_nu, :ca_nb, :ca_yk]}],
59
59
  12 => [{:mday => 25, :name => "Christmas Day", :regions => [:ca]},
60
60
  {:mday => 26, :name => "Boxing Day", :regions => [:ca]}],
61
61
  4 => [{:mday => 1, :type => :informal, :name => "April Fool's Day", :regions => [:us, :ca]},
@@ -76,7 +76,7 @@ until date.wday.eql? 4 do
76
76
  date += 1
77
77
  end
78
78
 
79
- if date.eql?(Holidays::DateCalculatorFactory::Easter::Gregorian.easter_calculator.calculate_easter_for(year)-3)
79
+ if date.eql?(Holidays::Factory::DateCalculator::Easter::Gregorian.easter_calculator.calculate_easter_for(year)-3)
80
80
  date += 7
81
81
  end
82
82
  date
@@ -507,7 +507,7 @@ until date.wday.eql? 4 do
507
507
  date += 1
508
508
  end
509
509
 
510
- if date.eql?(Holidays::DateCalculatorFactory::Easter::Gregorian.easter_calculator.calculate_easter_for(year)-3)
510
+ if date.eql?(Holidays::Factory::DateCalculator::Easter::Gregorian.easter_calculator.calculate_easter_for(year)-3)
511
511
  date += 7
512
512
  end
513
513
  date
@@ -535,7 +535,7 @@ end
535
535
  date = Date.civil(year,4,18)
536
536
  if date.wday < 4
537
537
  date += (4 - date.wday)
538
- else date
538
+ else
539
539
  date += (11 - date.wday)
540
540
  end
541
541
  date
@@ -53,7 +53,7 @@ module Holidays
53
53
  date = Date.civil(year,4,18)
54
54
  if date.wday < 4
55
55
  date += (4 - date.wday)
56
- else date
56
+ else
57
57
  date += (11 - date.wday)
58
58
  end
59
59
  date
@@ -40,7 +40,7 @@ module Holidays
40
40
  {:function => "jp_mountain_holiday_substitute(year)", :function_arguments => [:year], :year_ranges => [{:after => 2016}],:name => "振替休日", :regions => [:jp]}],
41
41
  9 => [{:wday => 1, :week => 3, :name => "敬老の日", :regions => [:jp]},
42
42
  {:function => "jp_respect_for_aged_holiday_substitute(year)", :function_arguments => [:year], :name => "振替休日", :regions => [:jp]},
43
- {:function => "jp_citizens_holiday(year)", :function_arguments => [:year], :name => "国民の休日", :regions => [:jp]},
43
+ {:function => "jp_citizens_holiday(year)", :function_arguments => [:year], :year_ranges => [{:after => 2003}],:name => "国民の休日", :regions => [:jp]},
44
44
  {:function => "jp_national_culture_day(year)", :function_arguments => [:year], :name => "秋分の日", :regions => [:jp]},
45
45
  {:function => "jp_national_culture_day_substitute(year)", :function_arguments => [:year], :name => "振替休日", :regions => [:jp]}],
46
46
  10 => [{:wday => 1, :week => 2, :name => "体育の日", :regions => [:jp]},
@@ -57,7 +57,7 @@ module Holidays
57
57
  def self.custom_methods
58
58
  {
59
59
  "jp_health_sports_day_substitute(year)" => Proc.new { |year|
60
- Holidays::DefinitionFactory.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, 10, Holidays::DateCalculatorFactory.day_of_month_calculator.call(year, 10, 2, 1))
60
+ Holidays::Factory::Definition.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, 10, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 2, 1))
61
61
  },
62
62
 
63
63
  "jp_vernal_equinox_day(year)" => Proc.new { |year|
@@ -80,12 +80,12 @@ Date.civil(year, 3, day)
80
80
  },
81
81
 
82
82
  "jp_vernal_equinox_day_substitute(year)" => Proc.new { |year|
83
- date = Holidays::DefinitionFactory.custom_methods_repository.find("jp_vernal_equinox_day(year)").call(year)
84
- Holidays::DefinitionFactory.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, date.month, date.mday)
83
+ date = Holidays::Factory::Definition.custom_methods_repository.find("jp_vernal_equinox_day(year)").call(year)
84
+ Holidays::Factory::Definition.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, date.month, date.mday)
85
85
  },
86
86
 
87
87
  "jp_marine_day_substitute(year)" => Proc.new { |year|
88
- Holidays::DefinitionFactory.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, 7, Holidays::DateCalculatorFactory.day_of_month_calculator.call(year, 7, 3, 1))
88
+ Holidays::Factory::Definition.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, 7, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 7, 3, 1))
89
89
  },
90
90
 
91
91
  "jp_national_culture_day(year)" => Proc.new { |year|
@@ -108,13 +108,12 @@ Date.civil(year, 9, day)
108
108
  },
109
109
 
110
110
  "jp_national_culture_day_substitute(year)" => Proc.new { |year|
111
- date = Holidays::DefinitionFactory.custom_methods_repository.find("jp_national_culture_day(year)").call(year)
112
- Holidays::DefinitionFactory.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, date.month, date.mday)
111
+ date = Holidays::Factory::Definition.custom_methods_repository.find("jp_national_culture_day(year)").call(year)
112
+ Holidays::Factory::Definition.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, date.month, date.mday)
113
113
  },
114
114
 
115
115
  "jp_citizens_holiday(year)" => Proc.new { |year|
116
- year < 2003 and return nil
117
- ncd = Holidays::DefinitionFactory.custom_methods_repository.find("jp_national_culture_day(year)").call(year)
116
+ ncd = Holidays::Factory::Definition.custom_methods_repository.find("jp_national_culture_day(year)").call(year)
118
117
  if ncd.wday == 3
119
118
  ncd - 1
120
119
  else
@@ -123,29 +122,28 @@ end
123
122
  },
124
123
 
125
124
  "jp_mountain_holiday(year)" => Proc.new { |year|
126
- return nil if year < 2016
127
125
  Date.civil(year, 8, 11)
128
126
  },
129
127
 
130
128
  "jp_mountain_holiday_substitute(year)" => Proc.new { |year|
131
- date = Holidays::DefinitionFactory.custom_methods_repository.find("jp_mountain_holiday(year)").call(year)
132
- Holidays::DefinitionFactory.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, date.month, date.mday)
129
+ date = Holidays::Factory::Definition.custom_methods_repository.find("jp_mountain_holiday(year)").call(year)
130
+ Holidays::Factory::Definition.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, date.month, date.mday)
133
131
  },
134
132
 
135
133
  "jp_respect_for_aged_holiday_substitute(year)" => Proc.new { |year|
136
- Holidays::DefinitionFactory.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, 9, Holidays::DateCalculatorFactory.day_of_month_calculator.call(year, 9, 3, 1))
134
+ Holidays::Factory::Definition.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, 9, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 9, 3, 1))
137
135
  },
138
136
 
139
137
  "jp_substitute_holiday(year, month, day)" => Proc.new { |year, month, day|
140
138
  date = Date.civil(year, month, day)
141
- date.wday == 0 ? (Holidays::DefinitionFactory.custom_methods_repository.find("jp_next_weekday(date)").call(date+1)) : nil
139
+ date.wday == 0 ? (Holidays::Factory::Definition.custom_methods_repository.find("jp_next_weekday(date)").call(date+1)) : nil
142
140
  },
143
141
 
144
142
  "jp_next_weekday(date)" => Proc.new { |date|
145
143
  is_holiday = Holidays::JP.holidays_by_month[date.month].any? do |holiday|
146
144
  holiday[:mday] == date.day
147
145
  end
148
- date.wday == 0 || is_holiday ? (Holidays::DefinitionFactory.custom_methods_repository.find("jp_next_weekday(date)").call(date+1)) : date
146
+ date.wday == 0 || is_holiday ? (Holidays::Factory::Definition.custom_methods_repository.find("jp_next_weekday(date)").call(date+1)) : date
149
147
  },
150
148
 
151
149
 
@@ -0,0 +1,248 @@
1
+ # encoding: utf-8
2
+ module Holidays
3
+ # This file is generated by the Ruby Holidays gem.
4
+ #
5
+ # Definitions loaded: definitions/kr.yaml
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/kr'
12
+ #
13
+ # All the definitions are available at https://github.com/holidays/holidays
14
+ module KR # :nodoc:
15
+ def self.defined_regions
16
+ [:kr]
17
+ end
18
+
19
+ def self.holidays_by_month
20
+ {
21
+ 0 => [{:function => "kr_new_years(year)", :function_arguments => [:year], :name => "Korean New Year", :regions => [:kr]},
22
+ {:function => "kr_buddahs_birthday(year)", :function_arguments => [:year], :name => "Buddah's Birthday", :regions => [:kr]},
23
+ {:function => "kr_thanksgiving(year)", :function_arguments => [:year], :name => "Korean Thanksgiving", :regions => [:kr]}],
24
+ 1 => [{:mday => 1, :name => "New Year's Day", :regions => [:kr]}],
25
+ 3 => [{:mday => 1, :name => "Independence Movement Day", :regions => [:kr]}],
26
+ 5 => [{:mday => 5, :name => "Children's Day", :regions => [:kr]}],
27
+ 6 => [{:mday => 6, :name => "Memorial Day", :regions => [:kr]}],
28
+ 7 => [{:mday => 17, :type => :informal, :name => "Constitution Day", :regions => [:kr]}],
29
+ 8 => [{:mday => 15, :name => "Liberation Day", :regions => [:kr]}],
30
+ 10 => [{:mday => 3, :name => "National Foundation Day", :regions => [:kr]},
31
+ {:mday => 9, :name => "Hangul Day", :regions => [:kr]}],
32
+ 12 => [{:mday => 25, :name => "Christmas Day", :regions => [:kr]}]
33
+ }
34
+ end
35
+
36
+ def self.custom_methods
37
+ {
38
+ "kr_new_years(year)" => Proc.new { |year|
39
+ month_day = case year
40
+ when 1941
41
+ [1, 17]
42
+ when 1966
43
+ [1, 21]
44
+ when 1909, 1947, 2004, 2023, 2042
45
+ [1, 22]
46
+ when 1917, 1928, 1974, 1993, 2012, 2031, 2015
47
+ [1, 23]
48
+ when 1925, 1936, 1955, 2001, 2039
49
+ [1, 24]
50
+ when 1906, 1944, 1963, 1982, 2020
51
+ [1, 25]
52
+ when 1914, 1933, 2009, 2028, 2047
53
+ [1, 26]
54
+ when 1952, 1971, 1990
55
+ [1, 27]
56
+ when 1922, 1960, 1979, 1998, 2017, 2036
57
+ [1, 28]
58
+ when 1903, 1949, 1987, 2006, 2025
59
+ [1, 29]
60
+ when 1911, 1930, 1968, 2044
61
+ [1, 30]
62
+ when 1938, 1957, 1976, 1995, 2014, 2033
63
+ [1, 31]
64
+ when 1919, 1948, 2003, 2022, 2041
65
+ [2, 1]
66
+ when 1908, 1927, 1946, 1965, 1984, 2049
67
+ [2, 2]
68
+ when 1916, 1954, 1973, 2011, 2030
69
+ [2, 3]
70
+ when 1905, 1935, 1992, 2038
71
+ [2, 4]
72
+ when 1924, 1943, 1962, 1981, 1989, 2000, 2019
73
+ [2, 5]
74
+ when 1913, 1932, 1951, 1970, 2027, 2046
75
+ [2, 6]
76
+ when 1978, 1997, 2008
77
+ [2, 7]
78
+ when 1902, 1921, 1940, 1959, 2016, 2035
79
+ [2, 8]
80
+ when 1967, 1986, 2005
81
+ [2, 9]
82
+ when 1910, 1929, 1994, 2013, 2024, 2043
83
+ [2, 10]
84
+ when 1918, 1937, 1975, 2032
85
+ [2, 11]
86
+ when 1956, 2002, 2021, 2040
87
+ [2, 12]
88
+ when 1907, 1926, 1945, 1964, 1983, 2029
89
+ [2, 13]
90
+ when 1915, 1934, 1953, 2010, 2048
91
+ [2, 14]
92
+ when 1942, 1961, 1972, 1991, 2037
93
+ [2, 15]
94
+ when 1904, 1923, 1980, 1999, 2018
95
+ [2, 16]
96
+ when 1931, 1950, 1969, 1988, 2026, 2045
97
+ [2, 17]
98
+ when 1912, 1958, 1977, 2007
99
+ [2, 18]
100
+ when 1901, 1939, 1996, 2015, 2034
101
+ [2, 19]
102
+ when 1920, 1985
103
+ [2, 20]
104
+ end
105
+ Date.civil(year, month_day[0], month_day[1])
106
+ },
107
+
108
+ "kr_buddahs_birthday(year)" => Proc.new { |year|
109
+ month_day = case year
110
+ when 2039
111
+ [4, 30]
112
+ when 1952, 1963, 1982
113
+ [5, 1]
114
+ when 1914, 1933, 1971, 1990, 2009, 2028, 2047
115
+ [5, 2]
116
+ when 1941, 1960, 1979, 1998, 2017, 2036
117
+ [5, 3]
118
+ when 1901, 1903, 1922, 1968
119
+ [5, 4]
120
+ when 1949, 1987, 2006, 2012, 2025, 2044
121
+ [5, 5]
122
+ when 1911, 1930, 1976, 2014, 2033
123
+ [5, 6]
124
+ when 1908, 1919, 1957, 1995, 2041
125
+ [5, 7]
126
+ when 1927, 1946, 1965, 1984, 2003, 2022
127
+ [5, 8]
128
+ when 1916, 2030, 2049
129
+ [5, 9]
130
+ when 1935, 1954, 1973, 1992, 2011
131
+ [5, 10]
132
+ when 1905, 1924, 1943, 1962, 1981, 2000, 2038
133
+ [5, 11]
134
+ when 1970, 1989, 2008, 2019
135
+ [5, 12]
136
+ when 1913, 1932, 1951, 2027
137
+ [5, 13]
138
+ when 1938, 1940, 1978, 1997, 2016
139
+ [5, 14]
140
+ when 1902, 1921, 1959, 2005, 2024, 2035
141
+ [5, 15]
142
+ when 1910, 1929, 1948, 1967, 1986, 2032, 2043
143
+ [5, 16]
144
+ when 1918, 1937, 1956, 2013
145
+ [5, 17]
146
+ when 1975, 1994, 2040
147
+ [5, 18]
148
+ when 1907, 1926, 1945, 1964, 2002, 2021
149
+ [5, 19]
150
+ when 1934, 1953, 1972, 1983, 2029, 2046, 2048
151
+ [5, 20]
152
+ when 1915, 1980, 1991, 2010
153
+ [5, 21]
154
+ when 1904, 1942, 1961, 1999, 2018, 2037
155
+ [5, 22]
156
+ when 1923, 1969, 1988
157
+ [5, 23]
158
+ when 1912, 1931, 1950, 1996, 2007, 2026, 2045
159
+ [5, 24]
160
+ when 1920, 1977, 2015, 2034
161
+ [5, 25]
162
+ when 1909, 1928, 1939, 1947, 1958, 2004, 2023, 2042
163
+ [5, 26]
164
+ when 1966, 1985
165
+ [5, 27]
166
+ when 1917, 1936, 1993, 2031, 2050
167
+ [5, 28]
168
+ when 1925, 1944, 1955, 1974
169
+ [5, 29]
170
+ when 1906, 2001, 2020
171
+ [5, 30]
172
+ end
173
+ Date.civil(year, month_day[0], month_day[1])
174
+ },
175
+
176
+ "kr_thanksgiving(year)" => Proc.new { |year|
177
+ month_day = case year
178
+ when 1905, 1924, 1973
179
+ [9, 8]
180
+ when 1913, 1970, 1989, 2000, 2008, 2019, 2038
181
+ [9, 10]
182
+ when 1902, 1932, 1938, 1981, 2027
183
+ [9, 11]
184
+ when 1929, 1940, 1951, 1978, 2016, 2035
185
+ [9, 12]
186
+ when 1921, 1948, 1959, 1997, 2024
187
+ [9, 13]
188
+ when 1910, 1975, 2005
189
+ [9, 14]
190
+ when 1918, 1937, 1945, 1967, 1986, 2032, 2043
191
+ [9, 15]
192
+ when 1907, 1964, 1994, 2013, 2040
193
+ [9, 16]
194
+ when 1926, 1956, 1962, 1972, 2046, 2048
195
+ [9, 17]
196
+ when 1934, 1953, 2002, 2021
197
+ [9, 18]
198
+ when 1904, 1915, 1980, 2010, 2029
199
+ [9, 19]
200
+ when 1923, 1969, 1983, 1991, 1999
201
+ [9, 20]
202
+ when 1942, 1961, 1988, 2037
203
+ [9, 21]
204
+ when 1912, 1977 ,1996, 2007, 2015, 2018, 2026
205
+ [9, 22]
206
+ when 1931, 1939, 1950
207
+ [9, 23]
208
+ when 1909, 1920, 1947, 1958, 2034, 2045
209
+ [9, 24]
210
+ when 1917, 1928, 1936, 1966, 1985, 2050
211
+ [9, 25]
212
+ when 2001, 2004, 2023, 2042
213
+ [9, 26]
214
+ when 1906, 1925, 1944, 1955, 1974, 1993, 2031
215
+ [9, 27]
216
+ when 1914, 1963, 1971, 2009
217
+ [9, 28]
218
+ when 1933, 1952, 1982, 2020
219
+ [9, 29]
220
+ when 1941, 1979, 1990, 2017, 2028, 2036, 2047
221
+ [9, 30]
222
+ when 1901, 1960, 1968, 1987, 2006
223
+ [10, 1]
224
+ when 1903, 1922, 1949, 1998
225
+ [10, 2]
226
+ when 1911, 1976, 2014, 2033, 2044
227
+ [10, 3]
228
+ when 1927, 1930, 2012, 2025, 2041
229
+ [10, 4]
230
+ when 1908, 1919, 1935, 1946, 1957, 1995, 2039
231
+ [10, 5]
232
+ when 1916, 1965, 2003, 2022, 2030, 2049
233
+ [10, 6]
234
+ when 1984
235
+ [10, 7]
236
+ when 1943, 1954, 1992
237
+ [10, 8]
238
+ when 2011
239
+ [10, 9]
240
+ end
241
+ Date.civil(year, month_day[0], month_day[1])
242
+ },
243
+
244
+
245
+ }
246
+ end
247
+ end
248
+ end