Skip to content

Commit 05a7106

Browse files
committed
handle invalid timezones Australia/ACT and Europe/Kiev - fixes azuyalabs#342
1 parent e7b3392 commit 05a7106

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/Yasumi/Provider/Australia/AustralianCapitalTerritory.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ class AustralianCapitalTerritory extends Australia
3333
*/
3434
public const ID = 'AU-ACT';
3535

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

3844
/**
3945
* Initialize holidays for Australian Capital Territory (Australia).

src/Yasumi/Provider/Ukraine.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,16 @@ class Ukraine extends AbstractProvider
4848
*/
4949
public function initialize(): void
5050
{
51-
$this->timezone = 'Europe/Kiev';
51+
// the name of the timezone changed at some point and some systems support both names,
52+
// while others only support the old or the new one -> try out, which version is actually working
53+
try {
54+
new \DateTimeZone('Europe/Kiev');
55+
$this->timezone = 'Europe/Kiev';
56+
} catch (\Exception $e) {
57+
// this is an DateInvalidTimeZoneException only since 8.3
58+
// see https://www.php.net/manual/en/datetimezone.construct.php
59+
$this->timezone = 'Europe/Kyiv';
60+
}
5261

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

0 commit comments

Comments
 (0)