Skip to content

Commit

Permalink
Update Holiday.php
Browse files Browse the repository at this point in the history
  • Loading branch information
gs-nasc authored Jan 28, 2021
1 parent 8e4e951 commit 80691cb
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Holiday.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 80691cb

Please sign in to comment.