Skip to content

Commit

Permalink
add english holidays
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBarrettACT committed Jan 18, 2024
1 parent 56959a3 commit 7ad1f80
Show file tree
Hide file tree
Showing 7 changed files with 234 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Countries/England.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class England extends Wales
{
public function countryCode(): string
{
return 'en';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"name": "New Year's Day",
"date": "2024-01-01"
},
{
"name": "Good Friday",
"date": "2024-03-29"
},
{
"name": "Easter Monday",
"date": "2024-04-01"
},
{
"name": "Early May bank holiday",
"date": "2024-05-06"
},
{
"name": "Spring bank holiday",
"date": "2024-05-27"
},
{
"name": "Summer bank holiday",
"date": "2024-08-26"
},
{
"name": "Christmas Day",
"date": "2024-12-25"
},
{
"name": "Boxing Day",
"date": "2024-12-26"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"name": "New Year's Day",
"date": "2020-01-01"
},
{
"name": "Good Friday",
"date": "2020-04-10"
},
{
"name": "Easter Monday",
"date": "2020-04-13"
},
{
"name": "Early May bank holiday",
"date": "2020-05-04"
},
{
"name": "Spring bank holiday",
"date": "2020-05-25"
},
{
"name": "Summer bank holiday",
"date": "2020-08-31"
},
{
"name": "Christmas Day",
"date": "2020-12-25"
},
{
"name": "Boxing Day (substitute day)",
"date": "2020-12-28"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"name": "New Year's Day",
"date": "2021-01-01"
},
{
"name": "Good Friday",
"date": "2021-04-02"
},
{
"name": "Easter Monday",
"date": "2021-04-05"
},
{
"name": "Early May bank holiday",
"date": "2021-05-03"
},
{
"name": "Spring bank holiday",
"date": "2021-05-31"
},
{
"name": "Summer bank holiday",
"date": "2021-08-30"
},
{
"name": "Christmas Day (substitute day)",
"date": "2021-12-27"
},
{
"name": "Boxing Day (substitute day)",
"date": "2021-12-28"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"name": "New Year's Day (substitute day)",
"date": "2022-01-03"
},
{
"name": "Good Friday",
"date": "2022-04-15"
},
{
"name": "Easter Monday",
"date": "2022-04-18"
},
{
"name": "Early May bank holiday",
"date": "2022-05-02"
},
{
"name": "Spring bank holiday",
"date": "2022-05-30"
},
{
"name": "Summer bank holiday",
"date": "2022-08-29"
},
{
"name": "Boxing Day",
"date": "2022-12-26"
},
{
"name": "Christmas Day (substitute day)",
"date": "2022-12-27"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"name": "New Year's Day (substitute day)",
"date": "2033-01-03"
},
{
"name": "Good Friday",
"date": "2033-04-15"
},
{
"name": "Easter Monday",
"date": "2033-04-18"
},
{
"name": "Early May bank holiday",
"date": "2033-05-02"
},
{
"name": "Spring bank holiday",
"date": "2033-05-30"
},
{
"name": "Summer bank holiday",
"date": "2033-08-29"
},
{
"name": "Boxing Day",
"date": "2033-12-26"
},
{
"name": "Christmas Day (substitute day)",
"date": "2033-12-27"
}
]
51 changes: 51 additions & 0 deletions tests/Countries/EnglandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

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

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

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

expect($holidays)->toBeArray()->not()->toBeEmpty()
->and(formatDates($holidays))->toMatchSnapshot();

});

it('returns a substitute day if new years day falls on a weekend', function () {
CarbonImmutable::setTestNowAndTimezone('2033-01-01');

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

expect($holidays)->toBeArray()->not()->toBeEmpty()
->and(formatDates($holidays))->toMatchSnapshot();
});


it('can calculate english holidays if christmas is on a friday', function () {
CarbonImmutable::setTestNowAndTimezone('2020-01-01');

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

expect($holidays)->toBeArray()->not()->toBeEmpty()
->and(formatDates($holidays))->toMatchSnapshot();
});

it('can calculate english holidays if christmas is on a saturday', function () {
CarbonImmutable::setTestNowAndTimezone('2021-01-01');

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

expect($holidays)->toBeArray()->not()->toBeEmpty()
->and(formatDates($holidays))->toMatchSnapshot();
});

it('can calculate english holidays if christmas is on a sunday', function () {
CarbonImmutable::setTestNowAndTimezone('2022-01-01');

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

expect($holidays)->toBeArray()->not()->toBeEmpty()
->and(formatDates($holidays))->toMatchSnapshot();
});

0 comments on commit 7ad1f80

Please sign in to comment.