From 80691cb8944bf6c8dec158c934d40ff0674ed947 Mon Sep 17 00:00:00 2001 From: Gabriel <48607315+gs-nasc@users.noreply.github.com> Date: Thu, 28 Jan 2021 12:20:05 -0300 Subject: [PATCH] Update Holiday.php --- src/Holiday.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Holiday.php b/src/Holiday.php index 48f9996..5a4fd6b 100644 --- a/src/Holiday.php +++ b/src/Holiday.php @@ -21,11 +21,13 @@ public function __construct($title = NULL, $date = NULL, $type = NULL) public function load($year = 2000, $type = "default") { + $fnacional = "Feriado Nacional"; + $holidays = json_decode(file_get_contents(dirname(__FILE__) . "/dates.json"), true); foreach ($holidays['fixed_holidays'] as $holiday) { if ($type == "default" || $type == "national") { - if ($holiday['type'] == "Feriado Nacional") { + if ($holiday['type'] == $fnacional) { $this->holiday[] = new Holiday($holiday['name'], DateTime::createFromFormat('d/m/Y', $holiday['date'] . '/' . $year), $holiday['type']); } } else { @@ -92,13 +94,13 @@ public function load($year = 2000, $type = "default") $dia_maes->modify('+7 days'); $dia_pais->modify('+98 days'); - $this->holiday[] = new Holiday('Páscoa', $pascoa, "Feriado Nacional"); - $this->holiday[] = new Holiday('Sexta-feira Santa', $sexta_santa, "Feriado Nacional"); - $this->holiday[] = new Holiday('Carnaval', $carnaval1, "Feriado Nacional"); - $this->holiday[] = new Holiday('Carnaval', $carnaval2, "Feriado Nacional"); - $this->holiday[] = new Holiday('Corpus Christ', $corpusChrist, "Feriado Nacional"); - $this->holiday[] = new Holiday('Dia das mães', $dia_maes, "Dia Convencional"); - $this->holiday[] = new Holiday('Dia dos Pais', $dia_pais, "Dia Convencional"); + $this->holiday[] = new Holiday('Páscoa', $pascoa, $fnacional); + $this->holiday[] = new Holiday('Sexta-feira Santa', $sexta_santa, $fnacional); + $this->holiday[] = new Holiday('Carnaval', $carnaval1, $fnacional); + $this->holiday[] = new Holiday('Carnaval', $carnaval2, $fnacional); + $this->holiday[] = new Holiday('Corpus Christ', $corpusChrist, $fnacional); + $this->holiday[] = new Holiday('Dia das mães', $dia_maes, $fnacional); + $this->holiday[] = new Holiday('Dia dos Pais', $dia_pais, $fnacional); } public function isHoliday(DateTime $dateToCheck)