Skip to content

Commit

Permalink
fixes for Sweden
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielsvanpach committed Feb 1, 2024
1 parent 6c140a5 commit 32a94ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ parameters:
count: 1
path: src/Countries/Country.php

-
message: "#^Cannot call method startOfDay\\(\\) on Carbon\\\\CarbonImmutable\\|false\\.$#"
count: 2
path: src/Countries/Sweden.php

-
message: "#^Cannot call method setTimeStamp\\(\\) on DateTime\\|false\\.$#"
count: 1
Expand Down
11 changes: 5 additions & 6 deletions src/Countries/Sweden.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;
use Carbon\CarbonInterface;

class Sweden extends Country
{
Expand All @@ -28,18 +29,16 @@ protected function variableHolidays(int $year): array
{
$easter = $this->easter($year);

/** @var CarbonImmutable $midsummerDay */
$midsummerDay = CarbonImmutable::createFromFormat('Y-m-d', "{$year}-06-20");
$midsummerDay = CarbonImmutable::createFromFormat('Y-m-d', "{$year}-06-20")->startOfDay();

if (! $midsummerDay->isSaturday()) {
$midsummerDay = $midsummerDay->next(CarbonImmutable::SATURDAY);
$midsummerDay = $midsummerDay->next(CarbonInterface::SATURDAY);
}

/** @var CarbonImmutable $halloween */
$halloween = CarbonImmutable::createFromFormat('Y-m-d', "{$year}-10-31");
$halloween = CarbonImmutable::createFromFormat('Y-m-d', "{$year}-10-31")->startOfDay();

if (! $halloween->isSaturday()) {
$halloween = $halloween->next(CarbonImmutable::SATURDAY);
$halloween = $halloween->next(CarbonInterface::SATURDAY);
}

return [
Expand Down

0 comments on commit 32a94ff

Please sign in to comment.