141 lines
No EOL
3.1 KiB
YAML
141 lines
No EOL
3.1 KiB
YAML
# Canadian holiday definitions for the Ruby Holiday gem.
|
|
# Updated 2008-11-21.
|
|
---
|
|
months:
|
|
0:
|
|
- name: Good Friday
|
|
regions: [ca]
|
|
function: easter(year)-2
|
|
- name: Easter Monday
|
|
regions: [ca]
|
|
function: easter(year)+1
|
|
type: informal
|
|
1:
|
|
- name: New Year's Day
|
|
regions: [ca]
|
|
mday: 1
|
|
- name: New Year's
|
|
regions: [ca_qc]
|
|
mday: 2
|
|
2:
|
|
- name: Family Day
|
|
regions: [ca_ab, ca_on, ca_sk]
|
|
wday: 1
|
|
week: 3
|
|
- name: Louis Riel Day
|
|
regions: [ca_mb]
|
|
wday: 1
|
|
week: 3
|
|
3:
|
|
- name: St. Patrick's Day
|
|
regions: [ca_nf]
|
|
mday: 17
|
|
3:
|
|
- name: St. George's Day
|
|
regions: [ca_nf]
|
|
mday: 23
|
|
5:
|
|
- name: Victoria Day
|
|
regions: [ca]
|
|
function: ca_victoria_day(year)
|
|
- name: National Patriotes Day
|
|
regions: [ca_qc]
|
|
function: ca_victoria_day(year)
|
|
6:
|
|
- name: Discovery Day
|
|
regions: [ca_nf]
|
|
mday: 24
|
|
- name: Fête Nationale
|
|
regions: [ca_qc]
|
|
mday: 24
|
|
- name: National Aboriginal Day
|
|
regions: [ca_nt]
|
|
mday: 21
|
|
7:
|
|
- name: Canada Day
|
|
regions: [ca]
|
|
mday: 1
|
|
observed: to_monday_if_sunday
|
|
- name: Orangemen's Day
|
|
regions: [ca_nf]
|
|
mday: 12
|
|
- name: Nunavut Day
|
|
regions: [ca_nu]
|
|
mday: 9
|
|
8:
|
|
- name: BC Day
|
|
week: 1
|
|
regions: [ca_bc]
|
|
wday: 1
|
|
- name: Saskatchewan Day
|
|
week: 1
|
|
regions: [ca_sk]
|
|
wday: 1
|
|
- name: Heritage Day
|
|
week: 1
|
|
regions: [ca_ab]
|
|
wday: 1
|
|
- name: Natal Day
|
|
week: 1
|
|
regions: [ca_ns]
|
|
wday: 1
|
|
- name: Civic Holiday
|
|
week: 1
|
|
regions: [ca_on]
|
|
wday: 1
|
|
- name: Discovery Day
|
|
week: 3
|
|
regions: [ca_yk]
|
|
wday: 1
|
|
9:
|
|
- name: Labour Day
|
|
week: 1
|
|
regions: [ca]
|
|
wday: 1
|
|
10:
|
|
- name: Thanksgiving
|
|
week: 2
|
|
regions: [ca]
|
|
wday: 1
|
|
11:
|
|
- name: Rememberance Day
|
|
regions: [ca]
|
|
mday: 11
|
|
12:
|
|
- name: Christmas Day
|
|
regions: [ca]
|
|
mday: 25
|
|
- name: Boxing Day
|
|
regions: [ca]
|
|
mday: 26
|
|
methods:
|
|
ca_victoria_day: |
|
|
# Monday on or before May 24
|
|
def self.ca_victoria_day(year)
|
|
date = Date.civil(year,5,24)
|
|
if date.wday > 1
|
|
date -= (date.wday - 1)
|
|
elsif date.wday == 0
|
|
date -= 6
|
|
end
|
|
date
|
|
end
|
|
tests: |
|
|
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
|
Date.civil(2008,3,21) => 'Good Friday',
|
|
Date.civil(2008,3,24) => 'Easter Monday',
|
|
Date.civil(2008,5,19) => 'Victoria Day',
|
|
Date.civil(2008,7,1) => 'Canada Day',
|
|
Date.civil(2008,9,1) => 'Labour Day',
|
|
Date.civil(2008,10,13) => 'Thanksgiving',
|
|
Date.civil(2008,11,11) => 'Rememberance Day',
|
|
Date.civil(2008,12,25) => 'Christmas Day',
|
|
Date.civil(2008,12,26) => 'Boxing Day'}.each do |date, name|
|
|
assert_equal name, Holidays.on(date, :ca, :informal)[0][:name]
|
|
end
|
|
|
|
# Victoria Day
|
|
[Date.civil(2004,5,24), Date.civil(2005,5,23), Date.civil(2006,5,22),
|
|
Date.civil(2007,5,21), Date.civil(2008,5,19)].each do |date|
|
|
assert_equal 'Victoria Day', Holidays.on(date, :ca)[0][:name]
|
|
end |