holidays 3.3.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +44 -0
  3. data/CONTRIBUTING.md +37 -0
  4. data/README.md +16 -25
  5. data/REFERENCES +4 -1
  6. data/Rakefile +38 -8
  7. data/benchmark.rb +8 -0
  8. data/definitions/README.md +187 -8
  9. data/definitions/ar.yaml +2 -1
  10. data/definitions/at.yaml +17 -13
  11. data/definitions/au.yaml +65 -60
  12. data/definitions/be_fr.yaml +14 -10
  13. data/definitions/be_nl.yaml +8 -4
  14. data/definitions/bg.yaml +12 -6
  15. data/definitions/br.yaml +6 -3
  16. data/definitions/ca.yaml +8 -6
  17. data/definitions/ch.yaml +21 -15
  18. data/definitions/cl.yaml +4 -2
  19. data/definitions/cr.yaml +5 -3
  20. data/definitions/cz.yaml +4 -2
  21. data/definitions/de.yaml +25 -14
  22. data/definitions/dk.yaml +26 -17
  23. data/definitions/ecb_target.yaml +4 -2
  24. data/definitions/el.yaml +23 -18
  25. data/definitions/es.yaml +31 -28
  26. data/definitions/federal_reserve.yaml +12 -12
  27. data/definitions/fedex.yaml +6 -6
  28. data/definitions/fi.yaml +26 -25
  29. data/definitions/fr.yaml +8 -4
  30. data/definitions/gb.yaml +9 -7
  31. data/definitions/hr.yaml +8 -6
  32. data/definitions/hu.yaml +8 -6
  33. data/definitions/ie.yaml +17 -16
  34. data/definitions/index.yaml +1 -1
  35. data/definitions/is.yaml +29 -19
  36. data/definitions/it.yaml +10 -9
  37. data/definitions/jp.yaml +92 -44
  38. data/definitions/li.yaml +25 -20
  39. data/definitions/lt.yaml +2 -1
  40. data/definitions/ma.yaml +7 -7
  41. data/definitions/mx.yaml +11 -11
  42. data/definitions/nerc.yaml +6 -6
  43. data/definitions/nl.yaml +22 -18
  44. data/definitions/no.yaml +19 -11
  45. data/definitions/north_america_informal.yaml +6 -6
  46. data/definitions/nyse.yaml +9 -8
  47. data/definitions/nz.yaml +33 -29
  48. data/definitions/ph.yaml +15 -8
  49. data/definitions/pl.yaml +27 -17
  50. data/definitions/pt.yaml +4 -2
  51. data/definitions/ro.yaml +21 -18
  52. data/definitions/se.yaml +24 -18
  53. data/definitions/sg.yaml +10 -9
  54. data/definitions/si.yaml +4 -2
  55. data/definitions/sk.yaml +4 -2
  56. data/definitions/united_nations.yaml +12 -12
  57. data/definitions/ups.yaml +6 -6
  58. data/definitions/us.yaml +12 -11
  59. data/definitions/ve.yaml +8 -4
  60. data/definitions/vi.yaml +6 -6
  61. data/definitions/za.yaml +26 -24
  62. data/holidays.gemspec +3 -1
  63. data/lib/generated_definitions/MANIFEST +1 -1
  64. data/lib/generated_definitions/ar.rb +8 -6
  65. data/lib/generated_definitions/at.rb +11 -9
  66. data/lib/generated_definitions/au.rb +75 -99
  67. data/lib/generated_definitions/be.rb +12 -10
  68. data/lib/generated_definitions/be_fr.rb +12 -10
  69. data/lib/generated_definitions/be_nl.rb +12 -10
  70. data/lib/generated_definitions/bg.rb +14 -13
  71. data/lib/generated_definitions/br.rb +11 -9
  72. data/lib/generated_definitions/ca.rb +20 -20
  73. data/lib/generated_definitions/ch.rb +41 -44
  74. data/lib/generated_definitions/cl.rb +9 -7
  75. data/lib/generated_definitions/cr.rb +9 -7
  76. data/lib/generated_definitions/cz.rb +9 -6
  77. data/lib/generated_definitions/de.rb +25 -25
  78. data/lib/generated_definitions/dk.rb +17 -15
  79. data/lib/generated_definitions/ecb_target.rb +9 -7
  80. data/lib/generated_definitions/el.rb +13 -11
  81. data/lib/generated_definitions/es.rb +35 -33
  82. data/lib/generated_definitions/europe.rb +234 -247
  83. data/lib/generated_definitions/federal_reserve.rb +11 -9
  84. data/lib/generated_definitions/fedex.rb +42 -0
  85. data/lib/generated_definitions/fi.rb +32 -36
  86. data/lib/generated_definitions/fr.rb +12 -10
  87. data/lib/generated_definitions/gb.rb +15 -13
  88. data/lib/generated_definitions/hr.rb +10 -8
  89. data/lib/generated_definitions/hu.rb +9 -7
  90. data/lib/generated_definitions/ie.rb +17 -17
  91. data/lib/generated_definitions/is.rb +26 -26
  92. data/lib/generated_definitions/it.rb +9 -7
  93. data/lib/generated_definitions/jp.rb +112 -89
  94. data/lib/generated_definitions/li.rb +14 -12
  95. data/lib/generated_definitions/lt.rb +9 -7
  96. data/lib/generated_definitions/ma.rb +7 -5
  97. data/lib/generated_definitions/mx.rb +7 -5
  98. data/lib/generated_definitions/nerc.rb +10 -8
  99. data/lib/generated_definitions/nl.rb +15 -13
  100. data/lib/generated_definitions/no.rb +16 -14
  101. data/lib/generated_definitions/north_america.rb +34 -37
  102. data/lib/generated_definitions/nyse.rb +10 -8
  103. data/lib/generated_definitions/nz.rb +40 -40
  104. data/lib/generated_definitions/ph.rb +17 -13
  105. data/lib/generated_definitions/pl.rb +25 -27
  106. data/lib/generated_definitions/pt.rb +10 -8
  107. data/lib/generated_definitions/ro.rb +11 -9
  108. data/lib/generated_definitions/scandinavia.rb +92 -102
  109. data/lib/generated_definitions/se.rb +25 -27
  110. data/lib/generated_definitions/sg.rb +11 -9
  111. data/lib/generated_definitions/si.rb +10 -8
  112. data/lib/generated_definitions/sk.rb +9 -7
  113. data/lib/generated_definitions/united_nations.rb +7 -5
  114. data/lib/generated_definitions/ups.rb +13 -12
  115. data/lib/generated_definitions/us.rb +20 -21
  116. data/lib/generated_definitions/ve.rb +11 -9
  117. data/lib/generated_definitions/vi.rb +7 -5
  118. data/lib/generated_definitions/za.rb +19 -17
  119. data/lib/holidays.rb +20 -83
  120. data/lib/holidays/date_calculator/weekend_modifier.rb +22 -5
  121. data/lib/holidays/definition/context/generator.rb +67 -29
  122. data/lib/holidays/definition/context/merger.rb +8 -8
  123. data/lib/holidays/definition/decorator/custom_method_proc.rb +28 -0
  124. data/lib/holidays/definition/decorator/custom_method_source.rb +30 -0
  125. data/lib/holidays/definition/entity/custom_method.rb +11 -0
  126. data/lib/holidays/definition/parser/custom_method.rb +69 -0
  127. data/lib/holidays/definition/repository/custom_methods.rb +27 -0
  128. data/lib/holidays/definition/repository/holidays_by_month.rb +1 -1
  129. data/lib/holidays/definition/repository/{proc_cache.rb → proc_result_cache.rb} +19 -4
  130. data/lib/holidays/definition/validator/custom_method.rb +31 -0
  131. data/lib/holidays/definition_factory.rb +42 -6
  132. data/lib/holidays/errors.rb +6 -0
  133. data/lib/holidays/load_all_definitions.rb +57 -0
  134. data/lib/holidays/option/context/parse_options.rb +26 -16
  135. data/lib/holidays/option_factory.rb +1 -0
  136. data/lib/holidays/use_case/context/between.rb +41 -14
  137. data/lib/holidays/use_case_factory.rb +2 -1
  138. data/lib/holidays/version.rb +1 -1
  139. data/test/data/test_single_custom_holiday_with_custom_procs.yaml +24 -0
  140. data/test/defs/test_defs_at.rb +1 -1
  141. data/test/defs/test_defs_au.rb +3 -2
  142. data/test/defs/test_defs_cr.rb +1 -0
  143. data/test/defs/test_defs_cz.rb +1 -0
  144. data/test/defs/test_defs_dk.rb +2 -2
  145. data/test/defs/test_defs_el.rb +7 -6
  146. data/test/defs/test_defs_europe.rb +40 -33
  147. data/test/defs/test_defs_fedex.rb +24 -0
  148. data/test/defs/test_defs_fi.rb +4 -3
  149. data/test/defs/test_defs_hr.rb +2 -2
  150. data/test/defs/test_defs_hu.rb +2 -2
  151. data/test/defs/test_defs_is.rb +2 -1
  152. data/test/defs/test_defs_it.rb +2 -1
  153. data/test/defs/test_defs_jp.rb +1 -1
  154. data/test/defs/test_defs_li.rb +1 -1
  155. data/test/defs/test_defs_ma.rb +2 -1
  156. data/test/defs/test_defs_mx.rb +4 -3
  157. data/test/defs/test_defs_nl.rb +7 -6
  158. data/test/defs/test_defs_no.rb +1 -0
  159. data/test/defs/test_defs_north_america.rb +4 -3
  160. data/test/defs/test_defs_nyse.rb +2 -1
  161. data/test/defs/test_defs_pl.rb +1 -0
  162. data/test/defs/test_defs_ro.rb +11 -11
  163. data/test/defs/test_defs_scandinavia.rb +12 -8
  164. data/test/defs/test_defs_se.rb +3 -2
  165. data/test/defs/test_defs_sg.rb +2 -1
  166. data/test/defs/test_defs_vi.rb +1 -1
  167. data/test/defs/test_defs_za.rb +3 -2
  168. data/test/holidays/date_calculator/test_weekend_modifier.rb +11 -0
  169. data/test/holidays/definition/context/test_generator.rb +64 -5
  170. data/test/holidays/definition/context/test_merger.rb +5 -2
  171. data/test/holidays/definition/decorator/test_custom_method_proc.rb +113 -0
  172. data/test/holidays/definition/decorator/test_custom_method_source.rb +96 -0
  173. data/test/holidays/definition/parser/test_custom_method.rb +79 -0
  174. data/test/holidays/definition/repository/test_custom_methods.rb +43 -0
  175. data/test/holidays/definition/repository/test_holidays_by_month.rb +0 -32
  176. data/test/holidays/definition/repository/test_proc_result_cache.rb +84 -0
  177. data/test/holidays/definition/validator/test_custom_method.rb +89 -0
  178. data/test/holidays/option/context/test_parse_options.rb +5 -0
  179. data/test/holidays/test_definition_factory.rb +17 -2
  180. data/test/holidays/use_case/context/test_between.rb +2 -0
  181. data/test/test_all_regions.rb +7 -49
  182. data/test/test_custom_holidays.rb +8 -2
  183. data/test/test_helper.rb +9 -2
  184. data/test/test_holidays.rb +9 -29
  185. metadata +46 -11
  186. data/lib/generated_definitions/fed_ex.rb +0 -41
  187. data/test/holidays/definition/repository/test_proc_cache.rb +0 -29
  188. data/test/test_parse_definitions.rb +0 -30
