From b850336d3b5cc0b634fa6304200bdbcfa90722db Mon Sep 17 00:00:00 2001 From: Christian Kraus Date: Mon, 29 Oct 2018 18:08:32 +0100 Subject: [PATCH] Use correct easter date for BR --- src/Provider/AbstractEaster.php | 3 +++ src/Provider/BR.php | 19 +++++-------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/Provider/AbstractEaster.php b/src/Provider/AbstractEaster.php index b3de8bb..63bcbd8 100644 --- a/src/Provider/AbstractEaster.php +++ b/src/Provider/AbstractEaster.php @@ -66,6 +66,8 @@ protected function getEasterDates($year, $orthodox = false) $saturday->modify('-1 days'); $ascensionDay = clone $easterSunday; $ascensionDay->modify('+39 days'); + $shroveTuesday = clone $easterSunday; + $shroveTuesday->modify('-47 days'); $pentecostSunday = clone $easterSunday; @@ -78,6 +80,7 @@ protected function getEasterDates($year, $orthodox = false) $corpusChristi->modify('+60 days'); return array( + 'shroveTuesday' => $shroveTuesday, 'maundyThursday' => $maundyThursday, 'easterSunday' => $easterSunday, 'easterMonday' => $easterMonday, diff --git a/src/Provider/BR.php b/src/Provider/BR.php index df83ef7..b76f4ed 100644 --- a/src/Provider/BR.php +++ b/src/Provider/BR.php @@ -2,9 +2,7 @@ namespace Checkdomain\Holiday\Provider; -use DateInterval; use DateTime; -use DateTimeImmutable; /** * Brazilian Holiday Provider @@ -13,7 +11,7 @@ * @see http://www.planalto.gov.br/ccivil_03/leis/l6802.htm * @see https://pt.wikipedia.org/wiki/Feriados_no_Brasil */ -class BR extends AbstractProvider +class BR extends AbstractEaster { const STATE_AC = 'Acre'; const STATE_AL = 'Alagoas'; @@ -48,8 +46,7 @@ class BR extends AbstractProvider */ public function getHolidaysByYear($year) { - // Easter - $easter = DateTimeImmutable::createFromFormat('U', easter_date($year)); + $easter = $this->getEasterDates($year); $holidays = array( // National Fixed @@ -62,9 +59,9 @@ public function getHolidaysByYear($year) '11-15' => $this->createData('Proclamação da República'), '12-25' => $this->createData('Natal'), // National Variable (and Optional) - $easter->sub(new DateInterval('P47D'))->format(self::DATE_FORMAT) => $this->createData('Carnaval'), - $easter->sub(new DateInterval('P2D'))->format(self::DATE_FORMAT) => $this->createData('Sexta-Feira Santa'), - $easter->add(new DateInterval('P60D'))->format(self::DATE_FORMAT) => $this->createData('Corpus Christi'), + $easter['shroveTuesday']->format(self::DATE_FORMAT) => $this->createData('Carnaval'), + $easter['goodFriday']->format(self::DATE_FORMAT) => $this->createData('Sexta-Feira Santa'), + $easter['corpusChristi']->format(self::DATE_FORMAT) => $this->createData('Corpus Christi'), ); // Acre State @@ -144,12 +141,6 @@ public function getHolidaysByYear($year) // Rio de Janeiro State $this->setHolidayForState($holidays, '04-23', self::STATE_RJ, 'São Jorge'); $this->setHolidayForState($holidays, '11-20', self::STATE_RJ, 'Dia da Consciência Negra'); - $this->setHolidayForState( - $holidays, - $easter->sub(new DateInterval('P47D'))->format(self::DATE_FORMAT), - self::STATE_RJ, - 'Carnaval' - ); // Rio Grande do Norte State $this->setHolidayForState($holidays, '10-03', self::STATE_RN, 'Mártires de Cunhaú e Uruaçu');