holidays 0.9.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/.gitignore +3 -0
  2. data/CHANGELOG +7 -0
  3. data/{README → README.rdoc} +36 -39
  4. data/data/SYNTAX +1 -1
  5. data/data/au.yaml +110 -105
  6. data/data/build_defs.rb +4 -3
  7. data/data/ca.yaml +140 -140
  8. data/data/cz.yaml +68 -0
  9. data/data/de.yaml +12 -14
  10. data/data/dk.yaml +1 -1
  11. data/data/es.yaml +1 -1
  12. data/data/fr.yaml +1 -1
  13. data/data/gb.yaml +1 -1
  14. data/data/ie.yaml +1 -1
  15. data/data/index.yaml +7 -2
  16. data/data/is.yaml +1 -1
  17. data/data/it.yaml +1 -1
  18. data/data/mx.yaml +1 -1
  19. data/data/nl.yaml +1 -1
  20. data/data/no.yaml +82 -0
  21. data/data/nyse.yaml +1 -1
  22. data/data/nz.yaml +141 -0
  23. data/data/pt.yaml +1 -1
  24. data/data/se.yaml +1 -1
  25. data/data/united_nations.yaml +188 -188
  26. data/data/ups.yaml +55 -55
  27. data/data/us.yaml +80 -80
  28. data/data/za.yaml +1 -1
  29. data/holidays.gemspec +155 -0
  30. data/lib/holidays.rb +424 -403
  31. data/lib/holidays/MANIFEST +28 -25
  32. data/lib/holidays/au.rb +43 -41
  33. data/lib/holidays/ca.rb +69 -68
  34. data/lib/holidays/cz.rb +36 -0
  35. data/lib/holidays/de.rb +51 -52
  36. data/lib/holidays/dk.rb +48 -47
  37. data/lib/holidays/es.rb +53 -52
  38. data/lib/holidays/europe.rb +236 -215
  39. data/lib/holidays/fr.rb +37 -36
  40. data/lib/holidays/gb.rb +41 -40
  41. data/lib/holidays/ie.rb +33 -32
  42. data/lib/holidays/is.rb +62 -61
  43. data/lib/holidays/it.rb +36 -35
  44. data/lib/holidays/mx.rb +52 -51
  45. data/lib/holidays/nl.rb +37 -36
  46. data/lib/holidays/no.rb +40 -0
  47. data/lib/holidays/north_america.rb +108 -107
  48. data/lib/holidays/nyse.rb +33 -32
  49. data/lib/holidays/nz.rb +69 -0
  50. data/lib/holidays/pt.rb +38 -52
  51. data/lib/holidays/scandinavia.rb +124 -114
  52. data/lib/holidays/se.rb +53 -52
  53. data/lib/holidays/united_nations.rb +25 -24
  54. data/lib/holidays/ups.rb +32 -31
  55. data/lib/holidays/us.rb +49 -48
  56. data/lib/holidays/za.rb +36 -35
  57. data/rakefile.rb +105 -113
  58. data/test/defs/test_defs_au.rb +36 -36
  59. data/test/defs/test_defs_ca.rb +29 -29
  60. data/test/defs/test_defs_cz.rb +26 -0
  61. data/test/defs/test_defs_de.rb +51 -46
  62. data/test/defs/test_defs_dk.rb +30 -30
  63. data/test/defs/test_defs_es.rb +57 -57
  64. data/test/defs/test_defs_europe.rb +280 -240
  65. data/test/defs/test_defs_fr.rb +26 -26
  66. data/test/defs/test_defs_gb.rb +36 -36
  67. data/test/defs/test_defs_ie.rb +21 -21
  68. data/test/defs/test_defs_is.rb +33 -33
  69. data/test/defs/test_defs_it.rb +25 -25
  70. data/test/defs/test_defs_mx.rb +22 -22
  71. data/test/defs/test_defs_nl.rb +24 -24
  72. data/test/defs/test_defs_no.rb +29 -0
  73. data/test/defs/test_defs_north_america.rb +54 -54
  74. data/test/defs/test_defs_nyse.rb +22 -22
  75. data/test/defs/test_defs_nz.rb +22 -0
  76. data/test/defs/test_defs_pt.rb +32 -32
  77. data/test/defs/test_defs_scandinavia.rb +94 -75
  78. data/test/defs/test_defs_se.rb +32 -32
  79. data/test/defs/test_defs_ups.rb +21 -21
  80. data/test/defs/test_defs_us.rb +23 -23
  81. data/test/defs/test_defs_za.rb +25 -25
  82. data/test/test_date.rb +123 -0
  83. data/test/test_helper.rb +22 -0
  84. data/test/test_holidays.rb +128 -0
  85. data/test/test_multiple_regions.rb +24 -0
  86. metadata +126 -73
