holidays 4.7.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +3 -0
  3. data/CHANGELOG.md +9 -0
  4. data/CONTRIBUTING.md +21 -11
  5. data/Makefile +9 -6
  6. data/holidays.gemspec +1 -1
  7. data/lib/generated_definitions/MANIFEST +1 -0
  8. data/lib/generated_definitions/REGIONS.rb +1 -1
  9. data/lib/generated_definitions/hk.rb +112 -0
  10. data/lib/generated_definitions/kr.rb +4 -4
  11. data/lib/holidays/errors.rb +1 -0
  12. data/lib/holidays/finder/context/parse_options.rb +8 -3
  13. data/lib/holidays/load_all_definitions.rb +0 -11
  14. data/lib/holidays/version.rb +1 -1
  15. data/test/defs/test_defs_hk.rb +38 -0
  16. data/test/defs/test_defs_jp.rb +1 -0
  17. data/test/defs/test_defs_kr.rb +1 -1
  18. data/test/holidays/definition/validator/test_region.rb +4 -0
  19. data/test/holidays/finder/context/test_parse_options.rb +9 -1
  20. data/test/integration/test_all_regions.rb +4 -4
  21. data/test/integration/test_custom_holidays.rb +4 -4
  22. data/test/integration/test_holidays.rb +6 -6
  23. metadata +6 -60
  24. data/definitions/README.md +0 -353
  25. data/definitions/ar.yaml +0 -93
  26. data/definitions/at.yaml +0 -72
  27. data/definitions/au.yaml +0 -378
  28. data/definitions/be_fr.yaml +0 -69
  29. data/definitions/be_nl.yaml +0 -69
  30. data/definitions/bg.yaml +0 -127
  31. data/definitions/br.yaml +0 -77
  32. data/definitions/ca.yaml +0 -317
  33. data/definitions/ch.yaml +0 -193
  34. data/definitions/cl.yaml +0 -94
  35. data/definitions/cr.yaml +0 -65
  36. data/definitions/cz.yaml +0 -73
  37. data/definitions/de.yaml +0 -209
  38. data/definitions/dk.yaml +0 -130
  39. data/definitions/ecb_target.yaml +0 -44
  40. data/definitions/el.yaml +0 -84
  41. data/definitions/es.yaml +0 -203
  42. data/definitions/federal_reserve.yaml +0 -114
  43. data/definitions/fedex.yaml +0 -62
  44. data/definitions/fi.yaml +0 -115
  45. data/definitions/fr.yaml +0 -79
  46. data/definitions/gb.yaml +0 -151
  47. data/definitions/hr.yaml +0 -79
  48. data/definitions/hu.yaml +0 -63
  49. data/definitions/ie.yaml +0 -89
  50. data/definitions/index.yaml +0 -61
  51. data/definitions/is.yaml +0 -146
  52. data/definitions/it.yaml +0 -67
  53. data/definitions/jp.yaml +0 -321
  54. data/definitions/kr.yaml +0 -282
  55. data/definitions/li.yaml +0 -107
  56. data/definitions/lt.yaml +0 -89
  57. data/definitions/lu.yaml +0 -56
  58. data/definitions/ma.yaml +0 -52
  59. data/definitions/mx.yaml +0 -106
  60. data/definitions/my.yaml +0 -51
  61. data/definitions/nerc.yaml +0 -51
  62. data/definitions/nl.yaml +0 -73
  63. data/definitions/no.yaml +0 -90
  64. data/definitions/north_america_informal.yaml +0 -61
  65. data/definitions/nyse.yaml +0 -64
  66. data/definitions/nz.yaml +0 -163
  67. data/definitions/pe.yaml +0 -119
  68. data/definitions/ph.yaml +0 -94
  69. data/definitions/pl.yaml +0 -320
  70. data/definitions/pt.yaml +0 -89
  71. data/definitions/ro.yaml +0 -78
  72. data/definitions/se.yaml +0 -120
  73. data/definitions/sg.yaml +0 -56
  74. data/definitions/si.yaml +0 -86
  75. data/definitions/sk.yaml +0 -80
  76. data/definitions/united_nations.yaml +0 -189
  77. data/definitions/ups.yaml +0 -62
  78. data/definitions/us.yaml +0 -103
  79. data/definitions/ve.yaml +0 -74
  80. data/definitions/vi.yaml +0 -29
  81. data/definitions/za.yaml +0 -80
