Skip to content

Commit 7d95217

Browse files
committed
[Intl][Form] Update tests, TimeZoneTransformer, and DateTimeToLocalizedStringTransformer for the GMT and UTC split in ICU
The [GMT timezone has been split from the UTC](http://site.icu-project.org/download/59) timezone [in CLDR](http://cldr.unicode.org/index/downloads/cldr-31) (which ICU is based on). For example, the code blow: * before ICU 59.1 would return "GMT" in all cases * with ICU 59.1 it returns "UTC" for the first three ('z', 'zz', 'zzz') and "Coordinated Universal Time" for the last two ('zzzz', 'zzzzz'). ```php foreach (['z', 'zz', 'zzz', 'zzzz', 'zzzzz'] as $pattern) { $formatter = new \IntlDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, new \DateTimeZone('UTC'), IntlDateFormatter::GREGORIAN, $pattern); var_dump($formatter->format(new \DateTime('@0'))); } ``` Similarly Form's `DateTimeToLocalizedStringTransformer` is also affected: ```php $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::FULL); var_dump($transformer->transform(new \DateTime('2010-02-03 04:05:06 UTC'))); // ICU 58.2: '03.02.2010, 04:05:06 GMT' // ICU 59.1: '03.02.2010, 04:05:06 Koordinierte Weltzeit' ``` Refer to added and modified test cases for more changes. I split this PR in two commits for easier review. First commit updates ICU data (generated files), the second updates code and test cases to be compatible with updated data.
1 parent aec55f4 commit 7d95217

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@ public function dataProvider()
6161
array(\IntlDateFormatter::FULL, \IntlDateFormatter::NONE, null, 'Mittwoch, 3. Februar 2010', '2010-02-03 00:00:00 UTC'),
6262
array(null, \IntlDateFormatter::SHORT, null, '03.02.2010, 04:05', '2010-02-03 04:05:00 UTC'),
6363
array(null, \IntlDateFormatter::MEDIUM, null, '03.02.2010, 04:05:06', '2010-02-03 04:05:06 UTC'),
64-
array(null, \IntlDateFormatter::LONG, null, '03.02.2010, 04:05:06 GMT', '2010-02-03 04:05:06 UTC'),
64+
array(null, \IntlDateFormatter::LONG, null, '03.02.2010, 04:05:06 UTC', '2010-02-03 04:05:06 UTC'),
65+
array(null, \IntlDateFormatter::LONG, null, '03.02.2010, 04:05:06 UTC', '2010-02-03 04:05:06 GMT'),
6566
// see below for extra test case for time format FULL
6667
array(\IntlDateFormatter::NONE, \IntlDateFormatter::SHORT, null, '04:05', '1970-01-01 04:05:00 UTC'),
6768
array(\IntlDateFormatter::NONE, \IntlDateFormatter::MEDIUM, null, '04:05:06', '1970-01-01 04:05:06 UTC'),
68-
array(\IntlDateFormatter::NONE, \IntlDateFormatter::LONG, null, '04:05:06 GMT', '1970-01-01 04:05:06 UTC'),
69+
array(\IntlDateFormatter::NONE, \IntlDateFormatter::LONG, null, '04:05:06 UTC', '1970-01-01 04:05:06 GMT'),
70+
array(\IntlDateFormatter::NONE, \IntlDateFormatter::LONG, null, '04:05:06 UTC', '1970-01-01 04:05:06 UTC'),
6971
array(null, null, 'yyyy-MM-dd HH:mm:00', '2010-02-03 04:05:00', '2010-02-03 04:05:00 UTC'),
7072
array(null, null, 'yyyy-MM-dd HH:mm', '2010-02-03 04:05', '2010-02-03 04:05:00 UTC'),
7173
array(null, null, 'yyyy-MM-dd HH', '2010-02-03 04', '2010-02-03 04:00:00 UTC'),
@@ -85,6 +87,9 @@ public function dataProvider()
8587
*/
8688
public function testTransform($dateFormat, $timeFormat, $pattern, $output, $input)
8789
{
90+
IntlTestHelper::requireFullIntl($this, '59.1');
91+
\Locale::setDefault('de_AT');
92+
8893
$transformer = new DateTimeToLocalizedStringTransformer(
8994
'UTC',
9095
'UTC',
@@ -101,9 +106,12 @@ public function testTransform($dateFormat, $timeFormat, $pattern, $output, $inpu
101106

102107
public function testTransformFullTime()
103108
{
109+
IntlTestHelper::requireFullIntl($this, '59.1');
110+
\Locale::setDefault('de_AT');
111+
104112
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::FULL);
105113

106-
$this->assertEquals('03.02.2010, 04:05:06 GMT', $transformer->transform($this->dateTime));
114+
$this->assertEquals('03.02.2010, 04:05:06 Koordinierte Weltzeit', $transformer->transform($this->dateTime));
107115
}
108116

109117
public function testTransformToDifferentLocale()

0 commit comments

Comments
 (0)