holidays 11.3.0 → 11.5.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 (116) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/lib/generated_definitions/MANIFEST +2 -0
  4. data/lib/generated_definitions/REGIONS.rb +3 -3
  5. data/lib/generated_definitions/ar.rb +1 -18
  6. data/lib/generated_definitions/at.rb +1 -3
  7. data/lib/generated_definitions/au.rb +1 -86
  8. data/lib/generated_definitions/be_fr.rb +1 -3
  9. data/lib/generated_definitions/be_nl.rb +1 -3
  10. data/lib/generated_definitions/bg.rb +1 -3
  11. data/lib/generated_definitions/br.rb +1 -3
  12. data/lib/generated_definitions/by.rb +39 -0
  13. data/lib/generated_definitions/ca.rb +4 -14
  14. data/lib/generated_definitions/ch.rb +1 -48
  15. data/lib/generated_definitions/cl.rb +1 -33
  16. data/lib/generated_definitions/cn.rb +39 -0
  17. data/lib/generated_definitions/co.rb +10 -90
  18. data/lib/generated_definitions/cr.rb +1 -3
  19. data/lib/generated_definitions/cy.rb +1 -3
  20. data/lib/generated_definitions/cz.rb +1 -3
  21. data/lib/generated_definitions/de.rb +2 -14
  22. data/lib/generated_definitions/dk.rb +1 -3
  23. data/lib/generated_definitions/ecbtarget.rb +1 -3
  24. data/lib/generated_definitions/ee.rb +1 -3
  25. data/lib/generated_definitions/es.rb +2 -4
  26. data/lib/generated_definitions/europe.rb +5 -95
  27. data/lib/generated_definitions/federalreserve.rb +1 -3
  28. data/lib/generated_definitions/federalreservebanks.rb +1 -3
  29. data/lib/generated_definitions/fedex.rb +1 -7
  30. data/lib/generated_definitions/fi.rb +1 -25
  31. data/lib/generated_definitions/fr.rb +1 -3
  32. data/lib/generated_definitions/gb.rb +1 -3
  33. data/lib/generated_definitions/ge.rb +1 -3
  34. data/lib/generated_definitions/gr.rb +1 -3
  35. data/lib/generated_definitions/hk.rb +1 -3
  36. data/lib/generated_definitions/hr.rb +1 -3
  37. data/lib/generated_definitions/hu.rb +1 -3
  38. data/lib/generated_definitions/ie.rb +1 -12
  39. data/lib/generated_definitions/il.rb +1 -3
  40. data/lib/generated_definitions/in.rb +1 -3
  41. data/lib/generated_definitions/is.rb +1 -13
  42. data/lib/generated_definitions/it.rb +1 -3
  43. data/lib/generated_definitions/jp.rb +1 -95
  44. data/lib/generated_definitions/ke.rb +1 -3
  45. data/lib/generated_definitions/kr.rb +4 -6
  46. data/lib/generated_definitions/kz.rb +1 -3
  47. data/lib/generated_definitions/li.rb +1 -3
  48. data/lib/generated_definitions/lt.rb +1 -3
  49. data/lib/generated_definitions/lu.rb +1 -3
  50. data/lib/generated_definitions/lv.rb +1 -17
  51. data/lib/generated_definitions/ma.rb +1 -3
  52. data/lib/generated_definitions/mc.rb +1 -3
  53. data/lib/generated_definitions/mt_en.rb +1 -3
  54. data/lib/generated_definitions/mt_mt.rb +1 -3
  55. data/lib/generated_definitions/mx.rb +4 -4
  56. data/lib/generated_definitions/my.rb +1 -3
  57. data/lib/generated_definitions/nerc.rb +1 -3
  58. data/lib/generated_definitions/ng.rb +1 -3
  59. data/lib/generated_definitions/nl.rb +1 -3
  60. data/lib/generated_definitions/no.rb +1 -3
  61. data/lib/generated_definitions/northamerica.rb +4 -97
  62. data/lib/generated_definitions/nyse.rb +1 -3
  63. data/lib/generated_definitions/nz.rb +4 -70
  64. data/lib/generated_definitions/pe.rb +12 -10
  65. data/lib/generated_definitions/ph.rb +1 -9
  66. data/lib/generated_definitions/pl.rb +1 -3
  67. data/lib/generated_definitions/pt.rb +1 -3
  68. data/lib/generated_definitions/ro.rb +3 -5
  69. data/lib/generated_definitions/rs_cyrl.rb +1 -3
  70. data/lib/generated_definitions/rs_la.rb +1 -3
  71. data/lib/generated_definitions/ru.rb +1 -3
  72. data/lib/generated_definitions/scandinavia.rb +1 -47
  73. data/lib/generated_definitions/se.rb +1 -15
  74. data/lib/generated_definitions/sg.rb +1 -3
  75. data/lib/generated_definitions/si.rb +1 -3
  76. data/lib/generated_definitions/sk.rb +1 -3
  77. data/lib/generated_definitions/southamerica.rb +18 -139
  78. data/lib/generated_definitions/th.rb +1 -3
  79. data/lib/generated_definitions/tn.rb +1 -3
  80. data/lib/generated_definitions/tr.rb +1 -29
  81. data/lib/generated_definitions/tsx.rb +1 -13
  82. data/lib/generated_definitions/ua.rb +1 -3
  83. data/lib/generated_definitions/unitednations.rb +1 -3
  84. data/lib/generated_definitions/ups.rb +1 -7
  85. data/lib/generated_definitions/us.rb +4 -87
  86. data/lib/generated_definitions/ve.rb +1 -3
  87. data/lib/generated_definitions/vn.rb +1 -3
  88. data/lib/generated_definitions/za.rb +1 -3
  89. data/lib/holidays/{load_all_definitions.rb → bootstrap.rb} +15 -8
  90. data/lib/holidays/date_calculator/lunar_date.rb +1 -0
  91. data/lib/holidays/definition/context/generator.rb +4 -0
  92. data/lib/holidays/definition/custom_methods/ar.rb +28 -0
  93. data/lib/holidays/definition/custom_methods/au.rb +96 -0
  94. data/lib/holidays/definition/custom_methods/ca.rb +23 -0
  95. data/lib/holidays/definition/custom_methods/ch.rb +58 -0
  96. data/lib/holidays/definition/custom_methods/cl.rb +43 -0
  97. data/lib/holidays/definition/custom_methods/cn.rb +31 -0
  98. data/lib/holidays/definition/custom_methods/co.rb +22 -0
  99. data/lib/holidays/definition/custom_methods/de.rb +23 -0
  100. data/lib/holidays/definition/custom_methods/fedex.rb +17 -0
  101. data/lib/holidays/definition/custom_methods/fi.rb +35 -0
  102. data/lib/holidays/definition/custom_methods/ie.rb +22 -0
  103. data/lib/holidays/definition/custom_methods/is.rb +23 -0
  104. data/lib/holidays/definition/custom_methods/jp.rb +107 -0
  105. data/lib/holidays/definition/custom_methods/kr.rb +17 -0
  106. data/lib/holidays/definition/custom_methods/lv.rb +27 -0
  107. data/lib/holidays/definition/custom_methods/nz.rb +77 -0
  108. data/lib/holidays/definition/custom_methods/ph.rb +19 -0
  109. data/lib/holidays/definition/custom_methods/registry.rb +103 -0
  110. data/lib/holidays/definition/custom_methods/se.rb +25 -0
  111. data/lib/holidays/definition/custom_methods/tr.rb +59 -0
  112. data/lib/holidays/definition/custom_methods/us.rb +92 -0
  113. data/lib/holidays/definition/generator/module.rb +7 -4
  114. data/lib/holidays/version.rb +1 -1
  115. data/lib/holidays.rb +4 -2
  116. metadata +25 -2
