Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Moldavian Holidays #95

Merged
merged 11 commits into from
Jan 31, 2024
40 changes: 40 additions & 0 deletions src/Countries/Moldova.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?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),
];
}
}
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"
}
]
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();

});