Skip to content

Commit

Permalink
Merge pull request #67 from 5rabbits/update-cl-holidays
Browse files Browse the repository at this point in the history
Update Chilean (CL) Holiday Definitions
  • Loading branch information
ppeble authored Aug 15, 2017
2 parents 0acd3a1 + 6513c88 commit 2bce036
Showing 1 changed file with 83 additions and 6 deletions.
89 changes: 83 additions & 6 deletions cl.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Chilean holiday definitions for the Ruby Holiday gem.
#
# Updated: 2014-10-08
# Updated: 2014-8-9
#
# Sources:
# - http://www.feriados.cl
# - http://www.feriadoschilenos.cl
#
---
months:
Expand All @@ -16,6 +17,16 @@ months:
regions: [cl]
function: easter(year)
function_modifier: -1
- name: San Pedro y San Pablo
regions: [cl]
function: st_peter_st_paul_cl(year)
year_ranges:
- after: 2000
- name: Día de las Iglesias Evangélicas y Protestantes
regions: [cl]
function: other_churches_day_cl(year)
year_ranges:
- after: 2008
1:
- name: Año Nuevo
regions: [cl]
Expand All @@ -31,6 +42,8 @@ months:
- name: San Pedro y San Pablo
regions: [cl]
mday: 29
year_ranges:
- before: 1999
7:
- name: Día de la Virgen del Carmen
regions: [cl]
Expand All @@ -50,9 +63,13 @@ months:
- name: Encuentro de Dos Mundos
regions: [cl]
mday: 12
- name: Día de las Iglesias Evangélicas y Protestantes
year_ranges:
- before: 1999
- name: Encuentro de Dos Mundos
regions: [cl]
mday: 31
year_ranges:
- after: 2000
function: columbus_day_cl(year)
11:
- name: Día de Todos los Santos
regions: [cl]
Expand All @@ -64,7 +81,43 @@ months:
- name: Navidad
regions: [cl]
mday: 25
methods:
st_peter_st_paul_cl:
arguments: year
# Nearest monday
source: |
date = Date.civil(year, 6, 29)
if [2,3,4].include?(date.wday)
date -= (date.wday - 1)
elsif date.wday == 5
date += 3
end
date
columbus_day_cl:
arguments: year
# Nearest monday
source: |
date = Date.civil(year, 10, 12)
if [2,3,4].include?(date.wday)
date -= (date.wday - 1)
elsif date.wday == 5
date += 3
end
date
other_churches_day_cl:
arguments: year
# If on tuesday, friday before, if on wednesday, next friday
source: |
date = Date.civil(year, 10, 31)
if date.wday == 2
date -= 4
elsif date.wday == 3
date += 2
end
date
tests:
- given:
date: '2014-01-01'
Expand Down Expand Up @@ -157,7 +210,25 @@ tests:
expect:
name: "Día de las Glorias Navales"
- given:
date: '2014-06-29'
date: '1999-06-29'
regions: ["cl"]
options: ["informal"]
expect:
name: "San Pedro y San Pablo"
- given:
date: '2000-06-26'
regions: ["cl"]
options: ["informal"]
expect:
name: "San Pedro y San Pablo"
- given:
date: '2017-06-26'
regions: ["cl"]
options: ["informal"]
expect:
name: "San Pedro y San Pablo"
- given:
date: '2018-07-2'
regions: ["cl"]
options: ["informal"]
expect:
Expand Down Expand Up @@ -187,13 +258,19 @@ tests:
expect:
name: "Día de las Glorias del Ejército"
- given:
date: '2014-10-12'
date: '1999-10-12'
regions: ["cl"]
options: ["informal"]
expect:
name: "Encuentro de Dos Mundos"
- given:
date: '2017-10-9'
regions: ["cl"]
options: ["informal"]
expect:
name: "Encuentro de Dos Mundos"
- given:
date: '2014-10-31'
date: '2017-10-27'
regions: ["cl"]
options: ["informal"]
expect:
Expand Down

0 comments on commit 2bce036

Please sign in to comment.