-
-
Notifications
You must be signed in to change notification settings - Fork 199
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 UK bank holidays #75
Conversation
I don't think the Christmas/Boxing day is correct. It looks like if Christmas Day is Sunday, Boxing Day stays as Monday and Christmas (substitute) is moved to Tuesday. An example can be seen for 2022 on https://www.gov.uk/bank-holidays |
Thanks @nebarg, that is correct. If Christmas is on a Friday, Boxing Day is a substitute day on the Monday |
Have included England, and will add Scotland and NI. |
Just to say that I believe GB was the correct country code. The readme references iso codes (although it doesn't specify which one). Assuming this means ISO 3166-2 the correct country codes are: GB-ENG for England (BS 6879 also allows GB-CYM for Wales, but ISO 3166-2 doesn't allow double coding, so this isn't formally part of ISO 3166-2 though most implementations allow both.) |
protected function christmasDay(int $year): array | ||
{ | ||
$christmasDay = new CarbonImmutable($year . "-12-25", 'Europe/London'); | ||
$key = 'Christmas Day'; | ||
|
||
if ($christmasDay->isSaturday()) { | ||
$key .= ' (substitute day)'; | ||
$christmasDay = $christmasDay->next('monday'); | ||
} | ||
|
||
if ($christmasDay->isSunday()) { | ||
$key .= ' (substitute day)'; | ||
$christmasDay = $christmasDay->next('tuesday'); | ||
} | ||
|
||
return [$key => $christmasDay]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great thought for this scenario.
Is it possible you move chrismas, boxing and new year to a generic file so other countries can inherit it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 😊
I'm not sure about this as different countries might have different rules when either fall on a weekend.
I switched it because NI isn't in Great Britain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for your work on this! Could you also solve the phpstan issues?
Did you verify the generated results in the snapshots?
src/Countries/NorthernIreland.php
Outdated
/** @return array<string, CarbonImmutable> */ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
$easterSunday = CarbonImmutable::createFromTimestamp(easter_date($year)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use $this->easter($year)
instead? Available after having your fork in sync & rebasing your branch on our main branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also for the other usages of easter_date() ofcourse
I think something went wrong while rebasing: 115 updated files. |
I have opened a new PR request #162 to fix the rebase issue. |
This adds bank holidays for Wales, England, Scotland and Northern Ireland.
If a bank holiday is on a weekend, a ‘substitute’ weekday becomes a bank holiday, normally the following Monday.
https://www.gov.uk/bank-holidays
Country codes
Wales: gb-cym
Scotland: gb-sct
Northern Ireland: gb-nir
England: gb-eng