@@ -0,0 +1,23 @@
1
+ require 'date'
2
+
3
+ module Holidays
4
+ module Definition
5
+ module CustomMethods
6
+ # ca custom holiday calculations, ported verbatim from the
7
+ # +methods:+ block in definitions/ca.yaml.
8
+ module CA
9
+ class << self
10
+ def ca_victoria_day(year)
11
+ date = Date.civil(year,5,24)
12
+ if date.wday > 1
13
+ date -= (date.wday - 1)
14
+ elsif date.wday == 0
15
+ date -= 6
16
+ end
17
+ date
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,58 @@
1
+ require 'date'
2
+
3
+ module Holidays
4
+ module Definition
5
+ module CustomMethods
6
+ # ch custom holiday calculations, ported verbatim from the
7
+ # +methods:+ block in definitions/ch.yaml.
8
+ module CH
9
+ class << self
10
+ def ch_vd_lundi_du_jeune_federal(year)
11
+ date = Date.civil(year,9,1)
12
+ # Find the first Sunday of September
13
+ until date.wday.eql? 0 do
14
+ date += 1
15
+ end
16
+ # There are 15 days between the first Sunday
17
+ # and the Monday after the third Sunday
18
+ date + 15
19
+ end
20
+
21
+ def ch_ge_jeune_genevois(year)
22
+ date = Date.civil(year,9,1)
23
+ # Find the first Sunday of September
24
+ until date.wday.eql? 0 do
25
+ date += 1
26
+ end
27
+ # Thursday is four days after Sunday
28
+ date + 4
29
+ end
30
+
31
+ def ch_gl_naefelser_fahrt(year)
32
+ date = Date.civil(year,4,1)
33
+ # Find the first Thursday of April
34
+ until date.wday.eql? 4 do
35
+ date += 1
36
+ end
37
+
38
+ if date.eql?(Holidays::Factory::DateCalculator::Easter::Gregorian.easter_calculator.calculate_easter_for(year)-3)
39
+ date += 7
40
+ end
41
+ date
42
+ end
43
+
44
+ def ch_be_zibelemaerit(year)
45
+ date = Date.civil(year,11,1)
46
+ # Find the first Monday of November
47
+ until date.wday.eql? 1 do
48
+ date += 1
49
+ end
50
+ # There are 21 days between the first monday
51
+ # and the 4rth Monday after
52
+ date + 21
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,43 @@
1
+ require 'date'
2
+
3
+ module Holidays
4
+ module Definition
5
+ module CustomMethods
6
+ # cl custom holiday calculations, ported verbatim from the
7
+ # +methods:+ block in definitions/cl.yaml.
8
+ module CL
9
+ class << self
10
+ def st_peter_st_paul_cl(year)
11
+ date = Date.civil(year, 6, 29)
12
+ if [2,3,4].include?(date.wday)
13
+ date -= (date.wday - 1)
14
+ elsif date.wday == 5
15
+ date += 3
16
+ end
17
+ date
18
+ end
19
+
20
+ def columbus_day_cl(year)
21
+ date = Date.civil(year, 10, 12)
22
+ if [2,3,4].include?(date.wday)
23
+ date -= (date.wday - 1)
24
+ elsif date.wday == 5
25
+ date += 3
26
+ end
27
+ date
28
+ end
29
+
30
+ def other_churches_day_cl(year)
31
+ date = Date.civil(year, 10, 31)
32
+ if date.wday == 2
33
+ date -= 4
34
+ elsif date.wday == 3
35
+ date += 2
36
+ end
37
+ date
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,31 @@
1
+ require 'date'
2
+
3
+ module Holidays
4
+ module Definition
5
+ module CustomMethods
6
+ # cn custom holiday calculations, ported verbatim from the
7
+ # +methods:+ block in definitions/cn.yaml.
8
+ module CN
9
+ class << self
10
+ # Qingming falls when the sun reaches celestial longitude 15 degrees,
11
+ # which lands on 4 or 5 April. This is the standard solar-term
12
+ # approximation; the century constant shifts between the 20th and
13
+ # 21st centuries.
14
+ def cn_qingming(year)
15
+ constant =
16
+ case year
17
+ when 1900..1999
18
+ 5.59
19
+ when 2000..2099
20
+ 4.81
21
+ else
22
+ raise IndexError.new("Out of range")
23
+ end
24
+ y = year % 100
25
+ Date.civil(year, 4, (y * 0.2422 + constant).floor - (y / 4))
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,22 @@
1
+ require 'date'
2
+
3
+ module Holidays
4
+ module Definition
5
+ module CustomMethods
6
+ # co custom holiday calculations, ported verbatim from the
7
+ # +methods:+ block in definitions/co.yaml.
8
+ module CO
9
+ class << self
10
+ def to_following_monday_if_not_monday(date)
11
+ if date.wday > 1
12
+ date += ( 8 - date.wday )
13
+ elsif date.wday == 0
14
+ date += 1
15
+ end
16
+ date
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ require 'date'
2
+
3
+ module Holidays
4
+ module Definition
5
+ module CustomMethods
6
+ # de custom holiday calculations, ported verbatim from the
7
+ # +methods:+ block in definitions/de.yaml.
8
+ module DE
9
+ class << self
10
+ def de_buss_und_bettag(year)
11
+ date = Date.civil(year,11,23)
12
+ if date.wday > 3
13
+ date -= (date.wday - 3)
14
+ else
15
+ date -= (date.wday + 4)
16
+ end
17
+ date
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ require 'date'
2
+
3
+ module Holidays
4
+ module Definition
5
+ module CustomMethods
6
+ # fedex custom holiday calculations, ported verbatim from the
7
+ # +methods:+ block in definitions/fedex.yaml.
8
+ module FEDEX
9
+ class << self
10
+ def day_after_thanksgiving(year)
11
+ Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 11, 4, 4) + 1
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,35 @@
1
+ require 'date'
2
+
3
+ module Holidays
4
+ module Definition
5
+ module CustomMethods
6
+ # fi custom holiday calculations, ported verbatim from the
7
+ # +methods:+ block in definitions/fi.yaml.
8
+ module FI
9
+ class << self
10
+ def fi_juhannusaatto(year)
11
+ date = Date.civil(year,6,19)
12
+ if date.wday > 5 #if 19.6 is saturday
13
+ date += 6
14
+ else
15
+ date += (5 - date.wday)
16
+ end
17
+ date
18
+ end
19
+
20
+ def fi_juhannuspaiva(year)
21
+ date = Date.civil(year,6,20)
22
+ date += (6 - date.wday)
23
+ date
24
+ end
25
+
26
+ def fi_pyhainpaiva(year)
27
+ date = Date.civil(year,10,31)
28
+ date += (6 - date.wday)
29
+ date
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,22 @@
1
+ require 'date'
2
+
3
+ module Holidays
4
+ module Definition
5
+ module CustomMethods
6
+ # ie custom holiday calculations, ported verbatim from the
7
+ # +methods:+ block in definitions/ie.yaml.
8
+ module IE
9
+ class << self
10
+ def ie_st_brigids_day(year)
11
+ date = Date.civil(year, 2, 1)
12
+ if date.wday == 5
13
+ date
14
+ else
15
+ date + ((1 - date.wday) % 7)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ require 'date'
2
+
3
+ module Holidays
4
+ module Definition
5
+ module CustomMethods
6
+ # is custom holiday calculations, ported verbatim from the
7
+ # +methods:+ block in definitions/is.yaml.
8
+ module IS
9
+ class << self
10
+ def is_sumardagurinn_fyrsti(year)
11
+ date = Date.civil(year,4,18)
12
+ if date.wday < 4
13
+ date += (4 - date.wday)
14
+ else
15
+ date += (11 - date.wday)
16
+ end
17
+ date
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,107 @@
1
+ require 'date'
2
+
3
+ module Holidays
4
+ module Definition
5
+ module CustomMethods
6
+ # jp custom holiday calculations, ported verbatim from the
7
+ # +methods:+ block in definitions/jp.yaml.
8
+ module JP
9
+ class << self
10
+ def jp_health_sports_day_substitute(year)
11
+ 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))
12
+ end
13
+
14
+ def jp_vernal_equinox_day(year)
15
+ day =
16
+ case year
17
+ when 1851..1899
18
+ 19.8277
19
+ when 1900..1979
20
+ 20.8357
21
+ when 1980..2099
22
+ 20.8431
23
+ when 2100..2150
24
+ 21.8510
25
+ else
26
+ raise IndexError.new("Out of range")
27
+ end
28
+ day += 0.242194 * (year - 1980) - ((year - 1980)/4).floor
29
+ day = day.floor
30
+ Date.civil(year, 3, day)
31
+ end
32
+
33
+ def jp_vernal_equinox_day_substitute(year)
34
+ date = Holidays::Factory::Definition.custom_methods_repository.find("jp_vernal_equinox_day(year)").call(year)
35
+ Holidays::Factory::Definition.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, date.month, date.mday)
36
+ end
37
+
38
+ def jp_marine_day_substitute(year)
39
+ 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))
40
+ end
41
+
42
+ def jp_national_culture_day(year)
43
+ day =
44
+ case year
45
+ when 1851..1899
46
+ 22.2588
47
+ when 1900..1979
48
+ 23.2588
49
+ when 1980..2099
50
+ 23.2488
51
+ when 2100..2150
52
+ 24.2488
53
+ else
54
+ raise IndexError.new("Out of range")
55
+ end
56
+ day += 0.242194 * (year - 1980) - ((year - 1980)/4).floor
57
+ day = day.floor
58
+ Date.civil(year, 9, day)
59
+ end
60
+
61
+ def jp_national_culture_day_substitute(year)
62
+ date = Holidays::Factory::Definition.custom_methods_repository.find("jp_national_culture_day(year)").call(year)
63
+ Holidays::Factory::Definition.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, date.month, date.mday)
64
+ end
65
+
66
+ def jp_citizens_holiday(year)
67
+ ncd = Holidays::Factory::Definition.custom_methods_repository.find("jp_national_culture_day(year)").call(year)
68
+ if ncd.wday == 3
69
+ ncd - 1
70
+ else
71
+ nil
72
+ end
73
+ end
74
+
75
+ def jp_mountain_holiday(year)
76
+ Date.civil(year, 8, 11)
77
+ end
78
+
79
+ def jp_mountain_holiday_substitute(year)
80
+ date = Holidays::Factory::Definition.custom_methods_repository.find("jp_mountain_holiday(year)").call(year)
81
+ Holidays::Factory::Definition.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, date.month, date.mday)
82
+ end
83
+
84
+ def jp_respect_for_aged_holiday_substitute(year)
85
+ 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))
86
+ end
87
+
88
+ def jp_substitute_holiday(year, month, day)
89
+ date = Date.civil(year, month, day)
90
+ date.wday == 0 ? (Holidays::Factory::Definition.custom_methods_repository.find("jp_next_weekday(date)").call(date+1)) : nil
91
+ end
92
+
93
+ def jp_next_weekday(date)
94
+ # This suuuucks. I have no idea how to make this not reach into our interal ruby API to do this.
95
+ # I'm punting, I'll come back to this.
96
+ is_holiday = Holidays::JP.holidays_by_month[date.month].any? do |holiday|
97
+ next false unless holiday[:mday] == date.day
98
+ next true unless holiday[:year_ranges]
99
+ Holidays::Finder::Rules::YearRange.call(date.year, holiday[:year_ranges])
100
+ end
101
+ date.wday == 0 || is_holiday ? (Holidays::Factory::Definition.custom_methods_repository.find("jp_next_weekday(date)").call(date+1)) : date
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,17 @@
1
+ module Holidays
2
+ module Definition
3
+ module CustomMethods
4
+ # kr custom holiday calculations, ported verbatim from the
5
+ # +methods:+ block in definitions/kr.yaml.
6
+ module KR
7
+ class << self
8
+ # Seollal eve is the day before Seollal (Korean New Year), which is
9
+ # the first day of the first lunar month.
10
+ def kr_seollal_eve(year, region)
11
+ Holidays::Factory::Definition.custom_methods_repository.find("lunar_to_solar(year, month, day, region)").call(year, 1, 1, region) - 1
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ require 'date'
2
+
3
+ module Holidays
4
+ module Definition
5
+ module CustomMethods
6
+ # lv custom holiday calculations, ported verbatim from the
7
+ # +methods:+ block in definitions/lv.yaml.
8
+ module LV
9
+ class << self
10
+ def lv_song_and_dance_festival_end_date(year)
11
+ case year
12
+ when 2018
13
+ # https://likumi.lv/ta/id/281541 (Ministru kabineta rīkojums Nr. 252 "Par XXVI Vispārējo latviešu dziesmu un XVI Deju svētku norises laiku")
14
+ Date.new(2018, 7, 8)
15
+ when 2023
16
+ # https://likumi.lv/ta/id/330067 (Ministru kabineta rīkojums Nr. 92 "Par XXVII Vispārējo latviešu dziesmu un XVII Deju svētku norises laiku")
17
+ Date.new(2023, 7, 9)
18
+ when 2028
19
+ # Event's period/next year is known, but precise dates aren't.
20
+ # Previously, dates were announced 2 years ahead, so on ~2026-05 this method would need to be revisited.
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,77 @@
1
+ require 'date'
2
+
3
+ module Holidays
4
+ module Definition
5
+ module CustomMethods
6
+ # nz custom holiday calculations, ported verbatim from the
7
+ # +methods:+ block in definitions/nz.yaml.
8
+ module NZ
9
+ class << self
10
+ def closest_monday(date)
11
+ if [1, 2, 3, 4].include?(date.wday)
12
+ date -= (date.wday - 1)
13
+ elsif 0 == date.wday
14
+ date += 1
15
+ else
16
+ date += 8 - date.wday
17
+ end
18
+ date
19
+ end
20
+
21
+ def previous_friday(date)
22
+ date - 3
23
+ end
24
+
25
+ def next_week(date)
26
+ date + 7
27
+ end
28
+
29
+ def nz_canterbury_anniversary(year)
30
+ date = Date.civil(year, 11, 1)
31
+ date += 1 until date.tuesday?
32
+ date += 1
33
+ date += 1 until date.friday?
34
+ date + 7
35
+ end
36
+
37
+ def matariki(year)
38
+ @matariki_dates ||= {
39
+ '2022' => Date.civil(2022, 6, 24),
40
+ '2023' => Date.civil(2023, 7, 14),
41
+ '2024' => Date.civil(2024, 6, 28),
42
+ '2025' => Date.civil(2025, 6, 20),
43
+ '2026' => Date.civil(2026, 7, 10),
44
+ '2027' => Date.civil(2027, 6, 25),
45
+ '2028' => Date.civil(2028, 7, 14),
46
+ '2029' => Date.civil(2029, 7, 6),
47
+ '2030' => Date.civil(2030, 6, 21),
48
+ '2031' => Date.civil(2031, 7, 11),
49
+ '2032' => Date.civil(2032, 7, 2),
50
+ '2033' => Date.civil(2033, 6, 24),
51
+ '2034' => Date.civil(2034, 7, 7),
52
+ '2035' => Date.civil(2035, 6, 29),
53
+ '2036' => Date.civil(2036, 7, 18),
54
+ '2037' => Date.civil(2037, 7, 10),
55
+ '2038' => Date.civil(2038, 6, 25),
56
+ '2039' => Date.civil(2039, 7, 15),
57
+ '2040' => Date.civil(2040, 7, 6),
58
+ '2041' => Date.civil(2041, 7, 19),
59
+ '2042' => Date.civil(2042, 7, 11),
60
+ '2043' => Date.civil(2043, 7, 3),
61
+ '2044' => Date.civil(2044, 6, 24),
62
+ '2045' => Date.civil(2045, 7, 7),
63
+ '2046' => Date.civil(2046, 6, 29),
64
+ '2047' => Date.civil(2047, 7, 19),
65
+ '2048' => Date.civil(2048, 7, 3),
66
+ '2049' => Date.civil(2049, 6, 25),
67
+ '2050' => Date.civil(2050, 7, 15),
68
+ '2051' => Date.civil(2051, 6, 30),
69
+ '2052' => Date.civil(2052, 6, 21),
70
+ }
71
+ @matariki_dates[year.to_s]
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,19 @@
1
+ require 'date'
2
+
3
+ module Holidays
4
+ module Definition
5
+ module CustomMethods
6
+ # ph custom holiday calculations, ported verbatim from the
7
+ # +methods:+ block in definitions/ph.yaml.
8
+ module PH
9
+ class << self
10
+ def ph_heroes_day(year)
11
+ date = Date.new(year, 8, -1)
12
+ date -= (date.wday - 1) % 7
13
+ date
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,103 @@
1
+ require 'holidays/definition/custom_methods/ar'
2
+ require 'holidays/definition/custom_methods/au'
3
+ require 'holidays/definition/custom_methods/ca'
4
+ require 'holidays/definition/custom_methods/ch'
5
+ require 'holidays/definition/custom_methods/cn'
6
+ require 'holidays/definition/custom_methods/cl'
7
+ require 'holidays/definition/custom_methods/co'
8
+ require 'holidays/definition/custom_methods/de'
9
+ require 'holidays/definition/custom_methods/fedex'
10
+ require 'holidays/definition/custom_methods/fi'
11
+ require 'holidays/definition/custom_methods/ie'
12
+ require 'holidays/definition/custom_methods/is'
13
+ require 'holidays/definition/custom_methods/jp'
14
+ require 'holidays/definition/custom_methods/kr'
15
+ require 'holidays/definition/custom_methods/lv'
16
+ require 'holidays/definition/custom_methods/nz'
17
+ require 'holidays/definition/custom_methods/ph'
18
+ require 'holidays/definition/custom_methods/se'
19
+ require 'holidays/definition/custom_methods/tr'
20
+ require 'holidays/definition/custom_methods/us'
21
+
22
+ module Holidays
23
+ module Definition
24
+ module CustomMethods
25
+ # Maps the full call-signature string used by YAML +function:+/+observed:+
26
+ # references to the native proc that implements it. Seeded into
27
+ # Factory::Definition.custom_methods_repository at boot by
28
+ # Holidays::Bootstrap.call, alongside the global built-in methods.
29
+ #
30
+ # Native replacement for the old per-region +methods:/ruby:+ YAML blocks.
31
+ # No eval, no public registration API.
32
+ #
33
+ # ca_victoria_day and day_after_thanksgiving each have byte-identical
34
+ # duplicates in other region YAML files; hosted once here and shared.
35
+ def self.all
36
+ {
37
+ "afl_grand_final(year)" => AU.method(:afl_grand_final).to_proc,
38
+ "ca_victoria_day(year)" => CA.method(:ca_victoria_day).to_proc,
39
+ "ch_be_zibelemaerit(year)" => CH.method(:ch_be_zibelemaerit).to_proc,
40
+ "ch_ge_jeune_genevois(year)" => CH.method(:ch_ge_jeune_genevois).to_proc,
41
+ "ch_gl_naefelser_fahrt(year)" => CH.method(:ch_gl_naefelser_fahrt).to_proc,
42
+ "ch_vd_lundi_du_jeune_federal(year)" => CH.method(:ch_vd_lundi_du_jeune_federal).to_proc,
43
+ "christmas_eve_holiday(date)" => US.method(:christmas_eve_holiday).to_proc,
44
+ "closest_monday(date)" => NZ.method(:closest_monday).to_proc,
45
+ "cn_qingming(year)" => CN.method(:cn_qingming).to_proc,
46
+ "columbus_day_cl(year)" => CL.method(:columbus_day_cl).to_proc,
47
+ "day_after_thanksgiving(year)" => FEDEX.method(:day_after_thanksgiving).to_proc,
48
+ "de_buss_und_bettag(year)" => DE.method(:de_buss_und_bettag).to_proc,
49
+ "election_day(year)" => US.method(:election_day).to_proc,
50
+ "even_year_election_day(year)" => US.method(:even_year_election_day).to_proc,
51
+ "fi_juhannusaatto(year)" => FI.method(:fi_juhannusaatto).to_proc,
52
+ "fi_juhannuspaiva(year)" => FI.method(:fi_juhannuspaiva).to_proc,
53
+ "fi_pyhainpaiva(year)" => FI.method(:fi_pyhainpaiva).to_proc,
54
+ "georgia_state_holiday(year, month)" => US.method(:georgia_state_holiday).to_proc,
55
+ "hobart_show_day(year)" => AU.method(:hobart_show_day).to_proc,
56
+ "ie_st_brigids_day(year)" => IE.method(:ie_st_brigids_day).to_proc,
57
+ "is_sumardagurinn_fyrsti(year)" => IS.method(:is_sumardagurinn_fyrsti).to_proc,
58
+ "jp_citizens_holiday(year)" => JP.method(:jp_citizens_holiday).to_proc,
59
+ "jp_health_sports_day_substitute(year)" => JP.method(:jp_health_sports_day_substitute).to_proc,
60
+ "jp_marine_day_substitute(year)" => JP.method(:jp_marine_day_substitute).to_proc,
61
+ "jp_mountain_holiday(year)" => JP.method(:jp_mountain_holiday).to_proc,
62
+ "jp_mountain_holiday_substitute(year)" => JP.method(:jp_mountain_holiday_substitute).to_proc,
63
+ "jp_national_culture_day(year)" => JP.method(:jp_national_culture_day).to_proc,
64
+ "jp_national_culture_day_substitute(year)" => JP.method(:jp_national_culture_day_substitute).to_proc,
65
+ "jp_next_weekday(date)" => JP.method(:jp_next_weekday).to_proc,
66
+ "jp_respect_for_aged_holiday_substitute(year)" => JP.method(:jp_respect_for_aged_holiday_substitute).to_proc,
67
+ "jp_substitute_holiday(year, month, day)" => JP.method(:jp_substitute_holiday).to_proc,
68
+ "jp_vernal_equinox_day(year)" => JP.method(:jp_vernal_equinox_day).to_proc,
69
+ "jp_vernal_equinox_day_substitute(year)" => JP.method(:jp_vernal_equinox_day_substitute).to_proc,
70
+ "juneteenth_national_independence_day(region, date)" => US.method(:juneteenth_national_independence_day).to_proc,
71
+ "kr_seollal_eve(year, region)" => KR.method(:kr_seollal_eve).to_proc,
72
+ "lee_jackson_day(year, month)" => US.method(:lee_jackson_day).to_proc,
73
+ "lv_song_and_dance_festival_end_date(year)" => LV.method(:lv_song_and_dance_festival_end_date).to_proc,
74
+ "march_pub_hol_sa(year)" => AU.method(:march_pub_hol_sa).to_proc,
75
+ "matariki(year)" => NZ.method(:matariki).to_proc,
76
+ "may_pub_hol_sa(year)" => AU.method(:may_pub_hol_sa).to_proc,
77
+ "next_week(date)" => NZ.method(:next_week).to_proc,
78
+ "nz_canterbury_anniversary(year)" => NZ.method(:nz_canterbury_anniversary).to_proc,
79
+ "other_churches_day_cl(year)" => CL.method(:other_churches_day_cl).to_proc,
80
+ "ph_heroes_day(year)" => PH.method(:ph_heroes_day).to_proc,
81
+ "previous_friday(date)" => NZ.method(:previous_friday).to_proc,
82
+ "qld_brisbane_ekka_holiday(year)" => AU.method(:qld_brisbane_ekka_holiday).to_proc,
83
+ "qld_kings_bday_october(year)" => AU.method(:qld_kings_bday_october).to_proc,
84
+ "qld_labour_day_may(year)" => AU.method(:qld_labour_day_may).to_proc,
85
+ "qld_labour_day_october(year)" => AU.method(:qld_labour_day_october).to_proc,
86
+ "qld_queens_bday_october(year)" => AU.method(:qld_queens_bday_october).to_proc,
87
+ "qld_queens_birthday_june(year)" => AU.method(:qld_queens_birthday_june).to_proc,
88
+ "ramadan_feast(year)" => TR.method(:ramadan_feast).to_proc,
89
+ "rosh_hashanah(year)" => US.method(:rosh_hashanah).to_proc,
90
+ "sacrifice_feast(year)" => TR.method(:sacrifice_feast).to_proc,
91
+ "se_alla_helgons_dag(year)" => SE.method(:se_alla_helgons_dag).to_proc,
92
+ "se_midsommardagen(year)" => SE.method(:se_midsommardagen).to_proc,
93
+ "st_peter_st_paul_cl(year)" => CL.method(:st_peter_st_paul_cl).to_proc,
94
+ "to_following_monday_if_not_monday(date)" => CO.method(:to_following_monday_if_not_monday).to_proc,
95
+ "to_nearest_monday(date)" => AR.method(:to_nearest_monday).to_proc,
96
+ "to_nearest_monday_after(date)" => AU.method(:to_nearest_monday_after).to_proc,
97
+ "us_inauguration_day(year)" => US.method(:us_inauguration_day).to_proc,
98
+ "yom_kippur(year)" => US.method(:yom_kippur).to_proc,
99
+ }
100
+ end
101
+ end
102
+ end
103
+ end