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/lib/holidays/nl.rb
CHANGED
@@ -1,36 +1,37 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# require 'holidays
|
11
|
-
#
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pasen", :regions => [:nl]},
|
21
|
-
{:function => lambda { |year| Holidays.easter(year)+
|
22
|
-
{:function => lambda { |year| Holidays.easter(year)+
|
23
|
-
{:function => lambda { |year| Holidays.easter(year)+
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
{:mday =>
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
module Holidays
|
3
|
+
# This file is generated by the Ruby Holiday gem.
|
4
|
+
#
|
5
|
+
# Definitions loaded: data/nl.yaml
|
6
|
+
#
|
7
|
+
# To use the definitions in this file, load them right after you load the
|
8
|
+
# Holiday gem:
|
9
|
+
#
|
10
|
+
# require 'holidays'
|
11
|
+
# require 'holidays/nl'
|
12
|
+
#
|
13
|
+
# More definitions are available at http://code.dunae.ca/holidays.
|
14
|
+
module NL # :nodoc:
|
15
|
+
DEFINED_REGIONS = [:nl]
|
16
|
+
|
17
|
+
HOLIDAYS_BY_MONTH = {
|
18
|
+
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Goede Vrijdag", :regions => [:nl]},
|
19
|
+
{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pasen", :regions => [:nl]},
|
20
|
+
{:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Pasen", :regions => [:nl]},
|
21
|
+
{:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Hemelvaartsdag", :regions => [:nl]},
|
22
|
+
{:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinksteren", :regions => [:nl]},
|
23
|
+
{:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pinksteren", :regions => [:nl]}],
|
24
|
+
1 => [{:mday => 1, :name => "Nieuwjaar", :regions => [:nl]}],
|
25
|
+
4 => [{:mday => 30, :name => "Koninginnedag", :regions => [:nl]}],
|
26
|
+
5 => [{:mday => 4, :name => "Dodenherdenking", :regions => [:nl]},
|
27
|
+
{:mday => 5, :name => "Bevrijdingsdag", :regions => [:nl]}],
|
28
|
+
12 => [{:mday => 5, :type => :informal, :name => "Sinterklaas", :regions => [:nl]},
|
29
|
+
{:mday => 25, :name => "Kerstmis", :regions => [:nl]},
|
30
|
+
{:mday => 26, :name => "Kerstmis", :regions => [:nl]}]
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
Holidays.merge_defs(Holidays::NL::DEFINED_REGIONS, Holidays::NL::HOLIDAYS_BY_MONTH)
|
data/lib/holidays/no.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Holidays
|
3
|
+
# This file is generated by the Ruby Holiday gem.
|
4
|
+
#
|
5
|
+
# Definitions loaded: data/no.yaml
|
6
|
+
#
|
7
|
+
# To use the definitions in this file, load them right after you load the
|
8
|
+
# Holiday gem:
|
9
|
+
#
|
10
|
+
# require 'holidays'
|
11
|
+
# require 'holidays/no'
|
12
|
+
#
|
13
|
+
# More definitions are available at http://code.dunae.ca/holidays.
|
14
|
+
module NO # :nodoc:
|
15
|
+
DEFINED_REGIONS = [:no]
|
16
|
+
|
17
|
+
HOLIDAYS_BY_MONTH = {
|
18
|
+
0 => [{:function => lambda { |year| Holidays.easter(year)-49 }, :function_id => "easter(year)-49", :type => :informal, :name => "Fastelavn", :regions => [:no]},
|
19
|
+
{:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :name => "Palmesøndag", :regions => [:no]},
|
20
|
+
{:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skjærtorsdag", :regions => [:no]},
|
21
|
+
{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Langfredag", :regions => [:no]},
|
22
|
+
{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "1. påskedag", :regions => [:no]},
|
23
|
+
{:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "2. påskedag", :regions => [:no]},
|
24
|
+
{:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi Himmelfartsdag", :regions => [:no]},
|
25
|
+
{:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "1. pinsedag", :regions => [:no]},
|
26
|
+
{:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "2. pinsedag", :regions => [:no]}],
|
27
|
+
1 => [{:mday => 1, :name => "Nyttårsdag", :regions => [:no]}],
|
28
|
+
5 => [{:mday => 1, :name => "1. mai", :regions => [:no]},
|
29
|
+
{:mday => 17, :name => "17. mai", :regions => [:no]}],
|
30
|
+
12 => [{:mday => 24, :type => :informal, :name => "Julaften", :regions => [:no]},
|
31
|
+
{:mday => 25, :name => "1. juledag", :regions => [:no]},
|
32
|
+
{:mday => 26, :name => "2. juledag", :regions => [:no]},
|
33
|
+
{:mday => 31, :type => :informal, :name => "Nyttårsaften", :regions => [:no]}]
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
Holidays.merge_defs(Holidays::NO::DEFINED_REGIONS, Holidays::NO::HOLIDAYS_BY_MONTH)
|
@@ -1,107 +1,108 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# require 'holidays
|
11
|
-
#
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
{:
|
20
|
-
{:
|
21
|
-
|
22
|
-
{:mday =>
|
23
|
-
{:mday =>
|
24
|
-
{:
|
25
|
-
{:
|
26
|
-
|
27
|
-
{:function => lambda { |year| Holidays.
|
28
|
-
|
29
|
-
|
30
|
-
{:
|
31
|
-
{:
|
32
|
-
{:
|
33
|
-
{:mday =>
|
34
|
-
|
35
|
-
|
36
|
-
{:mday =>
|
37
|
-
|
38
|
-
{:
|
39
|
-
|
40
|
-
{:mday =>
|
41
|
-
{:mday =>
|
42
|
-
{:mday =>
|
43
|
-
{:mday =>
|
44
|
-
{:wday => 1, :week =>
|
45
|
-
{:
|
46
|
-
|
47
|
-
{:mday =>
|
48
|
-
{:mday =>
|
49
|
-
{:
|
50
|
-
|
51
|
-
{:mday =>
|
52
|
-
{:mday =>
|
53
|
-
|
54
|
-
|
55
|
-
{:
|
56
|
-
{:
|
57
|
-
|
58
|
-
{:wday => 1, :week =>
|
59
|
-
{:wday => 1, :week =>
|
60
|
-
|
61
|
-
{:mday =>
|
62
|
-
{:mday =>
|
63
|
-
|
64
|
-
|
65
|
-
{:
|
66
|
-
{:wday => 1, :week =>
|
67
|
-
{:
|
68
|
-
|
69
|
-
|
70
|
-
{:
|
71
|
-
{:
|
72
|
-
|
73
|
-
{:
|
74
|
-
|
75
|
-
{:
|
76
|
-
|
77
|
-
{:mday =>
|
78
|
-
{:mday =>
|
79
|
-
|
80
|
-
{:mday =>
|
81
|
-
|
82
|
-
{:mday =>
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
module Holidays
|
3
|
+
# This file is generated by the Ruby Holiday gem.
|
4
|
+
#
|
5
|
+
# Definitions loaded: data/ca.yaml, data/mx.yaml, data/us.yaml, data/north_america_informal.yaml
|
6
|
+
#
|
7
|
+
# To use the definitions in this file, load them right after you load the
|
8
|
+
# Holiday gem:
|
9
|
+
#
|
10
|
+
# require 'holidays'
|
11
|
+
# require 'holidays/north_america'
|
12
|
+
#
|
13
|
+
# More definitions are available at http://code.dunae.ca/holidays.
|
14
|
+
module North_America # :nodoc:
|
15
|
+
DEFINED_REGIONS = [:ca, :ca_qc, :ca_ab, :ca_on, :ca_sk, :ca_mb, :ca_nf, :ca_nt, :ca_nu, :ca_bc, :ca_ns, :ca_yk, :mx, :mx_pue, :us, :us_dc]
|
16
|
+
|
17
|
+
HOLIDAYS_BY_MONTH = {
|
18
|
+
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:ca]},
|
19
|
+
{:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :type => :informal, :name => "Easter Monday", :regions => [:ca]},
|
20
|
+
{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :type => :informal, :name => "Good Friday", :regions => [:us]}],
|
21
|
+
1 => [{:mday => 1, :name => "New Year's Day", :regions => [:ca]},
|
22
|
+
{:mday => 2, :name => "New Year's", :regions => [:ca_qc]},
|
23
|
+
{:mday => 1, :name => "Año nuevo", :regions => [:mx]},
|
24
|
+
{:mday => 6, :name => "Dia de los Santos Reyes", :regions => [:mx]},
|
25
|
+
{:mday => 1, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "New Year's Day", :regions => [:us]},
|
26
|
+
{:wday => 1, :week => 3, :name => "Martin Luther King, Jr. Day", :regions => [:us]},
|
27
|
+
{:function => lambda { |year| Holidays.us_inauguration_day(year) }, :function_id => "us_inauguration_day(year)", :name => "Inauguration Day", :regions => [:us_dc]}],
|
28
|
+
2 => [{:wday => 1, :week => 3, :name => "Family Day", :regions => [:ca_ab, :ca_on, :ca_sk]},
|
29
|
+
{:wday => 1, :week => 3, :name => "Louis Riel Day", :regions => [:ca_mb]},
|
30
|
+
{:wday => 1, :week => 1, :name => "Día de la Constitución", :regions => [:mx]},
|
31
|
+
{:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:us]},
|
32
|
+
{:mday => 2, :type => :informal, :name => "Groundhog Day", :regions => [:us, :ca]},
|
33
|
+
{:mday => 14, :type => :informal, :name => "Valentine's Day", :regions => [:us, :ca]}],
|
34
|
+
3 => [{:mday => 23, :name => "St. George's Day", :regions => [:ca_nf]},
|
35
|
+
{:wday => 1, :week => 3, :name => "Natalicio de Benito Juárez", :regions => [:mx]},
|
36
|
+
{:mday => 17, :type => :informal, :name => "St. Patrick's Day", :regions => [:us, :ca]}],
|
37
|
+
5 => [{:function => lambda { |year| Holidays.ca_victoria_day(year) }, :function_id => "ca_victoria_day(year)", :name => "Victoria Day", :regions => [:ca]},
|
38
|
+
{:function => lambda { |year| Holidays.ca_victoria_day(year) }, :function_id => "ca_victoria_day(year)", :name => "National Patriotes Day", :regions => [:ca_qc]},
|
39
|
+
{:mday => 1, :name => "Día del Trabajo", :regions => [:mx]},
|
40
|
+
{:mday => 5, :type => :informal, :name => "Cinco de Mayo", :regions => [:mx]},
|
41
|
+
{:mday => 5, :name => "La Batalla de Puebla", :regions => [:mx_pue]},
|
42
|
+
{:mday => 10, :type => :informal, :name => "Día de la Madre", :regions => [:mx]},
|
43
|
+
{:mday => 15, :type => :informal, :name => "Día del Maestro", :regions => [:mx]},
|
44
|
+
{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:us]},
|
45
|
+
{:wday => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]}],
|
46
|
+
6 => [{:mday => 24, :name => "Discovery Day", :regions => [:ca_nf]},
|
47
|
+
{:mday => 24, :name => "Fête Nationale", :regions => [:ca_qc]},
|
48
|
+
{:mday => 21, :name => "National Aboriginal Day", :regions => [:ca_nt]},
|
49
|
+
{:wday => 0, :week => 3, :type => :informal, :name => "Día del Padre", :regions => [:mx]}],
|
50
|
+
7 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Canada Day", :regions => [:ca]},
|
51
|
+
{:mday => 12, :name => "Orangemen's Day", :regions => [:ca_nf]},
|
52
|
+
{:mday => 9, :name => "Nunavut Day", :regions => [:ca_nu]},
|
53
|
+
{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:us]}],
|
54
|
+
8 => [{:wday => 1, :week => 1, :name => "BC Day", :regions => [:ca_bc]},
|
55
|
+
{:wday => 1, :week => 1, :name => "Saskatchewan Day", :regions => [:ca_sk]},
|
56
|
+
{:wday => 1, :week => 1, :name => "Heritage Day", :regions => [:ca_ab]},
|
57
|
+
{:wday => 1, :week => 1, :name => "Natal Day", :regions => [:ca_ns]},
|
58
|
+
{:wday => 1, :week => 1, :name => "Civic Holiday", :regions => [:ca_on]},
|
59
|
+
{:wday => 1, :week => 3, :name => "Discovery Day", :regions => [:ca_yk]}],
|
60
|
+
9 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:ca]},
|
61
|
+
{:mday => 15, :name => "Grito de Dolores", :regions => [:mx]},
|
62
|
+
{:mday => 16, :name => "Día de la Independencia", :regions => [:mx]},
|
63
|
+
{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:us]}],
|
64
|
+
10 => [{:wday => 1, :week => 2, :name => "Thanksgiving", :regions => [:ca]},
|
65
|
+
{:mday => 12, :type => :informal, :name => "Día de la Raza", :regions => [:mx]},
|
66
|
+
{:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]},
|
67
|
+
{:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]}],
|
68
|
+
11 => [{:mday => 11, :name => "Rememberance Day", :regions => [:ca]},
|
69
|
+
{:mday => 1, :type => :informal, :name => "Todos los Santos", :regions => [:mx]},
|
70
|
+
{:mday => 2, :type => :informal, :name => "Los Fieles Difuntos", :regions => [:mx]},
|
71
|
+
{:wday => 1, :week => 3, :name => "Día de la Revolución", :regions => [:mx]},
|
72
|
+
{:mday => 11, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Veterans Day", :regions => [:us]},
|
73
|
+
{:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:us]}],
|
74
|
+
12 => [{:mday => 25, :name => "Christmas Day", :regions => [:ca]},
|
75
|
+
{:mday => 26, :name => "Boxing Day", :regions => [:ca]},
|
76
|
+
{:mday => 12, :type => :informal, :name => "Día de la Virgen de Guadalupe", :regions => [:mx]},
|
77
|
+
{:mday => 24, :type => :informal, :name => "Nochebuena", :regions => [:mx]},
|
78
|
+
{:mday => 25, :name => "Navidad", :regions => [:mx]},
|
79
|
+
{:mday => 28, :name => "Los Santos Inocentes", :regions => [:mx]},
|
80
|
+
{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:us]}],
|
81
|
+
4 => [{:mday => 30, :type => :informal, :name => "Día del Niño", :regions => [:mx]},
|
82
|
+
{:mday => 1, :type => :informal, :name => "April Fool's Day", :regions => [:us, :ca]},
|
83
|
+
{:mday => 22, :type => :informal, :name => "Earth Day", :regions => [:us, :ca]}]
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
# Monday on or before May 24
|
88
|
+
def self.ca_victoria_day(year)
|
89
|
+
date = Date.civil(year,5,24)
|
90
|
+
if date.wday > 1
|
91
|
+
date -= (date.wday - 1)
|
92
|
+
elsif date.wday == 0
|
93
|
+
date -= 6
|
94
|
+
end
|
95
|
+
date
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
# January 20, every fourth year, following Presidential election
|
100
|
+
def self.us_inauguration_day(year)
|
101
|
+
year % 4 == 1 ? 20 : nil
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
Holidays.merge_defs(Holidays::North_America::DEFINED_REGIONS, Holidays::North_America::HOLIDAYS_BY_MONTH)
|
data/lib/holidays/nyse.rb
CHANGED
@@ -1,32 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# require 'holidays
|
11
|
-
#
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:nyse]}],
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:nyse]}],
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
module Holidays
|
3
|
+
# This file is generated by the Ruby Holiday gem.
|
4
|
+
#
|
5
|
+
# Definitions loaded: data/nyse.yaml
|
6
|
+
#
|
7
|
+
# To use the definitions in this file, load them right after you load the
|
8
|
+
# Holiday gem:
|
9
|
+
#
|
10
|
+
# require 'holidays'
|
11
|
+
# require 'holidays/nyse'
|
12
|
+
#
|
13
|
+
# More definitions are available at http://code.dunae.ca/holidays.
|
14
|
+
module NYSE # :nodoc:
|
15
|
+
DEFINED_REGIONS = [:nyse]
|
16
|
+
|
17
|
+
HOLIDAYS_BY_MONTH = {
|
18
|
+
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:nyse]}],
|
19
|
+
1 => [{:mday => 1, :name => "New Year's Day", :regions => [:nyse]},
|
20
|
+
{:wday => 1, :week => 3, :name => "Martin Luther King, Jr. Day", :regions => [:nyse]}],
|
21
|
+
2 => [{:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:nyse]}],
|
22
|
+
5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:nyse]}],
|
23
|
+
7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:nyse]}],
|
24
|
+
9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:nyse]}],
|
25
|
+
11 => [{:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:nyse]}],
|
26
|
+
12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:nyse]}]
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
Holidays.merge_defs(Holidays::NYSE::DEFINED_REGIONS, Holidays::NYSE::HOLIDAYS_BY_MONTH)
|
data/lib/holidays/nz.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Holidays
|
3
|
+
# This file is generated by the Ruby Holiday gem.
|
4
|
+
#
|
5
|
+
# Definitions loaded: data/nz.yaml
|
6
|
+
#
|
7
|
+
# To use the definitions in this file, load them right after you load the
|
8
|
+
# Holiday gem:
|
9
|
+
#
|
10
|
+
# require 'holidays'
|
11
|
+
# require 'holidays/nz'
|
12
|
+
#
|
13
|
+
# More definitions are available at http://code.dunae.ca/holidays.
|
14
|
+
module NZ # :nodoc:
|
15
|
+
DEFINED_REGIONS = [:nz, :nz_sl, :nz_we, :nz_ak, :nz_nl, :nz_ot, :nz_sc, :nz_hb, :nz_mb, :nz_ca, :nz_ch, :nz_wl]
|
16
|
+
|
17
|
+
HOLIDAYS_BY_MONTH = {
|
18
|
+
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:nz]},
|
19
|
+
{:function => lambda { |year| Holidays.easter(year)-1 }, :function_id => "easter(year)-1", :name => "Easter Saturday", :regions => [:nz]},
|
20
|
+
{:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Easter Monday", :regions => [:nz]}],
|
21
|
+
1 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "New Year's Day", :regions => [:nz]},
|
22
|
+
{:mday => 2, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :name => "Day after New Year's Day", :regions => [:nz]},
|
23
|
+
{:mday => 17, :name => "Southland Anniversary Day", :regions => [:nz_sl]},
|
24
|
+
{:mday => 22, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Wellington Anniversary Day", :regions => [:nz_we]},
|
25
|
+
{:mday => 29, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Auckland Anniversary Day", :regions => [:nz_ak]},
|
26
|
+
{:mday => 29, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Northland Anniversary Day", :regions => [:nz_nl]}],
|
27
|
+
2 => [{:mday => 1, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Nelson Anniversary Day", :regions => [:nz_ak]},
|
28
|
+
{:mday => 6, :name => "Waitangi Day", :regions => [:nz]}],
|
29
|
+
3 => [{:mday => 23, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Otago Anniversary Day", :regions => [:nz_ot]},
|
30
|
+
{:wday => 1, :week => 2, :name => "Taranaki Anniversary Day", :regions => [:nz_ak]}],
|
31
|
+
4 => [{:mday => 25, :name => "ANZAC Day", :regions => [:nz]}],
|
32
|
+
6 => [{:wday => 1, :week => 1, :name => "Queen's Birthday", :regions => [:nz]}],
|
33
|
+
9 => [{:wday => 1, :week => 4, :name => "Dominion Day", :regions => [:nz_sc]}],
|
34
|
+
10 => [{:wday => 1, :week => 1, :observed => lambda { |date| Holidays.previous_friday(date) }, :observed_id => "previous_friday", :name => "Hawke's bay Anniversary Day", :regions => [:nz_hb]},
|
35
|
+
{:wday => 1, :week => 4, :name => "Labour Day", :regions => [:nz]},
|
36
|
+
{:wday => 1, :week => 4, :observed => lambda { |date| Holidays.next_week(date) }, :observed_id => "next_week", :name => "Marlborough Anniversary Day", :regions => [:nz_mb]}],
|
37
|
+
11 => [{:wday => 5, :week => 2, :name => "Canterbury Anniversary Day", :regions => [:nz_ca]},
|
38
|
+
{:mday => 30, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Chatham Island Anniversary Day", :regions => [:nz_ch]}],
|
39
|
+
12 => [{:mday => 1, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Westland Anniversary Day", :regions => [:nz_wl]},
|
40
|
+
{:mday => 25, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "Christmas Day", :regions => [:nz]},
|
41
|
+
{:mday => 26, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :name => "Boxing Day", :regions => [:nz]}]
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.closest_monday(date)
|
46
|
+
if [1, 2, 3, 4].include?(date.wday)
|
47
|
+
date -= (date.wday - 1)
|
48
|
+
elsif 0 == date.wday
|
49
|
+
date += 1
|
50
|
+
else
|
51
|
+
date += 8 - date.wday
|
52
|
+
end
|
53
|
+
date
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def self.previous_friday(date)
|
58
|
+
date - 3
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
def self.next_week(date)
|
63
|
+
date + 7
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
Holidays.merge_defs(Holidays::NZ::DEFINED_REGIONS, Holidays::NZ::HOLIDAYS_BY_MONTH)
|