@@ -10,7 +10,7 @@ module Holidays
10
10
  # require 'holidays'
11
11
  # require 'generated_definitions/pt'
12
12
  #
13
- # All the definitions are available at https://github.com/alexdunae/holidays
13
+ # All the definitions are available at https://github.com/holidays/holidays
14
14
  module PT # :nodoc:
15
15
  def self.defined_regions
16
16
  [:pt]
@@ -18,9 +18,9 @@ module Holidays
18
18
 
19
19
  def self.holidays_by_month
20
20
  {
21
- 0 => [{:function => lambda { |year| Holidays.easter(year)-47 }, :function_id => "easter(year)-47", :type => :informal, :name => "Carnaval", :regions => [:pt]},
22
- {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Sexta-feira Santa", :regions => [:pt]},
23
- {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Páscoa", :regions => [:pt]}],
21
+ 0 => [{:function => "easter(year)", :function_arguments => [:year], :function_modifier => -47, :type => :informal, :name => "Carnaval", :regions => [:pt]},
22
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -2, :name => "Sexta-feira Santa", :regions => [:pt]},
23
+ {:function => "easter(year)", :function_arguments => [:year], :name => "Páscoa", :regions => [:pt]}],
24
24
  1 => [{:mday => 1, :name => "Ano Novo", :regions => [:pt]}],
25
25
  4 => [{:mday => 25, :name => "Dia da Liberdade", :regions => [:pt]}],
26
26
  5 => [{:mday => 1, :name => "Dia do Trabalhador", :regions => [:pt]}],
@@ -30,9 +30,11 @@ module Holidays
30
30
  {:mday => 25, :name => "Natal", :regions => [:pt]}]
31
31
  }
32
32
  end
33
- end
34
-
35
33
 
34
+ def self.custom_methods
35
+ {
36
+
37
+ }
38
+ end
39
+ end
36
40
  end
37
-
38
- Holidays.merge_defs(Holidays::PT.defined_regions, Holidays::PT.holidays_by_month)
@@ -10,7 +10,7 @@ module Holidays
10
10
  # require 'holidays'
11
11
  # require 'generated_definitions/ro'
12
12
  #
13
- # All the definitions are available at https://github.com/alexdunae/holidays
13
+ # All the definitions are available at https://github.com/holidays/holidays
14
14
  module RO # :nodoc:
15
15
  def self.defined_regions
16
16
  [:ro]
@@ -18,10 +18,10 @@ module Holidays
18
18
 
19
19
  def self.holidays_by_month
20
20
  {
21
- 0 => [{:function => lambda { |year| Holidays.orthodox_easter(year) }, :function_id => "orthodox_easter(year)", :name => "Paștele", :regions => [:ro]},
22
- {:function => lambda { |year| Holidays.orthodox_easter(year)+1 }, :function_id => "orthodox_easter(year)+1", :name => "Paștele", :regions => [:ro]},
23
- {:function => lambda { |year| Holidays.orthodox_easter(year) + 49 }, :function_id => "orthodox_easter(year) + 49", :name => "Rusaliile", :regions => [:ro]},
24
- {:function => lambda { |year| Holidays.orthodox_easter(year) + 50 }, :function_id => "orthodox_easter(year) + 50", :name => "Rusaliile", :regions => [:ro]}],
21
+ 0 => [{:function => "orthodox_easter(year)", :function_arguments => [:year], :name => "Paștele - duminică", :regions => [:ro]},
22
+ {:function => "orthodox_easter(year)", :function_arguments => [:year], :function_modifier => 1, :name => "Paștele - luni", :regions => [:ro]},
23
+ {:function => "orthodox_easter(year)", :function_arguments => [:year], :function_modifier => 49, :name => "Rusaliile - 50", :regions => [:ro]},
24
+ {:function => "orthodox_easter(year)", :function_arguments => [:year], :function_modifier => 50, :name => "Rusaliile - 51", :regions => [:ro]}],
25
25
  1 => [{:mday => 1, :name => "Anul nou", :regions => [:ro]},
26
26
  {:mday => 2, :name => "Anul nou", :regions => [:ro]}],
27
27
  5 => [{:mday => 1, :name => "Ziua muncii", :regions => [:ro]}],
@@ -32,9 +32,11 @@ module Holidays
32
32
  {:mday => 26, :name => "Sărbătoarea Nașterii Domnului", :regions => [:ro]}]
33
33
  }
