[php-src] Issue #12052: Time Zone Un-Abbreviated Names
| From: | jack-worman | Date: | Sat, 26 Aug 2023 00:41:48 +0000 |
| Subject: | [php-src] Issue #12052: Time Zone Un-Abbreviated Names | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245247@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/12052
Author: jack-worman
### Description
Currently, there is only support for abbreviated time zone names. To get the un-abbreviated time
zone name, I have to maintain my own mappings:
```php
const TIME_ZONE_ABBREVIATION_TO_NAME_MAP = [
'HDT' => 'Hawaii-Aleutian Daylight Time',
'HST' => 'Hawaii Standard Time',
'AKDT' => 'Alaska Daylight Time',
'AKST' => 'Alaska Standard Time',
'MDT' => 'Mountain Daylight Time',
'MST' => 'Mountain Standard Time',
'CDT' => 'Central Daylight Time',
'CST' => 'Central Standard Time',
'EDT' => 'Eastern Daylight Time',
'EST' => 'Eastern Standard Time',
'PDT' => 'Pacific Daylight Time',
'PST' => 'Pacific Standard Time',
'AST' => 'Atlantic Standard Time',
'ChST' => 'Chamorro Standard Time',
// ...
];
```
Of course, this is not optimal.
I am requesting that
DateTimeInterface::format() and related functions have a format
character for the un-abbreviated time zone and DateTimeZone::getTransitions() adds an
"un-abbr" offset to the list of transitions returned.
```php
$timeZone = new \DateTimeZone('America/Chicago');
$dateTime = new \DateTimeImmutable('2023-08-25', timezone: $timeZone);
echo $dateTime->format('T') . "\n"; // CDT
// Feature request: Un-abbreviated time zone format ("Q" is just an arbitrary chose)
echo $dateTime->format('Q') . "\n"; // Central Daylight Time
// Feature request: Add "un-abbr" offset to transitions
$transition = $timeZone->getTransitions($dateTime->getTimestamp())[0];
var_export($transition);
//array (
// 'ts' => 1692939600,
// 'time' => '2023-08-25T05:00:00+00:00',
// 'offset' => -18000,
// 'isdst' => true,
// 'abbr' => 'CDT',
// 'un-abbr' => 'Central Daylight Time',
//)
```