@@ -1,51 +0,0 @@
1
- # NERC holiday definitions for the Ruby Holiday gem.
2
- #
3
- # By Adam Strickland
4
- # Source: www.nerc.com/docs/oc/rs/Additional_Off-peak_Days.doc
5
- #
6
- # Updated 2013-01-03.
7
- ---
8
- months:
9
- 1:
10
- - name: New Year's Day
11
- regions: [nerc]
12
- mday: 1
13
- observed: to_monday_if_sunday(date)
14
- 5:
15
- - name: Memorial Day
16
- week: -1
17
- regions: [nerc]
18
- wday: 1
19
- 7:
20
- - name: Independence Day
21
- regions: [nerc]
22
- mday: 4
23
- observed: to_monday_if_sunday(date)
24
- 9:
25
- - name: Labor Day
26
- week: 1
27
- regions: [nerc]
28
- wday: 1
29
- 11:
30
- - name: Thanksgiving
31
- week: 4
32
- regions: [nerc]
33
- wday: 4
34
- 12:
35
- - name: Christmas Day
36
- regions: [nerc]
37
- mday: 25
38
- observed: to_monday_if_sunday(date)
39
- methods:
40
- tests: |
41
- {Date.civil(2013,1,1) => 'New Year\'s Day',
42
- Date.civil(2017,1,2) => 'New Year\'s Day',
43
- Date.civil(2013,5,27) => 'Memorial Day',
44
- Date.civil(2013,7,4) => 'Independence Day',
45
- Date.civil(2010,7,5) => 'Independence Day',
46
- Date.civil(2013,9,2) => 'Labor Day',
47
- Date.civil(2013,11,28) => 'Thanksgiving',
48
- Date.civil(2013,12,25) => 'Christmas Day',
49
- Date.civil(2011,12,26) => 'Christmas Day'}.each do |date, name|
50
- assert_equal name, (Holidays.on(date, :nerc, :observed)[0] || {})[:name]
51
- end
@@ -1,73 +0,0 @@
1
- # Dutch holiday definitions for the Ruby Holiday gem.
2
- #
3
- # Updated: 2014-04-17.
4
- # Sources:
5
- # - http://en.wikipedia.org/wiki/Public_holidays_in_the_Netherlands
6
- ---
7
- months:
8
- 0:
9
- - name: Goede Vrijdag
10
- regions: [nl]
11
- function: easter(year)
12
- function_modifier: -2
13
- type: informal
14
- - name: Eerste Paasdag
15
- regions: [nl]
16
- function: easter(year)
17
- - name: Tweede Paasdag
18
- regions: [nl]
19
- function: easter(year)
20
- function_modifier: 1
21
- - name: Hemelvaartsdag
22
- regions: [nl]
23
- function: easter(year)
24
- function_modifier: 39
25
- - name: Eerste Pinksterdag
26
- regions: [nl]
27
- function: easter(year)
28
- function_modifier: 49
29
- - name: Tweede Pinksterdag
30
- regions: [nl]
31
- function: easter(year)
32
- function_modifier: 50
33
- 1:
34
- - name: Nieuwjaarsdag
35
- regions: [nl]
36
- mday: 1
37
- 4:
38
- - name: Koningsdag
39
- regions: [nl]
40
- mday: 27
41
- 5:
42
- - name: Dodenherdenking
43
- regions: [nl]
44
- mday: 4
45
- type: informal
46
- - name: Bevrijdingsdag
47
- regions: [nl]
48
- mday: 5
49
- 12:
50
- - name: Sinterklaas
51
- regions: [nl]
52
- mday: 5
53
- type: informal
54
- - name: Eerste Kerstdag
55
- regions: [nl]
56
- mday: 25
57
- - name: Tweede Kerstdag
58
- regions: [nl]
59
- mday: 26
60
- tests: |
61
- {Date.civil(2008,1,1) => 'Nieuwjaarsdag',
62
- Date.civil(2008,3,21) => 'Goede Vrijdag',
63
- Date.civil(2008,3,23) => 'Eerste Paasdag',
64
- Date.civil(2008,3,24) => 'Tweede Paasdag',
65
- Date.civil(2008,4,27) => 'Koningsdag',
66
- Date.civil(2008,5,1) => 'Hemelvaartsdag', # Ascension, Easter+39
67
- Date.civil(2008,5,5) => 'Bevrijdingsdag',
68
- Date.civil(2008,5,11) => 'Eerste Pinksterdag', # Pentecost, Easter+49
69
- Date.civil(2008,5,12) => 'Tweede Pinksterdag', # Pentecost, Easter+50
70
- Date.civil(2008,12,25) => 'Eerste Kerstdag',
71
- Date.civil(2008,12,26) => 'Tweede Kerstdag'}.each do |date, name|
72
- assert_equal name, (Holidays.on(date, :nl, :informal)[0] || {})[:name]
73
- end
@@ -1,90 +0,0 @@
1
- # Norwegian holiday definitions for the Ruby Holiday gem.
2
- #
3
- # Added: 20010-02-22.
4
- # Sources:
5
- # - http://no.wikipedia.org/wiki/Offentlig_fridag
6
- # - http://www.timeanddate.com/norsk/kalender.html
7
- ---
8
- months:
9
- 0:
10
- - name: Fastelavn
11
- regions: ["no"]
12
- function: easter(year)
13
- function_modifier: -49
14
- type: informal
15
- - name: Palmesøndag
16
- regions: ["no"]
17
- function: easter(year)
18
- function_modifier: -7
19
- - name: Skjærtorsdag
20
- regions: ["no"]
21
- function: easter(year)
22
- function_modifier: -3
23
- - name: Langfredag
24
- regions: ["no"]
25
- function: easter(year)
26
- function_modifier: -2
27
- - name: 1. påskedag
28
- regions: ["no"]
29
- function: easter(year)
30
- - name: 2. påskedag
31
- regions: ["no"]
32
- function: easter(year)
33
- function_modifier: 1
34
- - name: Kristi Himmelfartsdag
35
- regions: ["no"]
36
- function: easter(year)
37
- function_modifier: 39
38
- - name: 1. pinsedag
39
- regions: ["no"]
40
- function: easter(year)
41
- function_modifier: 49
42
- - name: 2. pinsedag
43
- regions: ["no"]
44
- function: easter(year)
45
- function_modifier: 50
46
- 1:
47
- - name: Nyttårsdag
48
- regions: ["no"]
49
- mday: 1
50
- 5:
51
- - name: 1. mai
52
- regions: ["no"]
53
- mday: 1
54
- - name: 17. mai
55
- regions: ["no"]
56
- mday: 17
57
- 12:
58
- - name: Julaften
59
- regions: ["no"]
60
- mday: 24
61
- type: informal
62
- - name: 1. juledag
63
- regions: ["no"]
64
- mday: 25
65
- - name: 2. juledag
66
- regions: ["no"]
67
- mday: 26
68
- - name: Nyttårsaften
69
- regions: ["no"]
70
- mday: 31
71
- type: informal
72
- tests: |
73
- {Date.civil(2010,1,1) => 'Nyttårsdag',
74
- Date.civil(2010,5,1) => '1. mai',
75
- Date.civil(2010,5,17) => '17. mai',
76
- Date.civil(2010,12,24) => 'Julaften',
77
- Date.civil(2010,12,25) => '1. juledag',
78
- Date.civil(2010,12,26) => '2. juledag',
79
- Date.civil(2010,12,31) => 'Nyttårsaften',
80
- Date.civil(2010,2,14) => 'Fastelavn',
81
- Date.civil(2010,3,28) => 'Palmesøndag',
82
- Date.civil(2010,4,1) => 'Skjærtorsdag',
83
- Date.civil(2010,4,2) => 'Langfredag',
84
- Date.civil(2010,4,4) => '1. påskedag',
85
- Date.civil(2010,4,5) => '2. påskedag',
86
- Date.civil(2010,5,13) => 'Kristi Himmelfartsdag',
87
- Date.civil(2010,5,23) => '1. pinsedag',
88
- Date.civil(2010,5,24) => '2. pinsedag'}.each do |date, name|
89
- assert_equal name, (Holidays.on(date, :no, :informal)[0] || {})[:name]
90
- end
@@ -1,61 +0,0 @@
1
- # Informal North American holiday definitions for the Ruby Holiday gem.
2
- # Updated 2008-11-22.
3
- ---
4
- months:
5
- 2:
6
- - name: Groundhog Day
7
- regions: [us, ca]
8
- mday: 2
9
- type: informal
10
- - name: Valentine's Day
11
- regions: [us, ca]
12
- mday: 14
13
- type: informal
14
- 3:
15
- - name: St. Patrick's Day
16
- regions: [us, ca]
17
- mday: 17
18
- type: informal
19
- 4:
20
- - name: April Fool's Day
21
- regions: [us, ca]
22
- mday: 1
23
- type: informal
24
- - name: Earth Day
25
- regions: [us, ca]
26
- mday: 22
27
- type: informal
28
- 5:
29
- - name: Mother's Day
30
- week: 2
31
- regions: [us, ca]
32
- wday: 0
33
- type: informal
34
- - name: Armed Forces Day
35
- week: 3
36
- regions: [us]
37
- wday: 6
38
- type: informal
39
- 6:
40
- - name: Father's Day
41
- week: 3
42
- regions: [us, ca]
43
- wday: 0
44
- type: informal
45
- 10:
46
- - name: Halloween
47
- regions: [us, ca]
48
- mday: 31
49
- type: informal
50
- tests: |
51
- {Date.civil(2013,2,2) => 'Groundhog Day',
52
- Date.civil(2013,2,14) => 'Valentine\'s Day',
53
- Date.civil(2013,3,17) => 'St. Patrick\'s Day',
54
- Date.civil(2013,4,1) => 'April Fool\'s Day',
55
- Date.civil(2013,4,22) => 'Earth Day',
56
- Date.civil(2013,5,12) => 'Mother\'s Day',
57
- Date.civil(2013,5,18) => 'Armed Forces Day',
58
- Date.civil(2013,6,16) => 'Father\'s Day',
59
- Date.civil(2013,10,31) => 'Halloween'}.each do |date, name|
60
- assert_equal name, (Holidays.on(date, :us, :informal)[0] || {})[:name]
61
- end
@@ -1,64 +0,0 @@
1
- # NYSE holiday definitions for the Ruby Holiday gem.
2
- #
3
- # By Alan Larkin
4
- # Source: http://www.nyse.com/about/newsevents/1176373643795.html#earlyclose2008
5
- #
6
- # Updated 2008-11-19.
7
- ---
8
- months:
9
- 0:
10
- - name: Good Friday
11
- regions: [nyse]
12
- function: easter(year)
13
- function_modifier: -2
14
- 1:
15
- - name: New Year's Day
16
- regions: [nyse]
17
- mday: 1
18
- - name: Martin Luther King, Jr. Day
19
- week: 3
20
- regions: [nyse]
21
- wday: 1
22
- 2:
23
- - name: Presidents' Day
24
- week: 3
25
- regions: [nyse]
26
- wday: 1
27
- 5:
28
- - name: Memorial Day
29
- week: -1
30
- regions: [nyse]
31
- wday: 1
32
- 7:
33
- - name: Independence Day
34
- regions: [nyse]
35
- mday: 4
36
- observed: to_weekday_if_weekend(date)
37
- 9:
38
- - name: Labor Day
39
- week: 1
40
- regions: [nyse]
41
- wday: 1
42
- 11:
43
- - name: Thanksgiving
44
- week: 4
45
- regions: [nyse]
46
- wday: 4
47
- 12:
48
- - name: Christmas Day
49
- regions: [nyse]
50
- mday: 25
51
- observed: to_weekday_if_weekend(date)
52
- methods:
53
- tests: |
54
- {Date.civil(2008,1,1) => 'New Year\'s Day',
55
- Date.civil(2008,1,21) => 'Martin Luther King, Jr. Day',
56
- Date.civil(2008,2,18) => 'Presidents\' Day',
57
- Date.civil(2008,3,21) => 'Good Friday',
58
- Date.civil(2008,5,26) => 'Memorial Day',
59
- Date.civil(2008,7,4) => 'Independence Day',
60
- Date.civil(2008,9,1) => 'Labor Day',
61
- Date.civil(2008,11,27) => 'Thanksgiving',
62
- Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name|
63
- assert_equal name, (Holidays.on(date, :nyse)[0] || {})[:name]
64
- end
@@ -1,163 +0,0 @@
1
- # New Zealand holiday definitions for the Ruby Holiday gem.
2
- # Updated: 2010-03-28.
3
- # Sources:
4
- # - http://en.wikipedia.org/wiki/Public_holidays_in_New_Zealand
5
- ---
6
- months:
7
- 0:
8
- - name: Good Friday
9
- regions: [nz]
10
- function: easter(year)
11
- function_modifier: -2
12
- - name: Easter Saturday
13
- regions: [nz]
14
- function: easter(year)
15
- function_modifier: -1
16
- - name: Easter Monday
17
- regions: [nz]
18
- function: easter(year)
19
- function_modifier: 1
20
- 1:
21
- - name: New Year's Day
22
- regions: [nz]
23
- mday: 1
24
- observed: to_monday_if_weekend(date)
25
- - name: Day after New Year's Day
26
- regions: [nz]
27
- mday: 2
28
- observed: to_weekday_if_boxing_weekend(date)
29
- - name: Southland Anniversary Day
30
- regions: [nz_sl]
31
- mday: 17
32
- - name: Wellington Anniversary Day
33
- regions: [nz_we]
34
- mday: 22
35
- observed: closest_monday(date)
36
- - name: Auckland Anniversary Day
37
- regions: [nz_ak]
38
- mday: 29
39
- observed: closest_monday(date)
40
- - name: Northland Anniversary Day
41
- regions: [nz_nl]
42
- mday: 29
43
- observed: closest_monday(date)
44
- 2:
45
- - name: Nelson Anniversary Day
46
- regions: [nz_ne]
47
- mday: 1
48
- observed: closest_monday(date)
49
- - name: Waitangi Day
50
- regions: [nz]
51
- mday: 6
52
- observed: to_monday_if_weekend(date)
53
- 3:
54
- - name: Otago Anniversary Day
55
- regions: [nz_ot]
56
- mday: 23
57
- observed: closest_monday(date)
58
- - name: Taranaki Anniversary Day
59
- regions: [nz_ta]
60
- week: 2
61
- wday: 1
62
- observed: closest_monday(date)
63
- 4:
64
- - name: ANZAC Day
65
- regions: [nz]
66
- mday: 25
67
- observed: to_monday_if_weekend(date)
68
- 6:
69
- - name: Queen's Birthday
70
- regions: [nz]
71
- week: 1
72
- wday: 1
73
- 9:
74
- - name: Dominion Day
75
- regions: [nz_sc]
76
- week: 4
77
- wday: 1
78
- 10:
79
- - name: Hawke's bay Anniversary Day
80
- regions: [nz_hb]
81
- week: 1
82
- wday: 1
83
- observed: previous_friday(date)
84
- - name: Labour Day
85
- regions: [nz]
86
- week: 4
87
- wday: 1
88
- - name: Marlborough Anniversary Day
89
- regions: [nz_mb]
90
- week: 4
91
- wday: 1
92
- observed: next_week(date)
93
- 11:
94
- - name: Canterbury Anniversary Day
95
- regions: [nz_ca]
96
- week: 2
97
- wday: 5
98
- - name: Chatham Island Anniversary Day
99
- regions: [nz_ch]
100
- mday: 30
101
- observed: closest_monday(date)
102
- 12:
103
- - name: Westland Anniversary Day
104
- regions: [nz_wl]
105
- mday: 1
106
- observed: closest_monday(date)
107
- - name: Christmas Day
108
- regions: [nz]
109
- mday: 25
110
- observed: to_monday_if_weekend(date)
111
- - name: Boxing Day
112
- regions: [nz]
113
- mday: 26
114
- observed: to_weekday_if_boxing_weekend(date)
115
- tests: |
116
- {Date.civil(2007,1,1) => 'New Year\'s Day',
117
- Date.civil(2007,1,2) => 'Day after New Year\'s Day',
118
- Date.civil(2007,2,6) => 'Waitangi Day',
119
- Date.civil(2007,4,6) => 'Good Friday',
120
- Date.civil(2007,4,9) => 'Easter Monday',
121
- Date.civil(2007,4,25) => 'ANZAC Day',
122
- Date.civil(2007,12,25) => 'Christmas Day',
123
- Date.civil(2007,12,26) => 'Boxing Day'}.each do |date, name|
124
- assert_equal name, (Holidays.on(date, :nz, :informal)[0] || {})[:name]
125
- end
126
- assert_equal 'ANZAC Day', Holidays.on(Date.civil(2015, 4, 25), :nz)[0][:name]
127
- assert_equal 'ANZAC Day', Holidays.on(Date.civil(2015, 4, 27), :nz, :observed)[0][:name]
128
- assert_equal 'ANZAC Day', Holidays.on(Date.civil(2016, 4, 25), :nz)[0][:name]
129
- assert_equal 'ANZAC Day', Holidays.on(Date.civil(2016, 4, 25), :nz, :observed)[0][:name]
130
- assert_equal 'Waitangi Day', Holidays.on(Date.civil(2015, 2, 6), :nz)[0][:name]
131
- assert_equal 'Waitangi Day', Holidays.on(Date.civil(2015, 2, 6), :nz, :observed)[0][:name]
132
- assert_equal 'Waitangi Day', Holidays.on(Date.civil(2016, 2, 6), :nz)[0][:name]
133
- assert_equal 'Waitangi Day', Holidays.on(Date.civil(2016, 2, 8), :nz, :observed)[0][:name]
134
-
135
- assert_equal 'Nelson Anniversary Day', Holidays.on(Date.civil(2016, 2, 1), :nz_ne, :observed)[0][:name]
136
- assert_equal 'Nelson Anniversary Day', Holidays.on(Date.civil(2017, 1, 30), :nz_ne, :observed)[0][:name]
137
- assert_equal 'Nelson Anniversary Day', Holidays.on(Date.civil(2018, 1, 29), :nz_ne, :observed)[0][:name]
138
- assert_equal 'Nelson Anniversary Day', Holidays.on(Date.civil(2019, 2, 4), :nz_ne, :observed)[0][:name]
139
-
140
- assert_equal 'Taranaki Anniversary Day', Holidays.on(Date.civil(2016, 3, 14), :nz_ta, :observed)[0][:name]
141
- assert_equal 'Taranaki Anniversary Day', Holidays.on(Date.civil(2017, 3, 13), :nz_ta, :observed)[0][:name]
142
- assert_equal 'Taranaki Anniversary Day', Holidays.on(Date.civil(2018, 3, 12), :nz_ta, :observed)[0][:name]
143
- assert_equal 'Taranaki Anniversary Day', Holidays.on(Date.civil(2019, 3, 11), :nz_ta, :observed)[0][:name]
144
- methods:
145
- closest_monday:
146
- arguments: date
147
- source: |
148
- if [1, 2, 3, 4].include?(date.wday)
149
- date -= (date.wday - 1)
150
- elsif 0 == date.wday
151
- date += 1
152
- else
153
- date += 8 - date.wday
154
- end
155
- date
156
- previous_friday:
157
- arguments: date
158
- source: |
159
- date - 3
160
- next_week:
161
- arguments: date
162
- source: |
163
- date + 7