holidays 0.9.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/CHANGELOG +7 -0
- data/{README → README.rdoc} +36 -39
- data/data/SYNTAX +1 -1
- data/data/au.yaml +110 -105
- data/data/build_defs.rb +4 -3
- data/data/ca.yaml +140 -140
- data/data/cz.yaml +68 -0
- data/data/de.yaml +12 -14
- data/data/dk.yaml +1 -1
- data/data/es.yaml +1 -1
- data/data/fr.yaml +1 -1
- data/data/gb.yaml +1 -1
- data/data/ie.yaml +1 -1
- data/data/index.yaml +7 -2
- data/data/is.yaml +1 -1
- data/data/it.yaml +1 -1
- data/data/mx.yaml +1 -1
- data/data/nl.yaml +1 -1
- data/data/no.yaml +82 -0
- data/data/nyse.yaml +1 -1
- data/data/nz.yaml +141 -0
- data/data/pt.yaml +1 -1
- data/data/se.yaml +1 -1
- data/data/united_nations.yaml +188 -188
- data/data/ups.yaml +55 -55
- data/data/us.yaml +80 -80
- data/data/za.yaml +1 -1
- data/holidays.gemspec +155 -0
- data/lib/holidays.rb +424 -403
- data/lib/holidays/MANIFEST +28 -25
- data/lib/holidays/au.rb +43 -41
- data/lib/holidays/ca.rb +69 -68
- data/lib/holidays/cz.rb +36 -0
- data/lib/holidays/de.rb +51 -52
- data/lib/holidays/dk.rb +48 -47
- data/lib/holidays/es.rb +53 -52
- data/lib/holidays/europe.rb +236 -215
- data/lib/holidays/fr.rb +37 -36
- data/lib/holidays/gb.rb +41 -40
- data/lib/holidays/ie.rb +33 -32
- data/lib/holidays/is.rb +62 -61
- data/lib/holidays/it.rb +36 -35
- data/lib/holidays/mx.rb +52 -51
- data/lib/holidays/nl.rb +37 -36
- data/lib/holidays/no.rb +40 -0
- data/lib/holidays/north_america.rb +108 -107
- data/lib/holidays/nyse.rb +33 -32
- data/lib/holidays/nz.rb +69 -0
- data/lib/holidays/pt.rb +38 -52
- data/lib/holidays/scandinavia.rb +124 -114
- data/lib/holidays/se.rb +53 -52
- data/lib/holidays/united_nations.rb +25 -24
- data/lib/holidays/ups.rb +32 -31
- data/lib/holidays/us.rb +49 -48
- data/lib/holidays/za.rb +36 -35
- data/rakefile.rb +105 -113
- data/test/defs/test_defs_au.rb +36 -36
- data/test/defs/test_defs_ca.rb +29 -29
- data/test/defs/test_defs_cz.rb +26 -0
- data/test/defs/test_defs_de.rb +51 -46
- data/test/defs/test_defs_dk.rb +30 -30
- data/test/defs/test_defs_es.rb +57 -57
- data/test/defs/test_defs_europe.rb +280 -240
- data/test/defs/test_defs_fr.rb +26 -26
- data/test/defs/test_defs_gb.rb +36 -36
- data/test/defs/test_defs_ie.rb +21 -21
- data/test/defs/test_defs_is.rb +33 -33
- data/test/defs/test_defs_it.rb +25 -25
- data/test/defs/test_defs_mx.rb +22 -22
- data/test/defs/test_defs_nl.rb +24 -24
- data/test/defs/test_defs_no.rb +29 -0
- data/test/defs/test_defs_north_america.rb +54 -54
- data/test/defs/test_defs_nyse.rb +22 -22
- data/test/defs/test_defs_nz.rb +22 -0
- data/test/defs/test_defs_pt.rb +32 -32
- data/test/defs/test_defs_scandinavia.rb +94 -75
- data/test/defs/test_defs_se.rb +32 -32
- data/test/defs/test_defs_ups.rb +21 -21
- data/test/defs/test_defs_us.rb +23 -23
- data/test/defs/test_defs_za.rb +25 -25
- data/test/test_date.rb +123 -0
- data/test/test_helper.rb +22 -0
- data/test/test_holidays.rb +128 -0
- data/test/test_multiple_regions.rb +24 -0
- metadata +126 -73
data/data/cz.yaml
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Czech holiday definitions for the Ruby Holiday gem.
|
2
|
+
#
|
3
|
+
# Updated: 2010-01-20.
|
4
|
+
# Sources:
|
5
|
+
# - http://cs.wikipedia.org/wiki/%C4%8Cesk%C3%BD_st%C3%A1tn%C3%AD_sv%C3%A1tek
|
6
|
+
# - http://www.mpsv.cz/cs/74
|
7
|
+
---
|
8
|
+
months:
|
9
|
+
0:
|
10
|
+
- name: Velikonoční pondělí
|
11
|
+
regions: [cz]
|
12
|
+
function: easter(year)+1
|
13
|
+
1:
|
14
|
+
- name: Den obnovy samostatného českého státu
|
15
|
+
regions: [cz]
|
16
|
+
mday: 1
|
17
|
+
5:
|
18
|
+
- name: Svátek práce
|
19
|
+
regions: [cz]
|
20
|
+
mday: 1
|
21
|
+
- name: Den vítězství
|
22
|
+
regions: [cz]
|
23
|
+
mday: 8
|
24
|
+
7:
|
25
|
+
- name: Den slovanských věrozvěstů Cyrila a Metoděje
|
26
|
+
regions: [cz]
|
27
|
+
mday: 5
|
28
|
+
- name: Den upálení mistra Jana Husa
|
29
|
+
regions: [cz]
|
30
|
+
mday: 6
|
31
|
+
9:
|
32
|
+
- name: Den české státnosti
|
33
|
+
regions: [cz]
|
34
|
+
mday: 28
|
35
|
+
10:
|
36
|
+
- name: Den vzniku samostatného československého státu
|
37
|
+
regions: [cz]
|
38
|
+
mday: 28
|
39
|
+
11:
|
40
|
+
- name: Den boje za svobodu a demokracii
|
41
|
+
regions: [cz]
|
42
|
+
mday: 17
|
43
|
+
12:
|
44
|
+
- name: Štědrý den
|
45
|
+
regions: [cz]
|
46
|
+
mday: 24
|
47
|
+
- name: 1. svátek vánoční
|
48
|
+
regions: [cz]
|
49
|
+
mday: 25
|
50
|
+
- name: 2. svátek vánoční
|
51
|
+
regions: [cz]
|
52
|
+
mday: 26
|
53
|
+
tests: |
|
54
|
+
{Date.civil(2010,1,1) => 'Den obnovy samostatného českého státu',
|
55
|
+
Date.civil(2010,4,5) => 'Velikonoční pondělí',
|
56
|
+
Date.civil(2010,5,1) => 'Svátek práce',
|
57
|
+
Date.civil(2010,5,8) => 'Den vítězství',
|
58
|
+
Date.civil(2010,7,5) => 'Den slovanských věrozvěstů Cyrila a Metoděje',
|
59
|
+
Date.civil(2010,7,6) => 'Den upálení mistra Jana Husa',
|
60
|
+
Date.civil(2010,9,28) => 'Den české státnosti',
|
61
|
+
Date.civil(2010,10,28) => 'Den vzniku samostatného československého státu',
|
62
|
+
Date.civil(2010,11,17) => 'Den boje za svobodu a demokracii',
|
63
|
+
Date.civil(2010,12,24) => 'Štědrý den',
|
64
|
+
Date.civil(2010,12,25) => '1. svátek vánoční',
|
65
|
+
Date.civil(2010,12,26) => '2. svátek vánoční'}.each do |date, name|
|
66
|
+
assert_equal name, (Holidays.on(date, :cz, :informal)[0] || {})[:name]
|
67
|
+
end
|
68
|
+
|
data/data/de.yaml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# German holiday definitions for the Ruby Holiday gem.
|
2
2
|
#
|
3
|
-
# Updated:
|
3
|
+
# Updated: 2009-11-05.
|
4
4
|
# Sources:
|
5
5
|
# - http://en.wikipedia.org/wiki/Holidays_in_Germany
|
6
6
|
# - http://www.timeanddate.com/calendar/index.html?country=8
|
@@ -11,10 +11,6 @@ months:
|
|
11
11
|
- name: Karfreitag
|
12
12
|
regions: [de]
|
13
13
|
function: easter(year)-2
|
14
|
-
- name: Ostern
|
15
|
-
regions: [de]
|
16
|
-
function: easter(year)
|
17
|
-
type: informal
|
18
14
|
- name: Ostermontag
|
19
15
|
regions: [de]
|
20
16
|
function: easter(year)+1
|
@@ -25,22 +21,19 @@ months:
|
|
25
21
|
regions: [de]
|
26
22
|
function: easter(year)+50
|
27
23
|
- name: Fronleichnam
|
28
|
-
regions: [de_bw, de_by, de_he, de_nw, de_rp, de_sl
|
24
|
+
regions: [de_bw, de_by, de_he, de_nw, de_rp, de_sl]
|
29
25
|
function: easter(year)+60
|
30
26
|
1:
|
31
27
|
- name: Neujahrstag
|
32
28
|
regions: [de]
|
33
29
|
mday: 1
|
34
30
|
- name: Heilige Drei Könige
|
35
|
-
regions: [de_bw, de_by]
|
31
|
+
regions: [de_bw, de_by, de_st]
|
36
32
|
mday: 6
|
37
33
|
5:
|
38
34
|
- name: Tag der Arbeit
|
39
35
|
regions: [de]
|
40
36
|
mday: 1
|
41
|
-
- name: Victoire 1945
|
42
|
-
regions: [de]
|
43
|
-
mday: 8
|
44
37
|
8:
|
45
38
|
- name: Mariä Himmelfahrt
|
46
39
|
regions: [de_by, de_sl]
|
@@ -57,7 +50,7 @@ months:
|
|
57
50
|
regions: [de_bw, de_by, de_nw, de_rp, de_sl]
|
58
51
|
mday: 1
|
59
52
|
- name: Buß- und Bettag
|
60
|
-
regions: [
|
53
|
+
regions: [de_sn]
|
61
54
|
function: de_buss_und_bettag(year)
|
62
55
|
12:
|
63
56
|
- name: 1. Weihnachtstag
|
@@ -81,7 +74,6 @@ methods:
|
|
81
74
|
tests: |
|
82
75
|
{Date.civil(2009,1,1) => 'Neujahrstag',
|
83
76
|
Date.civil(2009,4,10) => 'Karfreitag',
|
84
|
-
Date.civil(2009,4,12) => 'Ostern',
|
85
77
|
Date.civil(2009,4,13) => 'Ostermontag',
|
86
78
|
Date.civil(2009,5,1) => 'Tag der Arbeit',
|
87
79
|
Date.civil(2009,5,21) => 'Christi Himmelfahrt',
|
@@ -89,10 +81,14 @@ tests: |
|
|
89
81
|
Date.civil(2009,10,3) => 'Tag der Deutschen Einheit',
|
90
82
|
Date.civil(2009,12,25) => '1. Weihnachtstag',
|
91
83
|
Date.civil(2009,12,26) => '2. Weihnachtstag'}.each do |date, name|
|
92
|
-
assert_equal name, Holidays.on(date, :de, :informal)[0][:name]
|
84
|
+
assert_equal name, (Holidays.on(date, :de, :informal)[0] || {})[:name]
|
93
85
|
end
|
94
86
|
|
95
|
-
[:de_bw, :de_by, :
|
87
|
+
[:de_bw, :de_by, :de_st, :de_].each do |r|
|
88
|
+
assert_equal 'Heilige Drei Könige', Date.civil(2009,1,6).holidays(r)[0][:name]
|
89
|
+
end
|
90
|
+
|
91
|
+
[:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_].each do |r|
|
96
92
|
assert_equal 'Fronleichnam', Date.civil(2009,6,11).holidays(r)[0][:name]
|
97
93
|
end
|
98
94
|
|
@@ -107,6 +103,8 @@ tests: |
|
|
107
103
|
[:de_bw, :de_by, :de_nw, :de_rp, :de_sl, :de_].each do |r|
|
108
104
|
assert_equal 'Allerheiligen', Date.civil(2009,11,1).holidays(r)[0][:name]
|
109
105
|
end
|
106
|
+
|
107
|
+
assert !Date.civil(2010,5,8).holiday?(:de), '2010-05-08 is not a holiday in Germany'
|
110
108
|
|
111
109
|
# Repentance Day
|
112
110
|
assert_equal 'Buß- und Bettag', Date.civil(2004,11,17).holidays(:de_sn)[0][:name]
|
data/data/dk.yaml
CHANGED
@@ -113,5 +113,5 @@ tests: |
|
|
113
113
|
Date.civil(2007,12,24) => 'Juleaftensdag',
|
114
114
|
Date.civil(2007,12,25) => '1. juledag',
|
115
115
|
Date.civil(2007,12,26) => '2. juledag'}.each do |date, name|
|
116
|
-
assert_equal name, Holidays.on(date, :dk, :informal)[0][:name]
|
116
|
+
assert_equal name, (Holidays.on(date, :dk, :informal)[0] || {})[:name]
|
117
117
|
end
|
data/data/es.yaml
CHANGED
@@ -123,7 +123,7 @@ tests: |
|
|
123
123
|
Date.civil(2009,12,6) => 'Día de la Constitución',
|
124
124
|
Date.civil(2009,12,8) => 'Inmaculada Concepción',
|
125
125
|
Date.civil(2009,12,25) => 'Navidad del Señor'}.each do |date, name|
|
126
|
-
assert_equal name, Holidays.on(date, :es, :informal)[0][:name]
|
126
|
+
assert_equal name, (Holidays.on(date, :es, :informal)[0] || {})[:name]
|
127
127
|
end
|
128
128
|
|
129
129
|
[:es_pv, :es_ct, :es_na, :es_v, :es_vc, :es_].each do |r|
|
data/data/fr.yaml
CHANGED
@@ -66,5 +66,5 @@ tests: |
|
|
66
66
|
Date.civil(2007,11,1) => 'Toussaint',
|
67
67
|
Date.civil(2007,11,11) => 'Armistice 1918',
|
68
68
|
Date.civil(2007,12,25) => 'Nöel'}.each do |date, name|
|
69
|
-
assert_equal name, Holidays.on(date, :fr, :informal)[0][:name]
|
69
|
+
assert_equal name, (Holidays.on(date, :fr, :informal)[0] || {})[:name]
|
70
70
|
end
|
data/data/gb.yaml
CHANGED
@@ -87,7 +87,7 @@ tests: |
|
|
87
87
|
Date.civil(2008,11,5) => 'Guy Fawkes Day',
|
88
88
|
Date.civil(2008,12,25) => 'Christmas Day',
|
89
89
|
Date.civil(2008,12,26) => 'Boxing Day'}.each do |date, name|
|
90
|
-
assert_equal name, Holidays.on(date, :gb, :informal)[0][:name]
|
90
|
+
assert_equal name, (Holidays.on(date, :gb, :informal)[0] || {})[:name]
|
91
91
|
end
|
92
92
|
|
93
93
|
assert_equal 'St. Patrick\'s Day', Date.civil(2008,3,17).holidays(:gb_nir, :informal)[0][:name]
|
data/data/ie.yaml
CHANGED
@@ -54,5 +54,5 @@ tests: |
|
|
54
54
|
Date.civil(2008,8,4) => 'Bank Holiday',
|
55
55
|
Date.civil(2008,12,25) => 'Christmas Day',
|
56
56
|
Date.civil(2008,12,26) => 'St. Stephen\'s Day'}.each do |date, name|
|
57
|
-
assert_equal name, Holidays.on(date, :ie, :informal)[0][:name]
|
57
|
+
assert_equal name, (Holidays.on(date, :ie, :informal)[0] || {})[:name]
|
58
58
|
end
|
data/data/index.yaml
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
defs:
|
4
4
|
AU: ['au.yaml']
|
5
5
|
CA: ['ca.yaml', 'north_america_informal.yaml']
|
6
|
+
CZ: ['cz.yaml']
|
6
7
|
DK: ['dk.yaml']
|
7
8
|
DE: ['de.yaml']
|
8
9
|
ES: ['es.yaml']
|
@@ -13,11 +14,15 @@ defs:
|
|
13
14
|
IT: ['it.yaml']
|
14
15
|
MX: ['mx.yaml', 'north_america_informal.yaml']
|
15
16
|
NL: ['nl.yaml']
|
17
|
+
"NO": ['no.yaml']
|
16
18
|
NYSE: ['nyse.yaml']
|
17
|
-
|
19
|
+
NZ: ['nz.yaml']
|
20
|
+
PT: ['pt.yaml']
|
21
|
+
SE: ['se.yaml']
|
18
22
|
US: ['us.yaml', 'north_america_informal.yaml']
|
19
23
|
United_Nations: ['united_nations.yaml']
|
20
24
|
UPS: ['ups.yaml']
|
21
25
|
ZA: ['za.yaml']
|
22
26
|
North_America: ['ca.yaml', 'mx.yaml', 'us.yaml', 'north_america_informal.yaml']
|
23
|
-
|
27
|
+
Scandinavia: ['dk.yaml', 'is.yaml', 'no.yaml', 'se.yaml']
|
28
|
+
Europe: ['cz.yaml', 'dk.yaml', 'de.yaml', 'es.yaml', 'fr.yaml', 'gb.yaml', 'ie.yaml', 'is.yaml', 'it.yaml', 'nl.yaml', 'no.yaml', 'pt.yaml']
|
data/data/is.yaml
CHANGED
@@ -132,5 +132,5 @@ tests: |
|
|
132
132
|
Date.civil(2007,12,25) => 'Jól',
|
133
133
|
Date.civil(2007,12,26) => 'Jól',
|
134
134
|
Date.civil(2007,12,31) => 'Gamlárskvöld'}.each do |date, name|
|
135
|
-
assert_equal name, Holidays.on(date, :is, :informal)[0][:name]
|
135
|
+
assert_equal name, (Holidays.on(date, :is, :informal)[0] || {})[:name]
|
136
136
|
end
|
data/data/it.yaml
CHANGED
@@ -62,5 +62,5 @@ tests: |
|
|
62
62
|
Date.civil(2007,12,8) => 'Immacolata Concezione',
|
63
63
|
Date.civil(2007,12,25) => 'Natale',
|
64
64
|
Date.civil(2007,12,26) => 'Santo Stefano'}.each do |date, name|
|
65
|
-
assert_equal name, Holidays.on(date, :it, :informal)[0][:name]
|
65
|
+
assert_equal name, (Holidays.on(date, :it, :informal)[0] || {})[:name]
|
66
66
|
end
|
data/data/mx.yaml
CHANGED
@@ -102,5 +102,5 @@ tests: |
|
|
102
102
|
Date.civil(2007,11,2) => 'Los Fieles Difuntos',
|
103
103
|
Date.civil(2007,11,19) => 'Día de la Revolución',
|
104
104
|
Date.civil(2007,12,25) => 'Navidad'}.each do |date, name|
|
105
|
-
assert_equal name, Holidays.on(date, :mx, :informal)[0][:name]
|
105
|
+
assert_equal name, (Holidays.on(date, :mx, :informal)[0] || {})[:name]
|
106
106
|
end
|
data/data/nl.yaml
CHANGED
@@ -63,5 +63,5 @@ tests: |
|
|
63
63
|
Date.civil(2008,5,12) => 'Pinksteren', # Pentecost, Easter+50
|
64
64
|
Date.civil(2008,12,25) => 'Kerstmis',
|
65
65
|
Date.civil(2008,12,26) => 'Kerstmis'}.each do |date, name|
|
66
|
-
assert_equal name, Holidays.on(date, :nl, :informal)[0][:name]
|
66
|
+
assert_equal name, (Holidays.on(date, :nl, :informal)[0] || {})[:name]
|
67
67
|
end
|
data/data/no.yaml
ADDED
@@ -0,0 +1,82 @@
|
|
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)-49
|
13
|
+
type: informal
|
14
|
+
- name: Palmesøndag
|
15
|
+
regions: ["no"]
|
16
|
+
function: easter(year)-7
|
17
|
+
- name: Skjærtorsdag
|
18
|
+
regions: ["no"]
|
19
|
+
function: easter(year)-3
|
20
|
+
- name: Langfredag
|
21
|
+
regions: ["no"]
|
22
|
+
function: easter(year)-2
|
23
|
+
- name: 1. påskedag
|
24
|
+
regions: ["no"]
|
25
|
+
function: easter(year)
|
26
|
+
- name: 2. påskedag
|
27
|
+
regions: ["no"]
|
28
|
+
function: easter(year)+1
|
29
|
+
- name: Kristi Himmelfartsdag
|
30
|
+
regions: ["no"]
|
31
|
+
function: easter(year)+39
|
32
|
+
- name: 1. pinsedag
|
33
|
+
regions: ["no"]
|
34
|
+
function: easter(year)+49
|
35
|
+
- name: 2. pinsedag
|
36
|
+
regions: ["no"]
|
37
|
+
function: easter(year)+50
|
38
|
+
1:
|
39
|
+
- name: Nyttårsdag
|
40
|
+
regions: ["no"]
|
41
|
+
mday: 1
|
42
|
+
5:
|
43
|
+
- name: 1. mai
|
44
|
+
regions: ["no"]
|
45
|
+
mday: 1
|
46
|
+
- name: 17. mai
|
47
|
+
regions: ["no"]
|
48
|
+
mday: 17
|
49
|
+
12:
|
50
|
+
- name: Julaften
|
51
|
+
regions: ["no"]
|
52
|
+
mday: 24
|
53
|
+
type: informal
|
54
|
+
- name: 1. juledag
|
55
|
+
regions: ["no"]
|
56
|
+
mday: 25
|
57
|
+
- name: 2. juledag
|
58
|
+
regions: ["no"]
|
59
|
+
mday: 26
|
60
|
+
- name: Nyttårsaften
|
61
|
+
regions: ["no"]
|
62
|
+
mday: 31
|
63
|
+
type: informal
|
64
|
+
tests: |
|
65
|
+
{Date.civil(2010,1,1) => 'Nyttårsdag',
|
66
|
+
Date.civil(2010,5,1) => '1. mai',
|
67
|
+
Date.civil(2010,5,17) => '17. mai',
|
68
|
+
Date.civil(2010,12,24) => 'Julaften',
|
69
|
+
Date.civil(2010,12,25) => '1. juledag',
|
70
|
+
Date.civil(2010,12,26) => '2. juledag',
|
71
|
+
Date.civil(2010,12,31) => 'Nyttårsaften',
|
72
|
+
Date.civil(2010,2,14) => 'Fastelavn',
|
73
|
+
Date.civil(2010,3,28) => 'Palmesøndag',
|
74
|
+
Date.civil(2010,4,1) => 'Skjærtorsdag',
|
75
|
+
Date.civil(2010,4,2) => 'Langfredag',
|
76
|
+
Date.civil(2010,4,4) => '1. påskedag',
|
77
|
+
Date.civil(2010,4,5) => '2. påskedag',
|
78
|
+
Date.civil(2010,5,13) => 'Kristi Himmelfartsdag',
|
79
|
+
Date.civil(2010,5,23) => '1. pinsedag',
|
80
|
+
Date.civil(2010,5,24) => '2. pinsedag'}.each do |date, name|
|
81
|
+
assert_equal name, (Holidays.on(date, :no, :informal)[0] || {})[:name]
|
82
|
+
end
|
data/data/nyse.yaml
CHANGED
@@ -59,5 +59,5 @@ tests: |
|
|
59
59
|
Date.civil(2008,9,1) => 'Labor Day',
|
60
60
|
Date.civil(2008,11,27) => 'Thanksgiving',
|
61
61
|
Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name|
|
62
|
-
assert_equal name, Holidays.on(date, :nyse)[0][:name]
|
62
|
+
assert_equal name, (Holidays.on(date, :nyse)[0] || {})[:name]
|
63
63
|
end
|
data/data/nz.yaml
ADDED
@@ -0,0 +1,141 @@
|
|
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)-2
|
11
|
+
- name: Easter Saturday
|
12
|
+
regions: [nz]
|
13
|
+
function: easter(year)-1
|
14
|
+
- name: Easter Monday
|
15
|
+
regions: [nz]
|
16
|
+
function: easter(year)+1
|
17
|
+
1:
|
18
|
+
- name: New Year's Day
|
19
|
+
regions: [nz]
|
20
|
+
mday: 1
|
21
|
+
observed: to_monday_if_weekend
|
22
|
+
- name: Day after New Year's Day
|
23
|
+
regions: [nz]
|
24
|
+
mday: 2
|
25
|
+
observed: to_weekday_if_boxing_weekend
|
26
|
+
- name: Southland Anniversary Day
|
27
|
+
regions: [nz_sl]
|
28
|
+
mday: 17
|
29
|
+
- name: Wellington Anniversary Day
|
30
|
+
regions: [nz_we]
|
31
|
+
mday: 22
|
32
|
+
observed: closest_monday
|
33
|
+
- name: Auckland Anniversary Day
|
34
|
+
regions: [nz_ak]
|
35
|
+
mday: 29
|
36
|
+
observed: closest_monday
|
37
|
+
- name: Northland Anniversary Day
|
38
|
+
regions: [nz_nl]
|
39
|
+
mday: 29
|
40
|
+
observed: closest_monday
|
41
|
+
2:
|
42
|
+
- name: Nelson Anniversary Day
|
43
|
+
regions: [nz_ak]
|
44
|
+
mday: 1
|
45
|
+
observed: closest_monday
|
46
|
+
- name: Waitangi Day
|
47
|
+
regions: [nz]
|
48
|
+
mday: 6
|
49
|
+
3:
|
50
|
+
- name: Otago Anniversary Day
|
51
|
+
regions: [nz_ot]
|
52
|
+
mday: 23
|
53
|
+
observed: closest_monday
|
54
|
+
- name: Taranaki Anniversary Day
|
55
|
+
regions: [nz_ak]
|
56
|
+
week: 2
|
57
|
+
wday: 1
|
58
|
+
4:
|
59
|
+
- name: ANZAC Day
|
60
|
+
regions: [nz]
|
61
|
+
mday: 25
|
62
|
+
6:
|
63
|
+
- name: Queen's Birthday
|
64
|
+
regions: [nz]
|
65
|
+
week: 1
|
66
|
+
wday: 1
|
67
|
+
9:
|
68
|
+
- name: Dominion Day
|
69
|
+
regions: [nz_sc]
|
70
|
+
week: 4
|
71
|
+
wday: 1
|
72
|
+
10:
|
73
|
+
- name: Hawke's bay Anniversary Day
|
74
|
+
regions: [nz_hb]
|
75
|
+
week: 1
|
76
|
+
wday: 1
|
77
|
+
observed: previous_friday
|
78
|
+
- name: Labour Day
|
79
|
+
regions: [nz]
|
80
|
+
week: 4
|
81
|
+
wday: 1
|
82
|
+
- name: Marlborough Anniversary Day
|
83
|
+
regions: [nz_mb]
|
84
|
+
week: 4
|
85
|
+
wday: 1
|
86
|
+
observed: next_week
|
87
|
+
11:
|
88
|
+
- name: Canterbury Anniversary Day
|
89
|
+
regions: [nz_ca]
|
90
|
+
week: 2
|
91
|
+
wday: 5
|
92
|
+
- name: Chatham Island Anniversary Day
|
93
|
+
regions: [nz_ch]
|
94
|
+
mday: 30
|
95
|
+
observed: closest_monday
|
96
|
+
12:
|
97
|
+
- name: Westland Anniversary Day
|
98
|
+
regions: [nz_wl]
|
99
|
+
mday: 1
|
100
|
+
observed: closest_monday
|
101
|
+
- name: Christmas Day
|
102
|
+
regions: [nz]
|
103
|
+
mday: 25
|
104
|
+
observed: to_monday_if_weekend
|
105
|
+
- name: Boxing Day
|
106
|
+
regions: [nz]
|
107
|
+
mday: 26
|
108
|
+
observed: to_weekday_if_boxing_weekend
|
109
|
+
tests: |
|
110
|
+
{Date.civil(2007,1,1) => 'New Year\'s Day',
|
111
|
+
Date.civil(2007,1,2) => 'Day after New Year\'s Day',
|
112
|
+
Date.civil(2007,2,6) => 'Waitangi Day',
|
113
|
+
Date.civil(2007,4,6) => 'Good Friday',
|
114
|
+
Date.civil(2007,4,9) => 'Easter Monday',
|
115
|
+
Date.civil(2007,4,25) => 'ANZAC Day',
|
116
|
+
Date.civil(2007,12,25) => 'Christmas Day',
|
117
|
+
Date.civil(2007,12,26) => 'Boxing Day'}.each do |date, name|
|
118
|
+
assert_equal name, (Holidays.on(date, :nz, :informal)[0] || {})[:name]
|
119
|
+
end
|
120
|
+
methods:
|
121
|
+
closest_monday: |
|
122
|
+
def self.closest_monday(date)
|
123
|
+
if [1, 2, 3, 4].include?(date.wday)
|
124
|
+
date -= (date.wday - 1)
|
125
|
+
elsif 0 == date.wday
|
126
|
+
date += 1
|
127
|
+
else
|
128
|
+
date += 8 - date.wday
|
129
|
+
end
|
130
|
+
date
|
131
|
+
end
|
132
|
+
|
133
|
+
previous_friday: |
|
134
|
+
def self.previous_friday(date)
|
135
|
+
date - 3
|
136
|
+
end
|
137
|
+
|
138
|
+
next_week: |
|
139
|
+
def self.next_week(date)
|
140
|
+
date + 7
|
141
|
+
end
|