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
@@ -9,7 +9,8 @@ months:
9
9
  0:
10
10
  - name: Good Friday
11
11
  regions: [nyse]
12
- function: easter(year)-2
12
+ function: easter(year)
13
+ function_modifier: -2
13
14
  1:
14
15
  - name: New Year's Day
15
16
  regions: [nyse]
@@ -28,12 +29,12 @@ months:
28
29
  week: -1
29
30
  regions: [nyse]
30
31
  wday: 1
31
- 7:
32
+ 7:
32
33
  - name: Independence Day
33
34
  regions: [nyse]
34
35
  mday: 4
35
- observed: to_weekday_if_weekend
36
- 9:
36
+ observed: to_weekday_if_weekend(date)
37
+ 9:
37
38
  - name: Labor Day
38
39
  week: 1
39
40
  regions: [nyse]
@@ -43,14 +44,14 @@ months:
43
44
  week: 4
44
45
  regions: [nyse]
45
46
  wday: 4
46
- 12:
47
+ 12:
47
48
  - name: Christmas Day
48
49
  regions: [nyse]
49
50
  mday: 25
50
- observed: to_weekday_if_weekend
51
+ observed: to_weekday_if_weekend(date)
51
52
  methods:
52
53
  tests: |
53
- {Date.civil(2008,1,1) => 'New Year\'s Day',
54
+ {Date.civil(2008,1,1) => 'New Year\'s Day',
54
55
  Date.civil(2008,1,21) => 'Martin Luther King, Jr. Day',
55
56
  Date.civil(2008,2,18) => 'Presidents\' Day',
56
57
  Date.civil(2008,3,21) => 'Good Friday',
@@ -60,4 +61,4 @@ tests: |
60
61
  Date.civil(2008,11,27) => 'Thanksgiving',
61
62
  Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name|
62
63
  assert_equal name, (Holidays.on(date, :nyse)[0] || {})[:name]
63
- end
64
+ end
@@ -7,58 +7,64 @@ months:
7
7
  0:
8
8
  - name: Good Friday
9
9
  regions: [nz]
10
- function: easter(year)-2
10
+ function: easter(year)
11
+ function_modifier: -2
12
+ - name: Easter Saturday
13
+ regions: [nz]
14
+ function: easter(year)
15
+ function_modifier: -1
11
16
  - name: Easter Monday
12
17
  regions: [nz]
13
- function: easter(year)+1
18
+ function: easter(year)
19
+ function_modifier: 1
14
20
  1:
15
21
  - name: New Year's Day
16
22
  regions: [nz]
17
23
  mday: 1
18
- observed: to_monday_if_weekend
24
+ observed: to_monday_if_weekend(date)
19
25
  - name: Day after New Year's Day
20
26
  regions: [nz]
21
27
  mday: 2
22
- observed: to_weekday_if_boxing_weekend
28
+ observed: to_weekday_if_boxing_weekend(date)
23
29
  - name: Southland Anniversary Day
24
30
  regions: [nz_sl]
25
31
  mday: 17
26
32
  - name: Wellington Anniversary Day
27
33
  regions: [nz_we]
28
34
  mday: 22
29
- observed: closest_monday
35
+ observed: closest_monday(date)
30
36
  - name: Auckland Anniversary Day
31
37
  regions: [nz_ak]
32
38
  mday: 29
33
- observed: closest_monday
39
+ observed: closest_monday(date)
34
40
  - name: Northland Anniversary Day
35
41
  regions: [nz_nl]
36
42
  mday: 29
37
- observed: closest_monday
43
+ observed: closest_monday(date)
38
44
  2:
39
45
  - name: Nelson Anniversary Day
40
46
  regions: [nz_ne]
41
47
  mday: 1
42
- observed: closest_monday
48
+ observed: closest_monday(date)
43
49
  - name: Waitangi Day
44
50
  regions: [nz]
45
51
  mday: 6
46
- observed: to_monday_if_weekend
52
+ observed: to_monday_if_weekend(date)
47
53
  3:
48
54
  - name: Otago Anniversary Day
49
55
  regions: [nz_ot]
50
56
  mday: 23
51
- observed: closest_monday
57
+ observed: closest_monday(date)
52
58
  - name: Taranaki Anniversary Day
53
59
  regions: [nz_ta]
54
60
  week: 2
55
61
  wday: 1
56
- observed: closest_monday
62
+ observed: closest_monday(date)
57
63
  4:
58
64
  - name: ANZAC Day
59
65
  regions: [nz]
60
66
  mday: 25
61
- observed: to_monday_if_weekend
67
+ observed: to_monday_if_weekend(date)
62
68
  6:
63
69
  - name: Queen's Birthday
64
70
  regions: [nz]
@@ -74,7 +80,7 @@ months:
74
80
  regions: [nz_hb]
75
81
  week: 1
76
82
  wday: 1
77
- observed: previous_friday
83
+ observed: previous_friday(date)
78
84
  - name: Labour Day
79
85
  regions: [nz]
80
86
  week: 4
@@ -83,7 +89,7 @@ months:
83
89
  regions: [nz_mb]
84
90
  week: 4
85
91
  wday: 1
86
- observed: next_week
92
+ observed: next_week(date)
87
93
  11:
88
94
  - name: Canterbury Anniversary Day
89
95
  regions: [nz_ca]
@@ -92,20 +98,20 @@ months:
92
98
  - name: Chatham Island Anniversary Day
93
99
  regions: [nz_ch]
94
100
  mday: 30
95
- observed: closest_monday
101
+ observed: closest_monday(date)
96
102
  12:
97
103
  - name: Westland Anniversary Day
98
104
  regions: [nz_wl]
99
105
  mday: 1
100
- observed: closest_monday
106
+ observed: closest_monday(date)
101
107
  - name: Christmas Day
102
108
  regions: [nz]
103
109
  mday: 25
104
- observed: to_monday_if_weekend
110
+ observed: to_monday_if_weekend(date)
105
111
  - name: Boxing Day
106
112
  regions: [nz]
107
113
  mday: 26
108
- observed: to_weekday_if_boxing_weekend
114
+ observed: to_weekday_if_boxing_weekend(date)
109
115
  tests: |
110
116
  {Date.civil(2007,1,1) => 'New Year\'s Day',
111
117
  Date.civil(2007,1,2) => 'Day after New Year\'s Day',
@@ -136,8 +142,9 @@ tests: |
136
142
  assert_equal 'Taranaki Anniversary Day', Holidays.on(Date.civil(2018, 3, 12), :nz_ta, :observed)[0][:name]
137
143
  assert_equal 'Taranaki Anniversary Day', Holidays.on(Date.civil(2019, 3, 11), :nz_ta, :observed)[0][:name]
138
144
  methods:
139
- closest_monday: |
140
- def self.closest_monday(date)
145
+ closest_monday:
146
+ arguments: date
147
+ source: |
141
148
  if [1, 2, 3, 4].include?(date.wday)
142
149
  date -= (date.wday - 1)
143
150
  elsif 0 == date.wday
@@ -146,14 +153,11 @@ methods:
146
153
  date += 8 - date.wday
147
154
  end
148
155
  date
149
- end
150
-
151
- previous_friday: |
152
- def self.previous_friday(date)
156
+ previous_friday:
157
+ arguments: date
158
+ source: |
153
159
  date - 3
154
- end
155
-
156
- next_week: |
157
- def self.next_week(date)
160
+ next_week:
161
+ arguments: date
162
+ source: |
158
163
  date + 7
159
- end
@@ -9,13 +9,16 @@ months:
9
9
  0:
10
10
  - name: Maundy Thursday
11
11
  regions: [ph]
12
- function: easter(year)-3
12
+ function: easter(year)
13
+ function_modifier: -3
13
14
  - name: Good Friday
14
15
  regions: [ph]
15
- function: easter(year)-2
16
+ function: easter(year)
17
+ function_modifier: -2
16
18
  - name: Holy Saturday
17
19
  regions: [ph]
18
- function: easter(year)-1
20
+ function: easter(year)
21
+ function_modifier: -1
19
22
  - name: Easter Sunday
20
23
  regions: [ph]
21
24
  function: easter(year)
@@ -64,13 +67,17 @@ months:
64
67
  regions: [ph]
65
68
  mday: 31
66
69
  methods:
67
- ph_heroes_day: |
70
+ ph_heroes_day:
68
71
  # last Monday of August
69
- def self.ph_heroes_day(year)
72
+ arguments: year
73
+ source: |
70
74
  date = Date.new(year, 8, -1)
71
- return date if date.wday == 1
72
- date -= date.wday - 1
73
- end
75
+
76
+ if date.wday != 1
77
+ date -= date.wday - 1
78
+ end
79
+
80
+ date
74
81
  tests: |
75
82
  {Date.civil(2015,2,25) => 'People Power Anniversary',
76
83
  Date.civil(2015,4,3) => 'Good Friday',
@@ -7,44 +7,54 @@ months:
7
7
  0:
8
8
  - name: Tłusty Czwartek
9
9
  regions: [pl]
10
- function: easter(year)-52
10
+ function: easter(year)
11
+ function_modifier: -52
11
12
  type: informal
12
13
  - name: Ostatki
13
14
  regions: [pl]
14
- function: easter(year)-47
15
+ function: easter(year)
16
+ function_modifier: -47
15
17
  type: informal
16
18
  - name: Środa Popielcowa
17
19
  regions: [pl]
18
- function: easter(year)-46
20
+ function: easter(year)
21
+ function_modifier: -46
19
22
  type: informal
20
23
  - name: Niedziela Palmowa
21
24
  regions: [pl]
22
- function: easter(year)-7
25
+ function: easter(year)
26
+ function_modifier: -7
23
27
  type: informal
24
28
  - name: Wielki Czwartek
25
29
  regions: [pl]
26
- function: easter(year)-3
30
+ function: easter(year)
31
+ function_modifier: -3
27
32
  type: informal
28
33
  - name: Wielki Piątek
29
34
  regions: [pl]
30
- function: easter(year)-2
35
+ function: easter(year)
36
+ function_modifier: -2
31
37
  type: informal
32
38
  - name: Wielka Sobota
33
39
  regions: [pl]
34
- function: easter(year)-1
40
+ function: easter(year)
41
+ function_modifier: -1
35
42
  type: informal
36
43
  - name: Niedziela Wielkanocna
37
44
  regions: [pl]
38
45
  function: easter(year)
39
46
  - name: Poniedziałek Wielkanocny (Lany Poniedziałek)
40
47
  regions: [pl]
41
- function: easter(year)+1
48
+ function: easter(year)
49
+ function_modifier: 1
42
50
  - name: Zesłanie Ducha Świętego (Zielone Świątki)
43
51
  regions: [pl]
44
- function: easter(year)+49
52
+ function: easter(year)
53
+ function_modifier: 49
45
54
  - name: Uroczystość Najświętszego Ciała i Krwi Pańskiej (Boże Ciało)
46
55
  regions: [pl]
47
- function: easter(year)+60
56
+ function: easter(year)
57
+ function_modifier: 60
48
58
  1:
49
59
  - name: Nowy Rok
50
60
  regions: [pl]
@@ -163,16 +173,16 @@ months:
163
173
  mday: 31
164
174
  type: informal
165
175
  methods:
166
- pl_trzech_kroli: |
176
+ pl_trzech_kroli:
167
177
  # Poland: January 6 is holiday since 2011
168
- def self.pl_trzech_kroli(year)
178
+ arguments: year
179
+ source: |
169
180
  year >= 2011 ? 6 : nil
170
- end
171
- pl_trzech_kroli_informal: |
181
+ pl_trzech_kroli_informal:
172
182
  # Poland: January 6 wasn't holiday before 2011
173
- def self.pl_trzech_kroli_informal(year)
183
+ arguments: year
184
+ source: |
174
185
  year < 2011 ? 6 : nil
175
- end
176
186
  tests: |
177
187
  {Date.civil(2011,1,1) => 'Nowy Rok',
178
188
  Date.civil(2011,5,1) => 'Święto Państwowe (Święto Pracy)',
@@ -307,4 +317,4 @@ tests: |
307
317
 
308
318
  # Wniebowzięcie Najświętszej Maryi Panny & Święto Wojska Polskiego
309
319
  assert_equal 'Wniebowzięcie Najświętszej Maryi Panny', (Holidays.on(Date.civil(2011,8,15), :pl)[0] || {})[:name]
310
- assert_equal 'Święto Wojska Polskiego', (Holidays.on(Date.civil(2011,8,15), :pl)[1] || {})[:name]
320
+ assert_equal 'Święto Wojska Polskiego', (Holidays.on(Date.civil(2011,8,15), :pl)[1] || {})[:name]
@@ -14,11 +14,13 @@ months:
14
14
  0:
15
15
  - name: Carnaval # same as Shrove Tuesday
16
16
  regions: [pt]
17
- function: easter(year)-47
17
+ function: easter(year)
18
+ function_modifier: -47
18
19
  type: informal
19
20
  - name: Sexta-feira Santa
20
21
  regions: [pt]
21
- function: easter(year)-2
22
+ function: easter(year)
23
+ function_modifier: -2
22
24
  - name: Páscoa
23
25
  regions: [pt]
24
26
  function: easter(year)
@@ -7,18 +7,21 @@
7
7
  ---
8
8
  months:
9
9
  0:
10
- - name: Paștele
10
+ - name: Paștele - duminică
11
11
  regions: [ro]
12
12
  function: orthodox_easter(year)
13
- - name: Paștele
13
+ - name: Paștele - luni
14
14
  regions: [ro]
15
- function: orthodox_easter(year)+1
16
- - name: Rusaliile
15
+ function: orthodox_easter(year)
16
+ function_modifier: 1
17
+ - name: Rusaliile - 50
17
18
  regions: [ro]
18
- function: orthodox_easter(year) + 49
19
- - name: Rusaliile
19
+ function: orthodox_easter(year)
20
+ function_modifier: 49
21
+ - name: Rusaliile - 51
20
22
  regions: [ro]
21
- function: orthodox_easter(year) + 50
23
+ function: orthodox_easter(year)
24
+ function_modifier: 50
22
25
  1:
23
26
  - name: Anul nou
24
27
  regions: [ro]
@@ -50,17 +53,17 @@ months:
50
53
  mday: 26
51
54
  tests: |
52
55
  {
53
- Date.civil(1961,4,9) => 'Paștele',
54
- Date.civil(1961,4,10) => 'Paștele',
55
- Date.civil(2013,5,5) => 'Paștele',
56
- Date.civil(2013,5,6) => 'Paștele',
57
- Date.civil(2027,5,2) => 'Paștele',
58
- Date.civil(2027,5,3) => 'Paștele',
59
- Date.civil(2012,6,4) => 'Rusaliile',
60
- Date.civil(2013,6,23) => 'Rusaliile',
61
- Date.civil(2013,6,24) => 'Rusaliile',
62
- Date.civil(1986,6,22) => 'Rusaliile',
63
- Date.civil(1986,6,23) => 'Rusaliile',
56
+ Date.civil(1961,4,9) => 'Paștele - duminică',
57
+ Date.civil(1961,4,10) => 'Paștele - luni',
58
+ Date.civil(2013,5,5) => 'Paștele - duminică',
59
+ Date.civil(2013,5,6) => 'Paștele - luni',
60
+ Date.civil(2027,5,2) => 'Paștele - duminică',
61
+ Date.civil(2027,5,3) => 'Paștele - luni',
62
+ Date.civil(2012,6,4) => 'Rusaliile - 51',
63
+ Date.civil(2013,6,23) => 'Rusaliile - 50',
64
+ Date.civil(2013,6,24) => 'Rusaliile - 51',
65
+ Date.civil(1986,6,22) => 'Rusaliile - 50',
66
+ Date.civil(1986,6,23) => 'Rusaliile - 51',
64
67
  Date.civil(2009,1,1) => 'Anul nou',
65
68
  Date.civil(2014,1,2) => 'Anul nou',
66
69
  Date.civil(2009,5,1) => 'Ziua muncii',
@@ -6,32 +6,37 @@
6
6
  # - http://www.worldtravelguide.net/country/269/public_holidays/Europe/Sweden.html
7
7
  # - http://hem.passagen.se/farila/midsum.htm
8
8
  # - http://www.timeanddate.com/calendar/?country=21
9
- ---
9
+ ---
10
10
  months:
11
- 0:
11
+ 0:
12
12
  - name: Långfredagen
13
13
  regions: [se]
14
- function: easter(year)-2
14
+ function: easter(year)
15
+ function_modifier: -2
15
16
  - name: Påskafton
16
17
  regions: [se]
17
- function: easter(year)-1
18
+ function: easter(year)
19
+ function_modifier: -1
18
20
  type: informal
19
21
  - name: Påskdagen
20
22
  regions: [se]
21
23
  function: easter(year)
22
24
  - name: Annandag påsk
23
25
  regions: [se]
24
- function: easter(year)+1
26
+ function: easter(year)
27
+ function_modifier: 1
25
28
  - name: Kristi himmelsfärdsdag # Ascension Day
26
29
  regions: [se]
27
- function: easter(year)+39
30
+ function: easter(year)
31
+ function_modifier: 39
28
32
  - name: Pingstdagen # Whitsunday
29
33
  regions: [se]
30
- function: easter(year)+49
34
+ function: easter(year)
35
+ function_modifier: 49
31
36
  - name: Alla helgons dag # All Saint's Day
32
37
  regions: [se]
33
38
  function: se_alla_helgons_dag(year)
34
- 1:
39
+ 1:
35
40
  - name: Nyårsdagen
36
41
  regions: [se]
37
42
  mday: 1
@@ -51,7 +56,8 @@ months:
51
56
  function: se_midsommardagen(year)
52
57
  - name: Midsommarafton
53
58
  regions: [se]
54
- function: se_midsommardagen(year)-1
59
+ function: se_midsommardagen(year)
60
+ function_modifier: -1
55
61
  type: informal
56
62
  12:
57
63
  - name: Julafton
@@ -69,26 +75,26 @@ months:
69
75
  mday: 31
70
76
  type: informal
71
77
  methods:
72
- se_midsommardagen: |
78
+ se_midsommardagen:
73
79
  # Sweden: Mid-summer (Saturday between June 20–26)
74
- def self.se_midsommardagen(year)
80
+ arguments: year
81
+ source: |
75
82
  date = Date.civil(year,6,20)
76
83
  date += (6 - date.wday)
77
84
  date
78
- end
79
- se_alla_helgons_dag: |
85
+ se_alla_helgons_dag:
80
86
  # Sweden: All Saint's Day (Saturday between Oct 31 and Nov 6)
81
- def self.se_alla_helgons_dag(year)
87
+ arguments: year
88
+ source: |
82
89
  date = Date.civil(year,10,31)
83
90
  date += (6 - date.wday)
84
91
  date
85
- end
86
92
  tests: |
87
- {Date.civil(2008,1,1) => 'Nyårsdagen',
93
+ {Date.civil(2008,1,1) => 'Nyårsdagen',
88
94
  Date.civil(2008,1,6) => 'Trettondedag jul',
89
95
  Date.civil(2008,3,21) => 'Långfredagen',
90
96
  Date.civil(2008,3,22) => 'Påskafton',
91
- Date.civil(2008,3,23) => 'Påskdagen',
97
+ Date.civil(2008,3,23) => 'Påskdagen',
92
98
  Date.civil(2008,3,24) => 'Annandag påsk',
93
99
  Date.civil(2008,5,1) => 'Första maj',
94
100
  Date.civil(2008,5,1) => 'Kristi himmelsfärdsdag',
@@ -111,4 +117,4 @@ tests: |
111
117
  Date.civil(2008,12,31) => 'Nyårsafton'
112
118
  }.each do |date, name|
113
119
  assert_equal name, (Holidays.on(date, :se, :informal)[0] || {})[:name]
114
- end
120
+ end