Intl MessageFormatter using incorrect timezone
Nobody has claimed this yet.
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
Description
The following code:
<?php
\Locale::setDefault('en-CA');
date_default_timezone_set('America/Edmonton');
$now = new \DateTime();
echo "DateFormatter - [" . \IntlDateFormatter::formatObject($now, [\IntlDateFormatter::FULL, \IntlDateFormatter::FULL]) . "]\n";
echo "Singular - [" . \MessageFormatter::formatMessage(
\Locale::getDefault(),
'{0, date, full} - {0, time, full}',
[$now]
) . "]\n";
echo "Plural - [" . \MessageFormatter::formatMessage(
\Locale::getDefault(),
'{0, plural,
=0 {{1, date, full} - {1, time, full}.}
other {{1, date, full} - {1, time, full}}
}',
[1, $now]
) . "]\n";
?>
Resulted in this output:
DateFormatter - [Friday, March 4, 2022 at 1:28:49 p.m. Mountain Standard Time]
Singular - [Friday, March 4, 2022 - 1:28:49 p.m. Mountain Standard Time]
Plural - [Friday, March 4, 2022 - 8:28:49 p.m. Coordinated Universal Time]
But I expected this output instead:
Plural ICU format to MessageFormatter should return the same as that shown by Singular but it seems to be ignoring the default timezone set using date_default_timezone_set() and defaulting to server timezone of UTC when using the Plural form of ICU.
PHP Version
PHP 8.1.3
Operating System
Ubuntu 18.04.6 LTS
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No documentation file or test is named. Start by reproducing the supplied PHP 8.1.3 example, comparing IntlDateFormatter, singular MessageFormatter, and plural MessageFormatter output after date_default_timezone_set('America/Edmonton'); done means establishing whether the behavior needs documentation or should be reported to the PHP implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation, internationalization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100