34
34
  end
35
- end
36
-
37
35
 
36
+ def self.custom_methods
37
+ {
38
+
39
+ }
40
+ end
41
+ end
38
42
  end
39
-
40
- Holidays.merge_defs(Holidays::RO.defined_regions, Holidays::RO.holidays_by_month)
@@ -10,7 +10,7 @@ module Holidays
10
10
  # require 'holidays'
11
11
  # require 'generated_definitions/scandinavia'
12
12
  #
13
- # All the definitions are available at https://github.com/alexdunae/holidays
13
+ # All the definitions are available at https://github.com/holidays/holidays
14
14
  module SCANDINAVIA # :nodoc:
15
15
  def self.defined_regions
16
16
  [:dk, :is, :no, :se, :fi]
@@ -18,49 +18,49 @@ module Holidays
18
18
 
19
19
  def self.holidays_by_month
20
20
  {
21
- 0 => [{:function => lambda { |year| Holidays.easter(year)-49 }, :function_id => "easter(year)-49", :type => :informal, :name => "Fastelavn", :regions => [:dk]},
22
- {:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :type => :informal, :name => "Palmesøndag", :regions => [:dk]},
23
- {:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skærtorsdag", :regions => [:dk]},
24
- {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Langfredag", :regions => [:dk]},
25
- {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskedag", :regions => [:dk]},
26
- {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "2. påskedag", :regions => [:dk]},
27
- {:function => lambda { |year| Holidays.easter(year)+26 }, :function_id => "easter(year)+26", :name => "Store Bededag", :regions => [:dk]},
28
- {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi Himmelfartsdag", :regions => [:dk]},
29
- {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinsedag", :regions => [:dk]},
30
- {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "2. Pinsedag", :regions => [:dk]},
31
- {:function => lambda { |year| Holidays.easter(year)-48 }, :function_id => "easter(year)-48", :name => "Bolludagur", :regions => [:is]},
32
- {:function => lambda { |year| Holidays.easter(year)-47 }, :function_id => "easter(year)-47", :name => "Sprengidagur", :regions => [:is]},
33
- {:function => lambda { |year| Holidays.easter(year)-46 }, :function_id => "easter(year)-46", :name => "Öskudagur", :regions => [:is]},
34
- {:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :name => "Pálmasunnudagur", :regions => [:is]},
35
- {:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skírdagur", :regions => [:is]},
36
- {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Föstudaginn langi", :regions => [:is]},
37
- {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Páskadagur", :regions => [:is]},
38
- {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Annar í páskum", :regions => [:is]},
39
- {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Uppstigningardagur", :regions => [:is]},
40
- {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Hvítasunnudagur", :regions => [:is]},
41
- {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Annar í hvítasunnu", :regions => [:is]},
42
- {:function => lambda { |year| Holidays.easter(year)-49 }, :function_id => "easter(year)-49", :type => :informal, :name => "Fastelavn", :regions => [:no]},
43
- {:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :name => "Palmesøndag", :regions => [:no]},
44
- {:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skjærtorsdag", :regions => [:no]},
45
- {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Langfredag", :regions => [:no]},
46
- {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "1. påskedag", :regions => [:no]},
47
- {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "2. påskedag", :regions => [:no]},
48
- {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi Himmelfartsdag", :regions => [:no]},
49
- {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "1. pinsedag", :regions => [:no]},
50
- {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "2. pinsedag", :regions => [:no]},
51
- {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Långfredagen", :regions => [:se]},
52
- {:function => lambda { |year| Holidays.easter(year)-1 }, :function_id => "easter(year)-1", :type => :informal, :name => "Påskafton", :regions => [:se]},
53
- {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskdagen", :regions => [:se]},
54
- {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Annandag påsk", :regions => [:se]},
55
- {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi himmelsfärdsdag", :regions => [:se]},
56
- {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pingstdagen", :regions => [:se]},
57
- {:function => lambda { |year| Holidays.se_alla_helgons_dag(year) }, :function_id => "se_alla_helgons_dag(year)", :name => "Alla helgons dag", :regions => [:se]},
58
- {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Pitkäperjantai", :regions => [:fi]},
59
- {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pääsiäispäivä", :regions => [:fi]},
60
- {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "2. Pääsiäispäivä", :regions => [:fi]},
61
- {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Helatorstai", :regions => [:fi]},
62
- {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Helluntaipäivä", :regions => [:fi]},
63
- {:function => lambda { |year| Holidays.fi_pyhainpaiva(year) }, :function_id => "fi_pyhainpaiva(year)", :name => "Pyhäinpäivä", :regions => [:fi]}],
21
+ 0 => [{:function => "easter(year)", :function_arguments => [:year], :function_modifier => -49, :type => :informal, :name => "Fastelavn", :regions => [:dk]},
22
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -7, :type => :informal, :name => "Palmesøndag", :regions => [:dk]},
23
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -3, :name => "Skærtorsdag", :regions => [:dk]},
24
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -2, :name => "Langfredag", :regions => [:dk]},
25
+ {:function => "easter(year)", :function_arguments => [:year], :name => "Påskedag", :regions => [:dk]},
26
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 1, :name => "2. påskedag", :regions => [:dk]},
27
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 26, :name => "Store Bededag", :regions => [:dk]},
28
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 39, :name => "Kristi Himmelfartsdag", :regions => [:dk]},
29
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 49, :name => "Pinsedag", :regions => [:dk]},
30
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 50, :name => "2. Pinsedag", :regions => [:dk]},
31
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -48, :name => "Bolludagur", :regions => [:is]},
32
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -47, :name => "Sprengidagur", :regions => [:is]},
33
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -46, :name => "Öskudagur", :regions => [:is]},
34
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -7, :name => "Pálmasunnudagur", :regions => [:is]},
35
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -3, :name => "Skírdagur", :regions => [:is]},
36
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -2, :name => "Föstudaginn langi", :regions => [:is]},
37
+ {:function => "easter(year)", :function_arguments => [:year], :name => "Páskadagur", :regions => [:is]},
38
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 1, :name => "Annar í páskum", :regions => [:is]},
39
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 39, :name => "Uppstigningardagur", :regions => [:is]},
40
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 49, :name => "Hvítasunnudagur", :regions => [:is]},
41
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 50, :name => "Annar í hvítasunnu", :regions => [:is]},
42
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -49, :type => :informal, :name => "Fastelavn", :regions => [:no]},
43
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -7, :name => "Palmesøndag", :regions => [:no]},
44
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -3, :name => "Skjærtorsdag", :regions => [:no]},
45
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -2, :name => "Langfredag", :regions => [:no]},
46
+ {:function => "easter(year)", :function_arguments => [:year], :name => "1. påskedag", :regions => [:no]},
47
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 1, :name => "2. påskedag", :regions => [:no]},
48
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 39, :name => "Kristi Himmelfartsdag", :regions => [:no]},
49
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 49, :name => "1. pinsedag", :regions => [:no]},
50
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 50, :name => "2. pinsedag", :regions => [:no]},
51
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -2, :name => "Långfredagen", :regions => [:se]},
52
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -1, :type => :informal, :name => "Påskafton", :regions => [:se]},
53
+ {:function => "easter(year)", :function_arguments => [:year], :name => "Påskdagen", :regions => [:se]},
54
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 1, :name => "Annandag påsk", :regions => [:se]},
55
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 39, :name => "Kristi himmelsfärdsdag", :regions => [:se]},
56
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 49, :name => "Pingstdagen", :regions => [:se]},
57
+ {:function => "se_alla_helgons_dag(year)", :function_arguments => [:year], :name => "Alla helgons dag", :regions => [:se]},
58
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -2, :name => "Pitkäperjantai", :regions => [:fi]},
59
+ {:function => "easter(year)", :function_arguments => [:year], :name => "Pääsiäispäivä", :regions => [:fi]},
60
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 1, :name => "2. Pääsiäispäivä", :regions => [:fi]},
61
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 39, :name => "Helatorstai", :regions => [:fi]},
62
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 49, :name => "Helluntaipäivä", :regions => [:fi]},
63
+ {:function => "fi_pyhainpaiva(year)", :function_arguments => [:year], :name => "Pyhäinpäivä", :regions => [:fi]}],
64
64
  1 => [{:mday => 1, :name => "Nytårsdag", :regions => [:dk]},
65
65
  {:mday => 1, :name => "Nýársdagur", :regions => [:is]},
66
66
  {:mday => 6, :name => "Þrettándinn", :regions => [:is]},
@@ -73,7 +73,7 @@ module Holidays
73
73
  4 => [{:mday => 1, :type => :informal, :name => "1. april", :regions => [:dk]},
74
74
  {:mday => 9, :type => :informal, :name => "Danmarks besættelse", :regions => [:dk]},
75
75
  {:mday => 16, :type => :informal, :name => "Dronningens fødselsdag", :regions => [:dk]},
76
- {:function => lambda { |year| Holidays.is_sumardagurinn_fyrsti(year) }, :function_id => "is_sumardagurinn_fyrsti(year)", :name => "Sumardagurinn fyrsti", :regions => [:is]}],
76
+ {:function => "is_sumardagurinn_fyrsti(year)", :function_arguments => [:year], :name => "Sumardagurinn fyrsti", :regions => [:is]}],
77
77
  5 => [{:mday => 1, :type => :informal, :name => "Arbejdernes kampdag", :regions => [:dk]},
78
78
  {:mday => 5, :type => :informal, :name => "Danmarks befrielse", :regions => [:dk]},
79
79
  {:mday => 1, :name => "Verkalýðsdagurinn", :regions => [:is]},
@@ -88,10 +88,10 @@ module Holidays
88
88
  {:mday => 3, :type => :informal, :name => "Sjómannadagurinn", :regions => [:is]},
89
89
  {:mday => 17, :name => "Lýðveldisdagurinn", :regions => [:is]},
90
90
  {:mday => 6, :name => "Nationaldagen", :regions => [:se]},
91
- {:function => lambda { |year| Holidays.se_midsommardagen(year) }, :function_id => "se_midsommardagen(year)", :name => "Midsommardagen", :regions => [:se]},
92
- {:function => lambda { |year| Holidays.se_midsommardagen(year)-1 }, :function_id => "se_midsommardagen(year)-1", :type => :informal, :name => "Midsommarafton", :regions => [:se]},
93
- {:function => lambda { |year| Holidays.fi_juhannusaatto(year) }, :function_id => "fi_juhannusaatto(year)", :name => "Juhannusaatto", :regions => [:fi]},
94
- {:function => lambda { |year| Holidays.fi_juhannuspaiva(year) }, :function_id => "fi_juhannuspaiva(year)", :name => "Juhannuspäivä", :regions => [:fi]}],
91
+ {:function => "se_midsommardagen(year)", :function_arguments => [:year], :name => "Midsommardagen", :regions => [:se]},
92
+ {:function => "se_midsommardagen(year)", :function_arguments => [:year], :function_modifier => -1, :type => :informal, :name => "Midsommarafton", :regions => [:se]},
93
+ {:function => "fi_juhannusaatto(year)", :function_arguments => [:year], :name => "Juhannusaatto", :regions => [:fi]},
94
+ {:function => "fi_juhannuspaiva(year)", :function_arguments => [:year], :name => "Juhannuspäivä", :regions => [:fi]}],
95
95
  11 => [{:mday => 10, :type => :informal, :name => "Mortensaften", :regions => [:dk]},
96
96
  {:mday => 16, :name => "Dagur íslenskrar tungu", :regions => [:is]}],
