Skip to content

Commit

Permalink
handle invalid timezones Australia/ACT and Europe/Kiev - fixes azuyal…
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpapst committed Aug 19, 2024
1 parent e7b3392 commit 05a7106
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Yasumi/Provider/Australia/AustralianCapitalTerritory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ class AustralianCapitalTerritory extends Australia
*/
public const ID = 'AU-ACT';

public string $timezone = 'Australia/ACT';
/**
* This was "Australia/ACT" in the past, which is only a link to Australia/Sydney.
* In recent versions of PHP "Australia/ACT" was removed, so this is no longer the link version.
*
* @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
*/
public string $timezone = 'Australia/Sydney';

/**
* Initialize holidays for Australian Capital Territory (Australia).
Expand Down
11 changes: 10 additions & 1 deletion src/Yasumi/Provider/Ukraine.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ class Ukraine extends AbstractProvider
*/
public function initialize(): void
{
$this->timezone = 'Europe/Kiev';
// the name of the timezone changed at some point and some systems support both names,
// while others only support the old or the new one -> try out, which version is actually working
try {
new \DateTimeZone('Europe/Kiev');
$this->timezone = 'Europe/Kiev';
} catch (\Exception $e) {
// this is an DateInvalidTimeZoneException only since 8.3
// see https://www.php.net/manual/en/datetimezone.construct.php
$this->timezone = 'Europe/Kyiv';
}

// Add common holidays
// New Years Day will not be substituted to an monday if it's on a weekend!
Expand Down

0 comments on commit 05a7106

Please sign in to comment.