Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/bo3bdo/holidays
Browse files Browse the repository at this point in the history
  • Loading branch information
bo3bdo committed Jan 31, 2024
2 parents 4e5e083 + acc1c47 commit a366693
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/Countries/Moldova.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Moldova extends Country
{
public function countryCode(): string
{
return 'md';
}

protected function allHolidays(int $year): array
{
return array_merge([
'Anul Nou' => '01-01',
'Crăciunul pe stil vechi' => '01-07',
'A doua zi de Crăciun pe stil vechi' => '01-08',
'Ziua Internațională a Femeii' => '03-08',
'Ziua Muncii' => '05-01',
'Ziua Europei' => '05-09',
'Ziua Internațională a Copilului' => '06-01',
'Ziua Independenței' => '08-27',
'Ziua Limbii Române' => '08-31',
'Crăciunul pe stil nou' => '12-25',
], $this->variableHolidays($year));
}

/** @return array<string, CarbonImmutable> */
protected function variableHolidays(int $year): array
{
$easter = $this->orthodoxEaster($year);

return [
'Prima zi de Paște' => $easter,
'A doua zi de Paște' => $easter->addDay(),
'Paștele Blajinilor' => $easter->addDays(8),
];
}
}
42 changes: 42 additions & 0 deletions src/Countries/Slovenia.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Slovenia extends Country
{
public function countryCode(): string
{
return 'si';
}

protected function allHolidays(int $year): array
{

return array_merge([
'Novo leto' => '01-01', // New Year's Day
'Novo leto 2' => '01-02', // New Year's Day, yes it's a second day
'Prešernov dan, slovenski kulturni praznik' => '08-02', // Prešeren Day, Slovenian Cultural Holiday
'Dan upora proti okupatorju' => '04-27', // Day of Uprising Against Occupation
'Praznik dela' => '05-01', // Labour Day
'Praznik dela 2' => '05-02', // Labour Day, yes it's a second day
'Dan državnosti' => '06-25', // Statehood Day
'Marijino vnebovzetje' => '08-15', // Assumption of Mary
'Dan reformacije' => '10-31', // Reformation Day
'Dan spomina na mrtve' => '11-01', // Remembrance Day
'Božič' => '12-25', // Christmas Day
'Dan samostojnosti in enotnosti' => '12-26', // Independence and Unity Day
], $this->variableHolidays($year));
}

/** @return array<string, CarbonImmutable> */
protected function variableHolidays(int $year): array
{
$easter = $this->easter($year);

return [
'Velikonočni ponedeljek' => $easter->addDay(), // Easter Monday
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"name": "Anul Nou",
"date": "2024-01-01"
},
{
"name": "Cr\u0103ciunul pe stil vechi",
"date": "2024-01-07"
},
{
"name": "A doua zi de Cr\u0103ciun pe stil vechi",
"date": "2024-01-08"
},
{
"name": "Ziua Interna\u021bional\u0103 a Femeii",
"date": "2024-03-08"
},
{
"name": "Ziua Muncii",
"date": "2024-05-01"
},
{
"name": "Prima zi de Pa\u0219te",
"date": "2024-05-05"
},
{
"name": "A doua zi de Pa\u0219te",
"date": "2024-05-06"
},
{
"name": "Ziua Europei",
"date": "2024-05-09"
},
{
"name": "Pa\u0219tele Blajinilor",
"date": "2024-05-13"
},
{
"name": "Ziua Interna\u021bional\u0103 a Copilului",
"date": "2024-06-01"
},
{
"name": "Ziua Independen\u021bei",
"date": "2024-08-27"
},
{
"name": "Ziua Limbii Rom\u00e2ne",
"date": "2024-08-31"
},
{
"name": "Cr\u0103ciunul pe stil nou",
"date": "2024-12-25"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"name": "Novo leto",
"date": "2024-01-01"
},
{
"name": "Novo leto 2",
"date": "2024-01-02"
},
{
"name": "Velikono\u010dni ponedeljek",
"date": "2024-04-01"
},
{
"name": "Dan upora proti okupatorju",
"date": "2024-04-27"
},
{
"name": "Praznik dela",
"date": "2024-05-01"
},
{
"name": "Praznik dela 2",
"date": "2024-05-02"
},
{
"name": "Dan dr\u017eavnosti",
"date": "2024-06-25"
},
{
"name": "Pre\u0161ernov dan, slovenski kulturni praznik",
"date": "2024-08-02"
},
{
"name": "Marijino vnebovzetje",
"date": "2024-08-15"
},
{
"name": "Dan reformacije",
"date": "2024-10-31"
},
{
"name": "Dan spomina na mrtve",
"date": "2024-11-01"
},
{
"name": "Bo\u017ei\u010d",
"date": "2024-12-25"
},
{
"name": "Dan samostojnosti in enotnosti",
"date": "2024-12-26"
}
]
19 changes: 19 additions & 0 deletions tests/Countries/MoldovaTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Spatie\Holidays\Tests\Countries;

use Carbon\CarbonImmutable;
use Spatie\Holidays\Holidays;

it('can calculate moldavian holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

$holidays = Holidays::for(country: 'md')->get();

expect($holidays)
->toBeArray()
->not()->toBeEmpty();

expect(formatDates($holidays))->toMatchSnapshot();

});
18 changes: 18 additions & 0 deletions tests/Countries/SloveniaTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Spatie\Holidays\Tests\Countries;

use Carbon\CarbonImmutable;
use Spatie\Holidays\Holidays;

it('can calculate slovenian holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

$holidays = Holidays::for(country: 'si')->get();

expect($holidays)
->toBeArray()
->not()->toBeEmpty();

expect(formatDates($holidays))->toMatchSnapshot();
});

0 comments on commit a366693

Please sign in to comment.