97
97
  12 => [{:mday => 13, :type => :informal, :name => "Sankt Lucia", :regions => [:dk]},
@@ -118,65 +118,55 @@ module Holidays
118
118
  8 => [{:wday => 1, :week => 1, :name => "Frídagur verslunarmanna", :regions => [:is]}]
119
119
  }
120
120
  end
121
- end
122
121
 
123
- # Iceland: first day of summer (Thursday after 18 April)
124
- def self.is_sumardagurinn_fyrsti(year)
125
- date = Date.civil(year,4,18)
126
- if date.wday < 4
127
- date += (4 - date.wday)
128
- else date
129
- date += (11 - date.wday)
130
- end
131
- date
122
+ def self.custom_methods
123
+ {
124
+ "is_sumardagurinn_fyrsti(year)" => Proc.new { |year|
125
+ date = Date.civil(year,4,18)
126
+ if date.wday < 4
127
+ date += (4 - date.wday)
128
+ else date
129
+ date += (11 - date.wday)
132
130
  end
133
-
134
-
135
- # Sweden: Mid-summer (Saturday between June 20–26)
136
- def self.se_midsommardagen(year)
137
- date = Date.civil(year,6,20)
138
- date += (6 - date.wday)
139
- date
131
+ date
132
+ },
133
+
134
+ "se_midsommardagen(year)" => Proc.new { |year|
135
+ date = Date.civil(year,6,20)
136
+ date += (6 - date.wday)
137
+ date
138
+ },
139
+
140
+ "se_alla_helgons_dag(year)" => Proc.new { |year|
141
+ date = Date.civil(year,10,31)
142
+ date += (6 - date.wday)
143
+ date
144
+ },
145
+
146
+ "fi_juhannusaatto(year)" => Proc.new { |year|
147
+ date = Date.civil(year,6,19)
148
+ if date.wday > 5 #if 19.6 is saturday
149
+ date += 6
150
+ else
151
+ date += (5 - date.wday)
140
152
  end
153
+ date
154
+ },
141
155
 
156
+ "fi_juhannuspaiva(year)" => Proc.new { |year|
157
+ date = Date.civil(year,6,20)
158
+ date += (6 - date.wday)
159
+ date
160
+ },
142
161
 
143
- # Sweden: All Saint's Day (Saturday between Oct 31 and Nov 6)
144
- def self.se_alla_helgons_dag(year)
145
- date = Date.civil(year,10,31)
146
- date += (6 - date.wday)
147
- date
148
- end
162
+ "fi_pyhainpaiva(year)" => Proc.new { |year|
163
+ date = Date.civil(year,10,31)
164
+ date += (6 - date.wday)
165
+ date
166
+ },
149
167
 
150
168
 
151
- # Finland: Mid-summer eve (Friday between June 19–25)
152
- def self.fi_juhannusaatto(year)
153
- date = Date.civil(year,6,19)
154
- if date.wday > 5 #if 19.6 is saturday
155
- date += 6
156
- else
157
- date += (5 - date.wday)
169
+ }
170
+ end
158
171
  end
