This commit is contained in:
User
2025-01-04 13:02:50 -05:00
parent da807296f3
commit 489e054614
20 changed files with 377 additions and 61 deletions

41
app/Helper/Timezones.php Normal file
View File

@@ -0,0 +1,41 @@
<?php
namespace App\Helper;
use DateTimeZone;
class Timezones
{
public function groups(): array
{
return ['Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Australia', 'Europe', 'Indian', 'Pacific', 'UTC'];
}
public function locations(string $group): array
{
return DateTimeZone::listIdentifiers(DateTimeZone::{strtoupper($group)});
}
public function toArray(): array
{
$tzForSelect = [];
foreach (DateTimeZone::listIdentifiers() as $timezone) {
$tz = explode('/', $timezone);
if (!isset($tz[1])) {
$tzForSelect['UTC']['UTC'] = 'UTC';
} else {
if (isset($tz[2])) {
$tzForSelect[$tz[0]][$tz[1]] = $tz[1]."/".$tz[2];
} else {
$tzForSelect[$tz[0]][$timezone] = $tz[1];
}
}
}
return $tzForSelect;
}
}