@@ -1,36 +1,37 @@
1
- module Holidays
2
- # This file is generated by the Ruby Holiday gem.
3
- #
4
- # Definitions loaded: data/nl.yaml
5
- #
6
- # To use the definitions in this file, load them right after you load the
7
- # Holiday gem:
8
- #
9
- # require 'holidays'
10
- # require 'holidays/nl'
11
- #
12
- # More definitions are available at http://code.dunae.ca/holidays.
13
- module NL # :nodoc:
14
- DEFINED_REGIONS = [:nl]
15
-
16
- HOLIDAYS_BY_MONTH = {
17
- 5 => [{:mday => 4, :name => "Dodenherdenking", :regions => [:nl]},
18
- {:mday => 5, :name => "Bevrijdingsdag", :regions => [:nl]}],
19
- 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Goede Vrijdag", :regions => [:nl]},
20
- {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pasen", :regions => [:nl]},
21
- {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Pasen", :regions => [:nl]},
22
- {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Hemelvaartsdag", :regions => [:nl]},
23
- {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinksteren", :regions => [:nl]},
24
- {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pinksteren", :regions => [:nl]}],
25
- 1 => [{:mday => 1, :name => "Nieuwjaar", :regions => [:nl]}],
26
- 12 => [{:mday => 5, :type => :informal, :name => "Sinterklaas", :regions => [:nl]},
27
- {:mday => 25, :name => "Kerstmis", :regions => [:nl]},
28
- {:mday => 26, :name => "Kerstmis", :regions => [:nl]}],
29
- 4 => [{:mday => 30, :name => "Koninginnedag", :regions => [:nl]}]
30
- }
31
- end
32
-
33
-
34
- end
35
-
36
- Holidays.merge_defs(Holidays::NL::DEFINED_REGIONS, Holidays::NL::HOLIDAYS_BY_MONTH)
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)
@@ -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
- module Holidays
2
- # This file is generated by the Ruby Holiday gem.
3
- #
4
- # Definitions loaded: data/ca.yaml, data/mx.yaml, data/us.yaml, data/north_america_informal.yaml
5
- #
6
- # To use the definitions in this file, load them right after you load the
7
- # Holiday gem:
8
- #
9
- # require 'holidays'
10
- # require 'holidays/north_america'
11
- #
12
- # More definitions are available at http://code.dunae.ca/holidays.
13
- module North_America # :nodoc:
14
- DEFINED_REGIONS = [:ca, :ca_qc, :ca_nf, :ca_nt, :ca_nu, :ca_ab, :ca_on, :ca_sk, :ca_mb, :ca_bc, :ca_ns, :ca_yk, :mx, :mx_pue, :us, :us_dc]
15
-
16
- HOLIDAYS_BY_MONTH = {
17
- 5 => [{:function => lambda { |year| Holidays.ca_victoria_day(year) }, :function_id => "ca_victoria_day(year)", :name => "Victoria Day", :regions => [:ca]},
18
- {:function => lambda { |year| Holidays.ca_victoria_day(year) }, :function_id => "ca_victoria_day(year)", :name => "National Patriotes Day", :regions => [:ca_qc]},
19
- {:mday => 1, :name => "Día del Trabajo", :regions => [:mx]},
20
- {:mday => 5, :type => :informal, :name => "Cinco de Mayo", :regions => [:mx]},
21
- {:mday => 5, :name => "La Batalla de Puebla", :regions => [:mx_pue]},
22
- {:mday => 10, :type => :informal, :name => "Día de la Madre", :regions => [:mx]},
23
- {:mday => 15, :type => :informal, :name => "Día del Maestro", :regions => [:mx]},
24
- {:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:us]},
25
- {:wday => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]}],
26
- 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:ca]},
27
- {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :type => :informal, :name => "Easter Monday", :regions => [:ca]},
28
- {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :type => :informal, :name => "Good Friday", :regions => [:us]}],
29
- 11 => [{:mday => 11, :name => "Rememberance Day", :regions => [:ca]},
30
- {:mday => 1, :type => :informal, :name => "Todos los Santos", :regions => [:mx]},
31
- {:mday => 2, :type => :informal, :name => "Los Fieles Difuntos", :regions => [:mx]},
32
- {:wday => 1, :week => 3, :name => "Día de la Revolución", :regions => [:mx]},
33
- {:mday => 11, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Veterans Day", :regions => [:us]},
34
- {:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:us]}],
35
- 6 => [{:mday => 24, :name => "Discovery Day", :regions => [:ca_nf]},
36
- {:mday => 24, :name => "Fête Nationale", :regions => [:ca_qc]},
37
- {:mday => 21, :name => "National Aboriginal Day", :regions => [:ca_nt]},
38
- {:wday => 0, :week => 3, :type => :informal, :name => "Día del Padre", :regions => [:mx]}],
39
- 1 => [{:mday => 1, :name => "New Year's Day", :regions => [:ca]},
40
- {:mday => 2, :name => "New Year's", :regions => [:ca_qc]},
41
- {:mday => 1, :name => "Año nuevo", :regions => [:mx]},
42
- {:mday => 6, :name => "Dia de los Santos Reyes", :regions => [:mx]},
43
- {:mday => 1, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "New Year's Day", :regions => [:us]},
44
- {:wday => 1, :week => 3, :name => "Martin Luther King, Jr. Day", :regions => [:us]},
45
- {:function => lambda { |year| Holidays.us_inauguration_day(year) }, :function_id => "us_inauguration_day(year)", :name => "Inauguration Day", :regions => [:us_dc]}],
46
- 12 => [{:mday => 25, :name => "Christmas Day", :regions => [:ca]},
47
- {:mday => 26, :name => "Boxing Day", :regions => [:ca]},
48
- {:mday => 12, :type => :informal, :name => "Día de la Virgen de Guadalupe", :regions => [:mx]},
49
- {:mday => 24, :type => :informal, :name => "Nochebuena", :regions => [:mx]},
50
- {:mday => 25, :name => "Navidad", :regions => [:mx]},
51
- {:mday => 28, :name => "Los Santos Inocentes", :regions => [:mx]},
52
- {:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:us]}],
53
- 7 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Canada Day", :regions => [:ca]},
54
- {:mday => 12, :name => "Orangemen's Day", :regions => [:ca_nf]},
55
- {:mday => 9, :name => "Nunavut Day", :regions => [:ca_nu]},
56
- {:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:us]}],
57
- 2 => [{:wday => 1, :week => 3, :name => "Family Day", :regions => [:ca_ab, :ca_on, :ca_sk]},
58
- {:wday => 1, :week => 3, :name => "Louis Riel Day", :regions => [:ca_mb]},
59
- {:wday => 1, :week => 1, :name => "Día de la Constitución", :regions => [:mx]},
60
- {:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:us]},
61
- {:mday => 2, :type => :informal, :name => "Groundhog Day", :regions => [:us, :ca]},
62
- {:mday => 14, :type => :informal, :name => "Valentine's Day", :regions => [:us, :ca]}],
63
- 8 => [{:wday => 1, :week => 1, :name => "BC Day", :regions => [:ca_bc]},
64
- {:wday => 1, :week => 1, :name => "Saskatchewan Day", :regions => [:ca_sk]},
65
- {:wday => 1, :week => 1, :name => "Heritage Day", :regions => [:ca_ab]},
66
- {:wday => 1, :week => 1, :name => "Natal Day", :regions => [:ca_ns]},
67
- {:wday => 1, :week => 1, :name => "Civic Holiday", :regions => [:ca_on]},
68
- {:wday => 1, :week => 3, :name => "Discovery Day", :regions => [:ca_yk]}],
69
- 3 => [{:mday => 23, :name => "St. George's Day", :regions => [:ca_nf]},
70
- {:wday => 1, :week => 3, :name => "Natalicio de Benito Juárez", :regions => [:mx]},
71
- {:mday => 17, :type => :informal, :name => "St. Patrick's Day", :regions => [:us, :ca]}],
72
- 9 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:ca]},
73
- {:mday => 15, :name => "Grito de Dolores", :regions => [:mx]},
74
- {:mday => 16, :name => "Día de la Independencia", :regions => [:mx]},
75
- {:wday => 1, :week => 1, :name => "Labor Day", :regions => [:us]}],
76
- 4 => [{:mday => 30, :type => :informal, :name => "Día del Niño", :regions => [:mx]},
77
- {:mday => 1, :type => :informal, :name => "April Fool's Day", :regions => [:us, :ca]},
78
- {:mday => 22, :type => :informal, :name => "Earth Day", :regions => [:us, :ca]}],
79
- 10 => [{:wday => 1, :week => 2, :name => "Thanksgiving", :regions => [:ca]},
80
- {:mday => 12, :type => :informal, :name => "Día de la Raza", :regions => [:mx]},
81
- {:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]},
82
- {:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]}]
83
- }
84
- end
85
-
86
- # Monday on or before May 24
87
- def self.ca_victoria_day(year)
88
- date = Date.civil(year,5,24)
89
- if date.wday > 1
90
- date -= (date.wday - 1)
91
- elsif date.wday == 0
92
- date -= 6
93
- end
94
- date
95
- end
96
-
97
-
98
- # January 20, every fourth year, following Presidential election
99
- def self.us_inauguration_day(year)
100
- year % 4 == 1 ? 20 : nil
101
- end
102
-
103
-
104
-
105
- end
106
-
107
- Holidays.merge_defs(Holidays::North_America::DEFINED_REGIONS, Holidays::North_America::HOLIDAYS_BY_MONTH)
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)
@@ -1,32 +1,33 @@
1
- module Holidays
2
- # This file is generated by the Ruby Holiday gem.
3
- #
4
- # Definitions loaded: data/nyse.yaml
5
- #
6
- # To use the definitions in this file, load them right after you load the
7
- # Holiday gem:
8
- #
9
- # require 'holidays'
10
- # require 'holidays/nyse'
11
- #
12
- # More definitions are available at http://code.dunae.ca/holidays.
13
- module NYSE # :nodoc:
14
- DEFINED_REGIONS = [:nyse]
15
-
16
- HOLIDAYS_BY_MONTH = {
17
- 5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:nyse]}],
18
- 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:nyse]}],
19
- 11 => [{:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:nyse]}],
20
- 1 => [{:mday => 1, :name => "New Year's Day", :regions => [:nyse]},
21
- {:wday => 1, :week => 3, :name => "Martin Luther King, Jr. Day", :regions => [:nyse]}],
22
- 12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas 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
- 2 => [{:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:nyse]}],
25
- 9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:nyse]}]
26
- }
27
- end
28
-
29
-
30
- end
31
-
32
- Holidays.merge_defs(Holidays::NYSE::DEFINED_REGIONS, Holidays::NYSE::HOLIDAYS_BY_MONTH)
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)
@@ -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)