159
- date
160
172
  end
161
-
162
-
163
- # Finland: Mid-summer (Saturday between June 20–26)
164
- def self.fi_juhannuspaiva(year)
165
- date = Date.civil(year,6,20)
166
- date += (6 - date.wday)
167
- date
168
- end
169
-
170
-
171
- # Finland: All Saint's Day (Saturday between Oct 31 and Nov 6)
172
- def self.fi_pyhainpaiva(year)
173
- date = Date.civil(year,10,31)
174
- date += (6 - date.wday)
175
- date
176
- end
177
-
178
-
179
-
180
- end
181
-
182
- Holidays.merge_defs(Holidays::SCANDINAVIA.defined_regions, Holidays::SCANDINAVIA.holidays_by_month)
@@ -10,7 +10,7 @@ module Holidays
10
10
  # require 'holidays'
11
11
  # require 'generated_definitions/se'
12
12
  #
13
- # All the definitions are available at https://github.com/alexdunae/holidays
13
+ # All the definitions are available at https://github.com/holidays/holidays
14
14
  module SE # :nodoc:
15
15
  def self.defined_regions
16
16
  [:se]
@@ -18,44 +18,42 @@ module Holidays
18
18
 
19
19
  def self.holidays_by_month
20
20
  {
21
- 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Långfredagen", :regions => [:se]},
22
- {:function => lambda { |year| Holidays.easter(year)-1 }, :function_id => "easter(year)-1", :type => :informal, :name => "Påskafton", :regions => [:se]},
23
- {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskdagen", :regions => [:se]},
24
- {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Annandag påsk", :regions => [:se]},
25
- {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi himmelsfärdsdag", :regions => [:se]},
26
- {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pingstdagen", :regions => [:se]},
27
- {:function => lambda { |year| Holidays.se_alla_helgons_dag(year) }, :function_id => "se_alla_helgons_dag(year)", :name => "Alla helgons dag", :regions => [:se]}],
21
+ 0 => [{:function => "easter(year)", :function_arguments => [:year], :function_modifier => -2, :name => "Långfredagen", :regions => [:se]},
22
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => -1, :type => :informal, :name => "Påskafton", :regions => [:se]},
23
+ {:function => "easter(year)", :function_arguments => [:year], :name => "Påskdagen", :regions => [:se]},
24
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 1, :name => "Annandag påsk", :regions => [:se]},
25
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 39, :name => "Kristi himmelsfärdsdag", :regions => [:se]},
26
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 49, :name => "Pingstdagen", :regions => [:se]},
27
+ {:function => "se_alla_helgons_dag(year)", :function_arguments => [:year], :name => "Alla helgons dag", :regions => [:se]}],
28
28
  1 => [{:mday => 1, :name => "Nyårsdagen", :regions => [:se]},
29
29
  {:mday => 6, :name => "Trettondedag jul", :regions => [:se]}],
