From ec208d680e747bc91a5e8dba11dd91ce0ed8ebe1 Mon Sep 17 00:00:00 2001 From: Mario Lavandero Date: Mon, 14 Aug 2017 12:22:00 -0300 Subject: [PATCH 1/3] Update St Peter and St Paul holiday for CL Region Added method to calculate the holiday after 2000 and tests --- cl.yaml | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/cl.yaml b/cl.yaml index 182f86a..b00f668 100644 --- a/cl.yaml +++ b/cl.yaml @@ -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: @@ -16,6 +17,11 @@ 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 1: - name: Año Nuevo regions: [cl] @@ -31,6 +37,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] @@ -64,6 +72,19 @@ 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 tests: - given: @@ -157,7 +178,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: From 9d0b0ffa6c77425e6493ee3de66f87132c8d858e Mon Sep 17 00:00:00 2001 From: Mario Lavandero Date: Mon, 14 Aug 2017 12:26:14 -0300 Subject: [PATCH 2/3] Update Columbus Day holiday for CL Region Calculates the holiday after 2000 --- cl.yaml | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/cl.yaml b/cl.yaml index b00f668..7b968ee 100644 --- a/cl.yaml +++ b/cl.yaml @@ -58,9 +58,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] @@ -84,6 +88,18 @@ methods: 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 tests: @@ -226,7 +242,13 @@ 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: From 6513c88bacbe1df493141cd9c360178990eacf2c Mon Sep 17 00:00:00 2001 From: Mario Lavandero Date: Mon, 14 Aug 2017 12:29:18 -0300 Subject: [PATCH 3/3] Add other churches holiday to CL Region --- cl.yaml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cl.yaml b/cl.yaml index 7b968ee..6c80248 100644 --- a/cl.yaml +++ b/cl.yaml @@ -22,6 +22,11 @@ months: 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] @@ -101,7 +106,18 @@ methods: 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' @@ -254,7 +270,7 @@ tests: expect: name: "Encuentro de Dos Mundos" - given: - date: '2014-10-31' + date: '2017-10-27' regions: ["cl"] options: ["informal"] expect: