Skip to content

Commit

Permalink
Belarus Holidays (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jampire authored Jan 25, 2024
1 parent 076b619 commit 0acd603
Show file tree
Hide file tree
Showing 9 changed files with 296 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lang/belarus/be-latn/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Новы год": "Novy hod",
"Новы год (другі дзень)": "Novy hod (druhi dzień)",
"Нараджэнне Хрыстова (праваслаўнае Раство)": "Naradžeńnie Chrystova (pravasłaŭnaje Rastvo)",
"Дзень жанчын": "Dzień žančyn",
"Свята працы": "Sviata pracy",
"Дзень Перамогі": "Dzień Pieramohi",
"Дзень Незалежнасці": "Dzień Niezaležnaści",
"Дзень Кастрычніцкай рэвалюцыі": "Dzień Kastryčnickaj revalucyi",
"Нараджэнне Хрыстова (каталіцкае Раство)": "Naradžeńnie Chrystova (katalickaje Rastvo)",
"Радаўніца": "Radaŭnica"
}
12 changes: 12 additions & 0 deletions lang/belarus/en/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Новы год": "New Year's Day",
"Новы год (другі дзень)": "New Year's Day (second day)",
"Нараджэнне Хрыстова (праваслаўнае Раство)": "Orthodox Christmas",
"Дзень жанчын": "Women's Day",
"Свята працы": "Labor Day",
"Дзень Перамогі": "Victory Day",
"Дзень Незалежнасці": "Independence Day",
"Дзень Кастрычніцкай рэвалюцыі": "October Revolution Day",
"Нараджэнне Хрыстова (каталіцкае Раство)": "Catholic Christmas",
"Радаўніца": "Radaunitsa"
}
12 changes: 12 additions & 0 deletions lang/belarus/ru/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Новы год": "Новый год",
"Новы год (другі дзень)": "Новый год (второй день)",
"Нараджэнне Хрыстова (праваслаўнае Раство)": "Православное Рождество",
"Дзень жанчын": "Международный женский день",
"Свята працы": "День труда",
"Дзень Перамогі": "День Победы",
"Дзень Незалежнасці": "День Независимости",
"Дзень Кастрычніцкай рэвалюцыі": "День Октябрьской революции",
"Нараджэнне Хрыстова (каталіцкае Раство)": "Католическое Рождество",
"Радаўніца": "Радуница"
}
38 changes: 38 additions & 0 deletions src/Countries/Belarus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Belarus extends Country
{
public function countryCode(): string
{
return 'by';
}

protected function allHolidays(int $year): array
{
return array_merge([
'Новы год' => '01-01',
'Новы год (другі дзень)' => '01-02',
'Нараджэнне Хрыстова (праваслаўнае Раство)' => '01-07',
'Дзень жанчын' => '03-08',
'Свята працы' => '05-01',
'Дзень Перамогі' => '05-09',
'Дзень Незалежнасці' => '07-03',
'Дзень Кастрычніцкай рэвалюцыі' => '11-07',
'Нараджэнне Хрыстова (каталіцкае Раство)' => '12-25',
], $this->variableHolidays($year));
}

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

return [
'Радаўніца' => $easter->addDays(9),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"name": "\u041d\u043e\u0432\u044b \u0433\u043e\u0434",
"date": "2024-01-01"
},
{
"name": "\u041d\u043e\u0432\u044b \u0433\u043e\u0434 (\u0434\u0440\u0443\u0433\u0456 \u0434\u0437\u0435\u043d\u044c)",
"date": "2024-01-02"
},
{
"name": "\u041d\u0430\u0440\u0430\u0434\u0436\u044d\u043d\u043d\u0435 \u0425\u0440\u044b\u0441\u0442\u043e\u0432\u0430 (\u043f\u0440\u0430\u0432\u0430\u0441\u043b\u0430\u045e\u043d\u0430\u0435 \u0420\u0430\u0441\u0442\u0432\u043e)",
"date": "2024-01-07"
},
{
"name": "\u0414\u0437\u0435\u043d\u044c \u0436\u0430\u043d\u0447\u044b\u043d",
"date": "2024-03-08"
},
{
"name": "\u0421\u0432\u044f\u0442\u0430 \u043f\u0440\u0430\u0446\u044b",
"date": "2024-05-01"
},
{
"name": "\u0414\u0437\u0435\u043d\u044c \u041f\u0435\u0440\u0430\u043c\u043e\u0433\u0456",
"date": "2024-05-09"
},
{
"name": "\u0420\u0430\u0434\u0430\u045e\u043d\u0456\u0446\u0430",
"date": "2024-05-14"
},
{
"name": "\u0414\u0437\u0435\u043d\u044c \u041d\u0435\u0437\u0430\u043b\u0435\u0436\u043d\u0430\u0441\u0446\u0456",
"date": "2024-07-03"
},
{
"name": "\u0414\u0437\u0435\u043d\u044c \u041a\u0430\u0441\u0442\u0440\u044b\u0447\u043d\u0456\u0446\u043a\u0430\u0439 \u0440\u044d\u0432\u0430\u043b\u044e\u0446\u044b\u0456",
"date": "2024-11-07"
},
{
"name": "\u041d\u0430\u0440\u0430\u0434\u0436\u044d\u043d\u043d\u0435 \u0425\u0440\u044b\u0441\u0442\u043e\u0432\u0430 (\u043a\u0430\u0442\u0430\u043b\u0456\u0446\u043a\u0430\u0435 \u0420\u0430\u0441\u0442\u0432\u043e)",
"date": "2024-12-25"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"name": "Novy hod",
"date": "2024-01-01"
},
{
"name": "Novy hod (druhi dzie\u0144)",
"date": "2024-01-02"
},
{
"name": "Narad\u017ee\u0144nie Chrystova (pravas\u0142a\u016dnaje Rastvo)",
"date": "2024-01-07"
},
{
"name": "Dzie\u0144 \u017ean\u010dyn",
"date": "2024-03-08"
},
{
"name": "Sviata pracy",
"date": "2024-05-01"
},
{
"name": "Dzie\u0144 Pieramohi",
"date": "2024-05-09"
},
{
"name": "Rada\u016dnica",
"date": "2024-05-14"
},
{
"name": "Dzie\u0144 Niezale\u017ena\u015bci",
"date": "2024-07-03"
},
{
"name": "Dzie\u0144 Kastry\u010dnickaj revalucyi",
"date": "2024-11-07"
},
{
"name": "Narad\u017ee\u0144nie Chrystova (katalickaje Rastvo)",
"date": "2024-12-25"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"name": "New Year's Day",
"date": "2024-01-01"
},
{
"name": "New Year's Day (second day)",
"date": "2024-01-02"
},
{
"name": "Orthodox Christmas",
"date": "2024-01-07"
},
{
"name": "Women's Day",
"date": "2024-03-08"
},
{
"name": "Labor Day",
"date": "2024-05-01"
},
{
"name": "Victory Day",
"date": "2024-05-09"
},
{
"name": "Radaunitsa",
"date": "2024-05-14"
},
{
"name": "Independence Day",
"date": "2024-07-03"
},
{
"name": "October Revolution Day",
"date": "2024-11-07"
},
{
"name": "Catholic Christmas",
"date": "2024-12-25"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"name": "\u041d\u043e\u0432\u044b\u0439 \u0433\u043e\u0434",
"date": "2024-01-01"
},
{
"name": "\u041d\u043e\u0432\u044b\u0439 \u0433\u043e\u0434 (\u0432\u0442\u043e\u0440\u043e\u0439 \u0434\u0435\u043d\u044c)",
"date": "2024-01-02"
},
{
"name": "\u041f\u0440\u0430\u0432\u043e\u0441\u043b\u0430\u0432\u043d\u043e\u0435 \u0420\u043e\u0436\u0434\u0435\u0441\u0442\u0432\u043e",
"date": "2024-01-07"
},
{
"name": "\u041c\u0435\u0436\u0434\u0443\u043d\u0430\u0440\u043e\u0434\u043d\u044b\u0439 \u0436\u0435\u043d\u0441\u043a\u0438\u0439 \u0434\u0435\u043d\u044c",
"date": "2024-03-08"
},
{
"name": "\u0414\u0435\u043d\u044c \u0442\u0440\u0443\u0434\u0430",
"date": "2024-05-01"
},
{
"name": "\u0414\u0435\u043d\u044c \u041f\u043e\u0431\u0435\u0434\u044b",
"date": "2024-05-09"
},
{
"name": "\u0420\u0430\u0434\u0443\u043d\u0438\u0446\u0430",
"date": "2024-05-14"
},
{
"name": "\u0414\u0435\u043d\u044c \u041d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438",
"date": "2024-07-03"
},
{
"name": "\u0414\u0435\u043d\u044c \u041e\u043a\u0442\u044f\u0431\u0440\u044c\u0441\u043a\u043e\u0439 \u0440\u0435\u0432\u043e\u043b\u044e\u0446\u0438\u0438",
"date": "2024-11-07"
},
{
"name": "\u041a\u0430\u0442\u043e\u043b\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0420\u043e\u0436\u0434\u0435\u0441\u0442\u0432\u043e",
"date": "2024-12-25"
}
]
54 changes: 54 additions & 0 deletions tests/Countries/BelarusTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace Spatie\Holidays\Tests\Countries;

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

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

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

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

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

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

$holidays = Holidays::for(country: 'by', locale: 'en')->get();

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

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

it('can calculate belarus holidays in Belarus Lacinka', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

$holidays = Holidays::for(country: 'by', locale: 'be-latn')->get();

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

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

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

$holidays = Holidays::for(country: 'by', locale: 'ru')->get();

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

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

0 comments on commit 0acd603

Please sign in to comment.