30
30
  5 => [{:mday => 1, :name => "Första maj", :regions => [:se]}],
31
31
  6 => [{:mday => 6, :name => "Nationaldagen", :regions => [:se]},
32
- {:function => lambda { |year| Holidays.se_midsommardagen(year) }, :function_id => "se_midsommardagen(year)", :name => "Midsommardagen", :regions => [:se]},
33
- {:function => lambda { |year| Holidays.se_midsommardagen(year)-1 }, :function_id => "se_midsommardagen(year)-1", :type => :informal, :name => "Midsommarafton", :regions => [:se]}],
32
+ {:function => "se_midsommardagen(year)", :function_arguments => [:year], :name => "Midsommardagen", :regions => [:se]},
33
+ {:function => "se_midsommardagen(year)", :function_arguments => [:year], :function_modifier => -1, :type => :informal, :name => "Midsommarafton", :regions => [:se]}],
34
34
  12 => [{:mday => 24, :type => :informal, :name => "Julafton", :regions => [:se]},
35
35
  {:mday => 25, :name => "Juldagen", :regions => [:se]},
36
36
  {:mday => 26, :name => "Annandag jul", :regions => [:se]},
37
37
  {:mday => 31, :type => :informal, :name => "Nyårsafton", :regions => [:se]}]
