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
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ *.gem
3
+ nbproject
data/CHANGELOG CHANGED
@@ -1,5 +1,12 @@
1
1
  = Ruby Holidays Gem CHANGELOG
2
2
 
3
+ == 1.0.0
4
+ * Support calculating mday from negative weeks other than -1 (thanks http://github.com/bjeanes)
5
+ * Use class method to check leap years and fixed bug in Date.calculate_mday
6
+ (thanks http://github.com/dgrambow)
7
+ * Added Czech (thanks http://github.com/boblin), Brazilian (http://github.com/fabiokr), Norwegian (thanks to Peter Skeide) and Australia/Brisbane (http://github.com/bjeanes) definitions
8
+ * Cleaned up rake and gemspec
9
+
3
10
  == 0.9.3
4
11
  * Added New York Stock Exchange holidays (thank you Alan Larkin).
5
12
  * Added UPS holidays (thank you Tim Anglade).
@@ -1,76 +1,73 @@
1
1
  = Ruby Holidays Gem
2
2
 
3
3
  A set of functions to deal with holidays in Ruby.
4
-
4
+
5
5
  Extends Ruby's built-in Date class and supports custom holiday definition lists.
6
-
6
+
7
7
  === Installation
8
-
9
- To install the gem from RubyForge:
10
-
8
+
9
+ To install the gem from RubyGems:
10
+
11
11
  gem install holidays
12
-
13
- Or, download the source <tt>.tgz</tt> file from http://rubyforge.org/holidays and
14
- extract it somewhere in your include path.
15
-
12
+
16
13
  === Examples
17
-
14
+
18
15
  For more information, see the notes at the top of the Holidays module.
19
-
16
+
20
17
  ==== Using the Holidays class
21
18
  Get all holidays on April 25, 2008 in Australia.
22
19
  date = Date.civil(2008,4,25)
23
-
20
+
24
21
  Holidays.on(date, :au)
25
22
  => [{:name => 'ANZAC Day',...}]
26
-
23
+
27
24
  Get holidays that are observed on July 2, 2007 in British Columbia, Canada.
28
25
  date = Date.civil(2007,7,2)
29
-
26
+
30
27
  Holidays.on(date, :ca_bc, :observed)
31
28
  => [{:name => 'Canada Day',...}]
32
-
29
+
33
30
  Get all holidays in July, 2008 in Canada and the US.
34
31
  from = Date.civil(2008,7,1)
35
- to = Date.civil(2008,7,31)
36
-
32
+ to = Date.civil(2008,7,31)
33
+
37
34
  Holidays.between(from, to, :ca, :us)
38
35
  => [{:name => 'Canada Day',...}
39
36
  {:name => 'Independence Day',...}]
40
-
37
+
41
38
  Get informal holidays in February.
42
39
  from = Date.civil(2008,2,1)
43
- to = Date.civil(2008,2,15)
44
-
40
+ to = Date.civil(2008,2,15)
41
+
45
42
  Holidays.between(from, to)
46
43
  => [{:name => 'Valentine\'s Day',...}]
47
-
48
-
44
+
45
+
49
46
  ==== Extending Ruby's Date class
50
47
  Check which holidays occur in Iceland on January 1, 2008.
51
48
  d = Date.civil(2008,7,1)
52
-
49
+
53
50
  d.holidays(:is)
54
51
  => [{:name => 'Nýársdagur'}...]
55
-
52
+
56
53
  Lookup Canada Day in different regions.
57
54
  d = Date.civil(2008,7,1)
58
-
59
- d.holiday?(:ca) # Canada
55
+
56
+ d.holiday?(:ca) # Canada
60
57
  => true
61
-
62
- d.holiday?(:ca_bc) # British Columbia, Canada
58
+
59
+ d.holiday?(:ca_bc) # British Columbia, Canada
63
60
  => true
64
-
65
- d.holiday?(:fr) # France
61
+
62
+ d.holiday?(:fr) # France
66
63
  => false
67
-
64
+
68
65
  === Credits and code
69
-
70
- * Project page: http://code.dunae.ca/holidays
71
- * Source: http://code.dunae.ca/svn/holidays
72
- * Docs: http://code.dunae.ca/holidays/doc
73
-
74
- By Alex Dunae (dunae.ca, e-mail 'code' at the same domain), 2007-08.
75
-
76
- Made on Vancouver Island.
66
+
67
+ * Source: https://github.com/alexdunae/holidays
68
+ * Docs: http://rdoc.info/github/alexdunae/holidays/master/frames
69
+ * Contributors: https://github.com/alexdunae/holidays/contributors
70
+
71
+ Started by Alex Dunae (dunae.ca, e-mail 'code' at the same domain), 2007-10.
72
+
73
+ Made on Vancouver Island.
@@ -101,7 +101,7 @@ All definition files should have tests included. In the YAML file, tests are ju
101
101
  Date.civil(2008,9,1) => 'Labour Day',
102
102
  Date.civil(2008,12,25) => 'Christmas Day',
103
103
  Date.civil(2008,12,26) => 'Boxing Day'}.each do |date, name|
104
- assert_equal name, Holidays.on(date, :ca, :informal)[0][:name]
104
+ assert_equal name, (Holidays.on(date, :ca, :informal)[0] || {})[:name]
105
105
  end
106
106
 
107
107
  # Victoria Day
@@ -1,106 +1,111 @@
1
- # Australian holiday definitions for the Ruby Holiday gem.
2
- # Updated: 2008-11-29.
3
- # Sources:
4
- # - http://en.wikipedia.org/wiki/Australian_public_holidays
5
- # - http://www.docep.wa.gov.au/lr/LabourRelations/Content/Wages%20and%20Conditions/Public%20Holidays/Public_Holidays.html
6
- # - http://www.wst.tas.gov.au/employment_info/public_holidays
7
- # TODO: missing some regional holidays
8
- ---
9
- months:
10
- 0:
11
- - name: Good Friday
12
- regions: [au]
13
- function: easter(year)-2
14
- - name: Easter Saturday
15
- regions: [au]
16
- function: easter(year)-1
17
- - name: Easter Monday
18
- regions: [au]
19
- function: easter(year)+1
20
- - name: Easter Monday
21
- regions: [au_tas]
22
- function: easter(year)+2
23
- 1:
24
- - name: New Year's Day
25
- regions: [au]
26
- mday: 1
27
- - name: Australia Day
28
- regions: [au]
29
- mday: 26
30
- 3:
31
- - name: Labour Day
32
- regions: [au_wa]
33
- week: 1
34
- wday: 1
35
- - name: Eight Hours Day
36
- regions: [au_tas]
37
- week: 2
38
- wday: 1
39
- - name: Labour Day
40
- regions: [au_vic]
41
- week: 2
42
- wday: 1
43
- 4:
44
- - name: ANZAC Day
45
- regions: [au]
46
- mday: 25
47
- 5:
48
- - name: Labour Day
49
- regions: [au_qld]
50
- week: 1
51
- wday: 1
52
- - name: May Day
53
- regions: [au_nt]
54
- week: 1
55
- wday: 1
56
- 6:
57
- - name: Foundation Day
58
- regions: [au_wa]
59
- week: 1
60
- wday: 1
61
- - name: Queen's Birthday
62
- regions: [au_act, au_nsw, au_sa, au_tas, au_nt, au_qld, au_vic]
63
- week: 2
64
- wday: 1
65
- - name: Queensland Day
66
- regions: [au_qld]
67
- mday: 6
68
- type: informal
69
- 10:
70
- - name: Labour Day
71
- regions: [au_act, au_nsw, au_sa]
72
- week: 1
73
- wday: 1
74
- 12:
75
- - name: Christmas Day
76
- regions: [au]
77
- mday: 25
78
- - name: Boxing Day
79
- regions: [au]
80
- mday: 26
81
- tests: |
82
- {Date.civil(2007,1,1) => 'New Year\'s Day',
83
- Date.civil(2007,1,26) => 'Australia Day',
84
- Date.civil(2007,4,6) => 'Good Friday',
85
- Date.civil(2007,4,9) => 'Easter Monday',
86
- Date.civil(2007,4,25) => 'ANZAC Day',
87
- Date.civil(2007,12,25) => 'Christmas Day',
88
- Date.civil(2007,12,26) => 'Boxing Day'}.each do |date, name|
89
- assert_equal name, Holidays.on(date, :au, :informal)[0][:name]
90
- end
91
-
92
- [:au_sa, :au_act, :au_nsw, :au_].each do |r|
93
- assert_equal 'Labour Day', Date.civil(2007,10,1).holidays(r)[0][:name]
94
- end
95
-
96
- [:au_sa, :au_act, :au_nsw, :au_vic, :au_tas, :au_qld, :au_nt, :au_].each do |r|
97
- assert_equal 'Queen\'s Birthday', Date.civil(2007,6,11).holidays(r)[0][:name]
98
- end
99
-
100
- assert_equal 'Labour Day', Date.civil(2007,3,5).holidays(:au_wa)[0][:name]
101
- assert_equal 'Labour Day', Date.civil(2007,3,12).holidays(:au_vic)[0][:name]
102
- assert_equal 'Labour Day', Date.civil(2007,5,7).holidays(:au_qld)[0][:name]
103
-
104
- assert_equal 'May Day', Date.civil(2007,5,7).holidays(:au_nt)[0][:name]
105
-
1
+ # Australian holiday definitions for the Ruby Holiday gem.
2
+ # Updated: 2008-11-29.
3
+ # Sources:
4
+ # - http://en.wikipedia.org/wiki/Australian_public_holidays
5
+ # - http://www.docep.wa.gov.au/lr/LabourRelations/Content/Wages%20and%20Conditions/Public%20Holidays/Public_Holidays.html
6
+ # - http://www.wst.tas.gov.au/employment_info/public_holidays
7
+ # TODO: missing some regional holidays
8
+ ---
9
+ months:
10
+ 0:
11
+ - name: Good Friday
12
+ regions: [au]
13
+ function: easter(year)-2
14
+ - name: Easter Saturday
15
+ regions: [au]
16
+ function: easter(year)-1
17
+ - name: Easter Monday
18
+ regions: [au]
19
+ function: easter(year)+1
20
+ - name: Easter Monday
21
+ regions: [au_tas]
22
+ function: easter(year)+2
23
+ 1:
24
+ - name: New Year's Day
25
+ regions: [au]
26
+ mday: 1
27
+ - name: Australia Day
28
+ regions: [au]
29
+ mday: 26
30
+ 3:
31
+ - name: Labour Day
32
+ regions: [au_wa]
33
+ week: 1
34
+ wday: 1
35
+ - name: Eight Hours Day
36
+ regions: [au_tas]
37
+ week: 2
38
+ wday: 1
39
+ - name: Labour Day
40
+ regions: [au_vic]
41
+ week: 2
42
+ wday: 1
43
+ 4:
44
+ - name: ANZAC Day
45
+ regions: [au]
46
+ mday: 25
47
+ 5:
48
+ - name: Labour Day
49
+ regions: [au_qld]
50
+ week: 1
51
+ wday: 1
52
+ - name: May Day
53
+ regions: [au_nt]
54
+ week: 1
55
+ wday: 1
56
+ 6:
57
+ - name: Foundation Day
58
+ regions: [au_wa]
59
+ week: 1
60
+ wday: 1
61
+ - name: Queen's Birthday
62
+ regions: [au_act, au_nsw, au_sa, au_tas, au_nt, au_qld, au_vic]
63
+ week: 2
64
+ wday: 1
65
+ - name: Queensland Day
66
+ regions: [au_qld]
67
+ mday: 6
68
+ type: informal
69
+ 8:
70
+ - name: Ekka
71
+ regions: [au_qld_brisbane]
72
+ week: -3
73
+ wday: 3
74
+ 10:
75
+ - name: Labour Day
76
+ regions: [au_act, au_nsw, au_sa]
77
+ week: 1
78
+ wday: 1
79
+ 12:
80
+ - name: Christmas Day
81
+ regions: [au]
82
+ mday: 25
83
+ - name: Boxing Day
84
+ regions: [au]
85
+ mday: 26
86
+ tests: |
87
+ {Date.civil(2007,1,1) => 'New Year\'s Day',
88
+ Date.civil(2007,1,26) => 'Australia Day',
89
+ Date.civil(2007,4,6) => 'Good Friday',
90
+ Date.civil(2007,4,9) => 'Easter Monday',
91
+ Date.civil(2007,4,25) => 'ANZAC Day',
92
+ Date.civil(2007,12,25) => 'Christmas Day',
93
+ Date.civil(2007,12,26) => 'Boxing Day'}.each do |date, name|
94
+ assert_equal name, (Holidays.on(date, :au, :informal)[0] || {})[:name]
95
+ end
96
+
97
+ [:au_sa, :au_act, :au_nsw, :au_].each do |r|
98
+ assert_equal 'Labour Day', Date.civil(2007,10,1).holidays(r)[0][:name]
99
+ end
100
+
101
+ [:au_sa, :au_act, :au_nsw, :au_vic, :au_tas, :au_qld, :au_nt, :au_].each do |r|
102
+ assert_equal 'Queen\'s Birthday', Date.civil(2007,6,11).holidays(r)[0][:name]
103
+ end
104
+
105
+ assert_equal 'Labour Day', Date.civil(2007,3,5).holidays(:au_wa)[0][:name]
106
+ assert_equal 'Labour Day', Date.civil(2007,3,12).holidays(:au_vic)[0][:name]
107
+ assert_equal 'Labour Day', Date.civil(2007,5,7).holidays(:au_qld)[0][:name]
108
+
109
+ assert_equal 'May Day', Date.civil(2007,5,7).holidays(:au_nt)[0][:name]
110
+
106
111
  assert_equal 'Eight Hours Day', Date.civil(2007,3,12).holidays(:au_tas)[0][:name]
@@ -52,7 +52,7 @@ def parse_holiday_defs(module_name, files)
52
52
  end
53
53
 
54
54
  if def_file['tests']
55
- puts " - importing testings..."
55
+ puts " - importing tests..."
56
56
  test_strs << def_file['tests']
57
57
  end
58
58
  end
@@ -102,6 +102,7 @@ def parse_holiday_defs(module_name, files)
102
102
 
103
103
  # Build the module file
104
104
  module_src =<<-EOM
105
+ # encoding: utf-8
105
106
  module Holidays
106
107
  # This file is generated by the Ruby Holiday gem.
107
108
  #
@@ -132,8 +133,8 @@ EOM
132
133
  # Build the test file
133
134
  unless test_strs.empty?
134
135
  test_src =<<-EndOfTests
135
- require File.dirname(__FILE__) + '/../test_helper'
136
- require 'holidays/#{module_name.downcase}'
136
+ # encoding: utf-8
137
+ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
137
138
 
138
139
  # This file is generated by the Ruby Holiday gem.
139
140
  #
@@ -1,141 +1,141 @@
1
- # Canadian holiday definitions for the Ruby Holiday gem.
2
- # Updated 2008-11-21.
3
- ---
4
- months:
5
- 0:
6
- - name: Good Friday
7
- regions: [ca]
8
- function: easter(year)-2
9
- - name: Easter Monday
10
- regions: [ca]
11
- function: easter(year)+1
12
- type: informal
13
- 1:
14
- - name: New Year's Day
15
- regions: [ca]
16
- mday: 1
17
- - name: New Year's
18
- regions: [ca_qc]
19
- mday: 2
20
- 2:
21
- - name: Family Day
22
- regions: [ca_ab, ca_on, ca_sk]
23
- wday: 1
24
- week: 3
25
- - name: Louis Riel Day
26
- regions: [ca_mb]
27
- wday: 1
28
- week: 3
29
- 3:
30
- - name: St. Patrick's Day
31
- regions: [ca_nf]
32
- mday: 17
33
- 3:
34
- - name: St. George's Day
35
- regions: [ca_nf]
36
- mday: 23
37
- 5:
38
- - name: Victoria Day
39
- regions: [ca]
40
- function: ca_victoria_day(year)
41
- - name: National Patriotes Day
42
- regions: [ca_qc]
43
- function: ca_victoria_day(year)
44
- 6:
45
- - name: Discovery Day
46
- regions: [ca_nf]
47
- mday: 24
48
- - name: Fête Nationale
49
- regions: [ca_qc]
50
- mday: 24
51
- - name: National Aboriginal Day
52
- regions: [ca_nt]
53
- mday: 21
54
- 7:
55
- - name: Canada Day
56
- regions: [ca]
57
- mday: 1
58
- observed: to_monday_if_sunday
59
- - name: Orangemen's Day
60
- regions: [ca_nf]
61
- mday: 12
62
- - name: Nunavut Day
63
- regions: [ca_nu]
64
- mday: 9
65
- 8:
66
- - name: BC Day
67
- week: 1
68
- regions: [ca_bc]
69
- wday: 1
70
- - name: Saskatchewan Day
71
- week: 1
72
- regions: [ca_sk]
73
- wday: 1
74
- - name: Heritage Day
75
- week: 1
76
- regions: [ca_ab]
77
- wday: 1
78
- - name: Natal Day
79
- week: 1
80
- regions: [ca_ns]
81
- wday: 1
82
- - name: Civic Holiday
83
- week: 1
84
- regions: [ca_on]
85
- wday: 1
86
- - name: Discovery Day
87
- week: 3
88
- regions: [ca_yk]
89
- wday: 1
90
- 9:
91
- - name: Labour Day
92
- week: 1
93
- regions: [ca]
94
- wday: 1
95
- 10:
96
- - name: Thanksgiving
97
- week: 2
98
- regions: [ca]
99
- wday: 1
100
- 11:
101
- - name: Rememberance Day
102
- regions: [ca]
103
- mday: 11
104
- 12:
105
- - name: Christmas Day
106
- regions: [ca]
107
- mday: 25
108
- - name: Boxing Day
109
- regions: [ca]
110
- mday: 26
111
- methods:
112
- ca_victoria_day: |
113
- # Monday on or before May 24
114
- def self.ca_victoria_day(year)
115
- date = Date.civil(year,5,24)
116
- if date.wday > 1
117
- date -= (date.wday - 1)
118
- elsif date.wday == 0
119
- date -= 6
120
- end
121
- date
122
- end
123
- tests: |
124
- {Date.civil(2008,1,1) => 'New Year\'s Day',
125
- Date.civil(2008,3,21) => 'Good Friday',
126
- Date.civil(2008,3,24) => 'Easter Monday',
127
- Date.civil(2008,5,19) => 'Victoria Day',
128
- Date.civil(2008,7,1) => 'Canada Day',
129
- Date.civil(2008,9,1) => 'Labour Day',
130
- Date.civil(2008,10,13) => 'Thanksgiving',
131
- Date.civil(2008,11,11) => 'Rememberance Day',
132
- Date.civil(2008,12,25) => 'Christmas Day',
133
- Date.civil(2008,12,26) => 'Boxing Day'}.each do |date, name|
134
- assert_equal name, Holidays.on(date, :ca, :informal)[0][:name]
135
- end
136
-
137
- # Victoria Day
138
- [Date.civil(2004,5,24), Date.civil(2005,5,23), Date.civil(2006,5,22),
139
- Date.civil(2007,5,21), Date.civil(2008,5,19)].each do |date|
140
- assert_equal 'Victoria Day', Holidays.on(date, :ca)[0][:name]
1
+ # Canadian holiday definitions for the Ruby Holiday gem.
2
+ # Updated 2008-11-21.
3
+ ---
4
+ months:
5
+ 0:
6
+ - name: Good Friday
7
+ regions: [ca]
8
+ function: easter(year)-2
9
+ - name: Easter Monday
10
+ regions: [ca]
11
+ function: easter(year)+1
12
+ type: informal
13
+ 1:
14
+ - name: New Year's Day
15
+ regions: [ca]
16
+ mday: 1
17
+ - name: New Year's
18
+ regions: [ca_qc]
19
+ mday: 2
20
+ 2:
21
+ - name: Family Day
22
+ regions: [ca_ab, ca_on, ca_sk]
23
+ wday: 1
24
+ week: 3
25
+ - name: Louis Riel Day
26
+ regions: [ca_mb]
27
+ wday: 1
28
+ week: 3
29
+ 3:
30
+ - name: St. Patrick's Day
31
+ regions: [ca_nf]
32
+ mday: 17
33
+ 3:
34
+ - name: St. George's Day
35
+ regions: [ca_nf]
36
+ mday: 23
37
+ 5:
38
+ - name: Victoria Day
39
+ regions: [ca]
40
+ function: ca_victoria_day(year)
41
+ - name: National Patriotes Day
42
+ regions: [ca_qc]
43
+ function: ca_victoria_day(year)
44
+ 6:
45
+ - name: Discovery Day
46
+ regions: [ca_nf]
47
+ mday: 24
48
+ - name: Fête Nationale
49
+ regions: [ca_qc]
50
+ mday: 24
51
+ - name: National Aboriginal Day
52
+ regions: [ca_nt]
53
+ mday: 21
54
+ 7:
55
+ - name: Canada Day
56
+ regions: [ca]
57
+ mday: 1
58
+ observed: to_monday_if_sunday
59
+ - name: Orangemen's Day
60
+ regions: [ca_nf]
61
+ mday: 12
62
+ - name: Nunavut Day
63
+ regions: [ca_nu]
64
+ mday: 9
65
+ 8:
66
+ - name: BC Day
67
+ week: 1
68
+ regions: [ca_bc]
69
+ wday: 1
70
+ - name: Saskatchewan Day
71
+ week: 1
72
+ regions: [ca_sk]
73
+ wday: 1
74
+ - name: Heritage Day
75
+ week: 1
76
+ regions: [ca_ab]
77
+ wday: 1
78
+ - name: Natal Day
79
+ week: 1
80
+ regions: [ca_ns]
81
+ wday: 1
82
+ - name: Civic Holiday
83
+ week: 1
84
+ regions: [ca_on]
85
+ wday: 1
86
+ - name: Discovery Day
87
+ week: 3
88
+ regions: [ca_yk]
89
+ wday: 1
90
+ 9:
91
+ - name: Labour Day
92
+ week: 1
93
+ regions: [ca]
94
+ wday: 1
95
+ 10:
96
+ - name: Thanksgiving
97
+ week: 2
98
+ regions: [ca]
99
+ wday: 1
100
+ 11:
101
+ - name: Rememberance Day
102
+ regions: [ca]
103
+ mday: 11
104
+ 12:
105
+ - name: Christmas Day
106
+ regions: [ca]
107
+ mday: 25
108
+ - name: Boxing Day
109
+ regions: [ca]
110
+ mday: 26
111
+ methods:
112
+ ca_victoria_day: |
113
+ # Monday on or before May 24
114
+ def self.ca_victoria_day(year)
115
+ date = Date.civil(year,5,24)
116
+ if date.wday > 1
117
+ date -= (date.wday - 1)
118
+ elsif date.wday == 0
119
+ date -= 6
120
+ end
121
+ date
122
+ end
123
+ tests: |
124
+ {Date.civil(2008,1,1) => 'New Year\'s Day',
125
+ Date.civil(2008,3,21) => 'Good Friday',
126
+ Date.civil(2008,3,24) => 'Easter Monday',
127
+ Date.civil(2008,5,19) => 'Victoria Day',
128
+ Date.civil(2008,7,1) => 'Canada Day',
129
+ Date.civil(2008,9,1) => 'Labour Day',
130
+ Date.civil(2008,10,13) => 'Thanksgiving',
131
+ Date.civil(2008,11,11) => 'Rememberance Day',
132
+ Date.civil(2008,12,25) => 'Christmas Day',
133
+ Date.civil(2008,12,26) => 'Boxing Day'}.each do |date, name|
134
+ assert_equal name, (Holidays.on(date, :ca, :informal)[0] || {})[:name]
135
+ end
136
+
137
+ # Victoria Day
138
+ [Date.civil(2004,5,24), Date.civil(2005,5,23), Date.civil(2006,5,22),
139
+ Date.civil(2007,5,21), Date.civil(2008,5,19)].each do |date|
140
+ assert_equal 'Victoria Day', Holidays.on(date, :ca)[0][:name]
141
141
  end