38
38
  }
39
39
  end
40
- end
41
-
42
- # Sweden: Mid-summer (Saturday between June 20–26)
43
- def self.se_midsommardagen(year)
44
- date = Date.civil(year,6,20)
45
- date += (6 - date.wday)
46
- date
47
- end
48
40
 
41
+ def self.custom_methods
42
+ {
43
+ "se_midsommardagen(year)" => Proc.new { |year|
44
+ date = Date.civil(year,6,20)
45
+ date += (6 - date.wday)
46
+ date
47
+ },
49
48
 
50
- # Sweden: All Saint's Day (Saturday between Oct 31 and Nov 6)
51
- def self.se_alla_helgons_dag(year)
52
- date = Date.civil(year,10,31)
53
- date += (6 - date.wday)
54
- date
55
- end
56
-
49
+ "se_alla_helgons_dag(year)" => Proc.new { |year|
50
+ date = Date.civil(year,10,31)
51
+ date += (6 - date.wday)
52
+ date
53
+ },
57
54
 
58
55
 
56
+ }
57
+ end
58
+ end
59
59
  end
60
-
61
- Holidays.merge_defs(Holidays::SE.defined_regions, Holidays::SE.holidays_by_month)
@@ -10,7 +10,7 @@ module Holidays
10
10
  # require 'holidays'
11
11
  # require 'generated_definitions/sg'
12
12
  #
13
- # All the definitions are available at https://github.com/alexdunae/holidays
13
+ # All the definitions are available at https://github.com/holidays/holidays
14
14
  module SG # :nodoc:
15
15
  def self.defined_regions
16
16
  [:sg]
@@ -18,18 +18,20 @@ module Holidays
18
18
 
19
19
  def self.holidays_by_month
20
20
  {
21
- 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:sg]}],
22
- 1 => [{:mday => 1, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "New Year's Day", :regions => [:sg]}],
21
+ 0 => [{:function => "easter(year)", :function_arguments => [:year], :function_modifier => -2, :name => "Good Friday", :regions => [:sg]}],
22
+ 1 => [{:mday => 1, :observed => "to_weekday_if_weekend(date)", :observed_arguments => [:date], :name => "New Year's Day", :regions => [:sg]}],
23
23
  2 => [{:mday => 14, :type => :informal, :name => "Valentine's Day", :regions => [:sg]},
24
24
  {:mday => 15, :type => :informal, :name => "Total Defence Day", :regions => [:sg]}],
25
25
  5 => [{:mday => 1, :name => "Labour Day", :regions => [:sg]}],
26
- 8 => [{:mday => 9, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "National Day", :regions => [:sg]}],
27
- 12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:sg]}]
26
+ 8 => [{:mday => 9, :observed => "to_weekday_if_weekend(date)", :observed_arguments => [:date], :name => "National Day", :regions => [:sg]}],
27
+ 12 => [{:mday => 25, :observed => "to_weekday_if_weekend(date)", :observed_arguments => [:date], :name => "Christmas Day", :regions => [:sg]}]
28
28
  }
29
29
  end
30
- end
31
-
32
30
 
31
+ def self.custom_methods
32
+ {
33
+
34
+ }
35
+ end
36
+ end
33
37
  end
34
-
35
- Holidays.merge_defs(Holidays::SG.defined_regions, Holidays::SG.holidays_by_month)
@@ -10,7 +10,7 @@ module Holidays
10
10
  # require 'holidays'
11
11
  # require 'generated_definitions/si'
12
12
  #
13
- # All the definitions are available at https://github.com/alexdunae/holidays
13
+ # All the definitions are available at https://github.com/holidays/holidays
14
14
  module SI # :nodoc:
15
15
  def self.defined_regions
16
16
  [:si]
@@ -18,9 +18,9 @@ module Holidays
18
18
 
19
19
  def self.holidays_by_month
20
20
  {
21
- 0 => [{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "velikonočna nedelja", :regions => [:si]},
22
- {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "velikonočni ponedeljek", :regions => [:si]},
23
- {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "binkošti", :regions => [:si]}],
21
+ 0 => [{:function => "easter(year)", :function_arguments => [:year], :name => "velikonočna nedelja", :regions => [:si]},
22
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 1, :name => "velikonočni ponedeljek", :regions => [:si]},
23
+ {:function => "easter(year)", :function_arguments => [:year], :function_modifier => 49, :name => "binkošti", :regions => [:si]}],
24
24
  1 => [{:mday => 1, :name => "novo leto", :regions => [:si]}],
25
25
  2 => [{:mday => 8, :name => "Prešernov dan, slovenski kulturni praznik", :regions => [:si]}],
26
26
  4 => [{:mday => 27, :name => "dan upora proti okupatorju", :regions => [:si]}],
@@ -34,9 +34,11 @@ module Holidays
34
34
  {:mday => 26, :name => "dan samostojnosti in enotnosti", :regions => [:si]}]
35
35
  }
36
36
  end
37
- end
38
-
39
37
 
38
+ def self.custom_methods
39
+ {
40
+
41
+ }
42
+ end
43
+ end
40
44
  end
41
-
42
- Holidays.merge_defs(Holidays::SI.defined_regions, Holidays::SI.holidays_by_month)