Skip to content

Commit

Permalink
Merge branch '2.7' into 2.8
Browse files Browse the repository at this point in the history
* 2.7:
  [Intl][Form] Update tests, TimeZoneTransformer, and DateTimeToLocalizedStringTransformer for the GMT and UTC split in ICU
  [Intl] Update ICU data to 59.1
  • Loading branch information
fabpot committed May 15, 2017
2 parents 6ef78ec + c4abc15 commit b8c9597
Show file tree
Hide file tree
Showing 921 changed files with 1,471 additions and 1,094 deletions.
Expand Up @@ -61,11 +61,13 @@ public function dataProvider()
array(\IntlDateFormatter::FULL, \IntlDateFormatter::NONE, null, 'Mittwoch, 3. Februar 2010', '2010-02-03 00:00:00 UTC'),
array(null, \IntlDateFormatter::SHORT, null, '03.02.2010, 04:05', '2010-02-03 04:05:00 UTC'),
array(null, \IntlDateFormatter::MEDIUM, null, '03.02.2010, 04:05:06', '2010-02-03 04:05:06 UTC'),
array(null, \IntlDateFormatter::LONG, null, '03.02.2010, 04:05:06 GMT', '2010-02-03 04:05:06 UTC'),
array(null, \IntlDateFormatter::LONG, null, '03.02.2010, 04:05:06 UTC', '2010-02-03 04:05:06 UTC'),
array(null, \IntlDateFormatter::LONG, null, '03.02.2010, 04:05:06 UTC', '2010-02-03 04:05:06 GMT'),
// see below for extra test case for time format FULL
array(\IntlDateFormatter::NONE, \IntlDateFormatter::SHORT, null, '04:05', '1970-01-01 04:05:00 UTC'),
array(\IntlDateFormatter::NONE, \IntlDateFormatter::MEDIUM, null, '04:05:06', '1970-01-01 04:05:06 UTC'),
array(\IntlDateFormatter::NONE, \IntlDateFormatter::LONG, null, '04:05:06 GMT', '1970-01-01 04:05:06 UTC'),
array(\IntlDateFormatter::NONE, \IntlDateFormatter::LONG, null, '04:05:06 UTC', '1970-01-01 04:05:06 GMT'),
array(\IntlDateFormatter::NONE, \IntlDateFormatter::LONG, null, '04:05:06 UTC', '1970-01-01 04:05:06 UTC'),
array(null, null, 'yyyy-MM-dd HH:mm:00', '2010-02-03 04:05:00', '2010-02-03 04:05:00 UTC'),
array(null, null, 'yyyy-MM-dd HH:mm', '2010-02-03 04:05', '2010-02-03 04:05:00 UTC'),
array(null, null, 'yyyy-MM-dd HH', '2010-02-03 04', '2010-02-03 04:00:00 UTC'),
Expand All @@ -85,6 +87,9 @@ public function dataProvider()
*/
public function testTransform($dateFormat, $timeFormat, $pattern, $output, $input)
{
IntlTestHelper::requireFullIntl($this, '59.1');
\Locale::setDefault('de_AT');

$transformer = new DateTimeToLocalizedStringTransformer(
'UTC',
'UTC',
Expand All @@ -101,9 +106,12 @@ public function testTransform($dateFormat, $timeFormat, $pattern, $output, $inpu

public function testTransformFullTime()
{
IntlTestHelper::requireFullIntl($this, '59.1');
\Locale::setDefault('de_AT');

$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::FULL);

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

public function testTransformToDifferentLocale()
Expand Down
Expand Up @@ -35,10 +35,29 @@ public function format(\DateTime $dateTime, $length)
throw new NotImplementedException('Time zone different than GMT or UTC is not supported as a formatting output.');
}

// From ICU >= 4.8, the zero offset is not more used, example: GMT instead of GMT+00:00
$format = (0 !== (int) $dateTime->format('O')) ? '\G\M\TP' : '\G\M\T';
if ('Etc' === $timeZone) {
// i.e. Etc/GMT+1, Etc/UTC, Etc/Zulu
$timeZone = substr($dateTime->getTimezone()->getName(), 4);
}

// From ICU >= 59.1 GMT and UTC are no longer unified
if (in_array($timeZone, array('UTC', 'UCT', 'Universal', 'Zulu'))) {
// offset is not supported with UTC
return $length > 3 ? 'Coordinated Universal Time' : 'UTC';
}

$offset = (int) $dateTime->format('O');

// From ICU >= 4.8, the zero offset is no more used, example: GMT instead of GMT+00:00
if (0 === $offset) {
return $length > 3 ? 'Greenwich Mean Time' : 'GMT';
}

if ($length > 3) {
return $dateTime->format('\G\M\TP');
}

return $dateTime->format($format);
return sprintf('GMT%s%d', ($offset >= 0 ? '+' : ''), $offset / 100);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Intl/README.md
Expand Up @@ -15,5 +15,7 @@ Resources
* [Report issues](https://github.com/symfony/symfony/issues) and
[send Pull Requests](https://github.com/symfony/symfony/pulls)
in the [main Symfony repository](https://github.com/symfony/symfony)
* [Docker images with intl support](https://hub.docker.com/r/jakzal/php-intl)
(for the Intl component development)

[0]: http://www.php.net/manual/en/intl.setup.php
1 change: 1 addition & 0 deletions src/Symfony/Component/Intl/Resources/bin/icu.ini
Expand Up @@ -14,3 +14,4 @@
55 = http://source.icu-project.org/repos/icu/icu/tags/release-55-1/source
57 = http://source.icu-project.org/repos/icu/icu/tags/release-57-1/source
58 = http://source.icu-project.org/repos/icu/tags/release-58-2/icu4c/source
59 = http://source.icu-project.org/repos/icu/tags/release-59-1/icu4c/source
4 changes: 2 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/currencies/af.json
@@ -1,5 +1,5 @@
{
"Version": "2.1.29.44",
"Version": "2.1.32.59",
"Names": {
"AED": [
"AED",
Expand Down Expand Up @@ -451,7 +451,7 @@
],
"PEN": [
"PEN",
"Peruaanse nuwe sol"
"Peruaanse sol"
],
"PGK": [
"PGK",
Expand Down
@@ -1,5 +1,5 @@
{
"Version": "2.1.27.40",
"Version": "2.1.31.33",
"Names": {
"NAD": [
"$",
Expand Down
@@ -1,5 +1,5 @@
{
"Version": "2.1.27.40",
"Version": "2.1.31.33",
"Names": {
"AED": [
"AED",
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/currencies/am.json
@@ -1,5 +1,5 @@
{
"Version": "2.1.28.79",
"Version": "2.1.32.59",
"Names": {
"AED": [
"AED",
Expand Down Expand Up @@ -439,7 +439,7 @@
],
"PEN": [
"PEN",
"የፔሩቪያ ኑኤቮ ሶል"
"የፔሩቪያ ሶል"
],
"PGK": [
"PGK",
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/currencies/ar.json
@@ -1,5 +1,5 @@
{
"Version": "2.1.28.79",
"Version": "2.1.32.86",
"Names": {
"ADP": [
"ADP",
Expand Down Expand Up @@ -647,7 +647,7 @@
],
"PEN": [
"PEN",
"سول جديد البيرو"
"سول البيرو"
],
"PGK": [
"PGK",
Expand Down
@@ -1,5 +1,5 @@
{
"Version": "2.1.27.40",
"Version": "2.1.31.33",
"Names": {
"DJF": [
"Fdj",
Expand Down
@@ -1,5 +1,5 @@
{
"Version": "2.1.27.40",
"Version": "2.1.31.33",
"Names": {
"ERN": [
"Nfk",
Expand Down
@@ -1,5 +1,5 @@
{
"Version": "2.1.27.40",
"Version": "2.1.31.33",
"Names": {
"SDG": [
"SDG",
Expand Down
@@ -1,5 +1,5 @@
{
"Version": "2.1.27.40",
"Version": "2.1.31.33",
"Names": {
"SOS": [
"S",
Expand Down
@@ -1,5 +1,5 @@
{
"Version": "2.1.27.40",
"Version": "2.1.31.33",
"Names": {
"GBP": [
"GB£",
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Intl/Resources/data/currencies/az.json
@@ -1,5 +1,5 @@
{
"Version": "2.1.28.79",
"Version": "2.1.32.59",
"Names": {
"ADP": [
"ADP",
Expand Down Expand Up @@ -703,11 +703,11 @@
],
"PEN": [
"PEN",
"Peru Nuevo Solu"
"Peru Solu"
],
"PES": [
"PES",
"Peru Solu"
"Peru Solu (1863–1965)"
],
"PGK": [
"PGK",
Expand Down
@@ -1,5 +1,5 @@
{
"Version": "2.1.27.40",
"Version": "2.1.31.74",
"Names": {
"AZN": [
"",
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/currencies/be.json
@@ -1,5 +1,5 @@
{
"Version": "2.1.29.66",
"Version": "2.1.31.86",
"Names": {
"AED": [
"AED",
Expand Down Expand Up @@ -423,7 +423,7 @@
],
"PEN": [
"PEN",
"перуанскі новы соль"
"перуанскі соль"
],
"PGK": [
"PGK",
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Intl/Resources/data/currencies/bg.json
@@ -1,5 +1,5 @@
{
"Version": "2.1.30.6",
"Version": "2.1.33.75",
"Names": {
"ADP": [
"ADP",
Expand Down Expand Up @@ -687,11 +687,11 @@
],
"PEN": [
"PEN",
"Перуански нов сол"
"Перуански сол"
],
"PES": [
"PES",
"Перуански сол"
"Перуански сол (1863–1965)"
],
"PGK": [
"PGK",
Expand Down
@@ -1,5 +1,5 @@
{
"Version": "2.1.27.40",
"Version": "2.1.31.33",
"Names": {
"AED": [
"AED",
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Intl/Resources/data/currencies/bn.json
@@ -1,5 +1,5 @@
{
"Version": "2.1.29.44",
"Version": "2.1.32.59",
"Names": {
"ADP": [
"ADP",
Expand Down Expand Up @@ -707,11 +707,11 @@
],
"PEN": [
"PEN",
"পেরুভিয়ান সোল নুয়েভো"
"পেরুভিয়ান সোল"
],
"PES": [
"PES",
"পেরুভিয়ান সোল"
"পেরুভিয়ান সোল (1863–1965)"
],
"PGK": [
"PGK",
Expand Down
@@ -1,5 +1,5 @@
{
"Version": "2.1.27.40",
"Version": "2.1.31.33",
"Names": {
"CNY": [
"¥",
Expand Down
@@ -1,5 +1,5 @@
{
"Version": "2.1.27.40",
"Version": "2.1.31.33",
"Names": {
"CNY": [
"CN¥",
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/currencies/br.json
@@ -1,5 +1,5 @@
{
"Version": "2.1.28.76",
"Version": "2.1.31.86",
"Names": {
"ADP": [
"ADP",
Expand Down Expand Up @@ -779,7 +779,7 @@
],
"PEN": [
"PEN",
"nuevo sol Perou"
"sol Perou"
],
"PES": [
"PES",
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/currencies/bs.json
@@ -1,5 +1,5 @@
{
"Version": "2.1.28.79",
"Version": "2.1.31.86",
"Names": {
"ADP": [
"ADP",
Expand Down Expand Up @@ -739,7 +739,7 @@
],
"PEN": [
"PEN",
"Peruanski novi sol"
"Peruanski sol"
],
"PES": [
"PES",
Expand Down
@@ -1,5 +1,5 @@
{
"Version": "2.1.28.76",
"Version": "2.1.32.72",
"Names": {
"ADP": [
"ADP",
Expand Down Expand Up @@ -715,11 +715,11 @@
],
"PEN": [
"PEN",
"Перуански нуево сол"
"Перуански сол"
],
"PES": [
"PES",
"Перуански сол"
"Перуански сол (1863–1965)"
],
"PGK": [
"PGK",
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Intl/Resources/data/currencies/ca.json
@@ -1,5 +1,5 @@
{
"Version": "2.1.28.79",
"Version": "2.1.32.59",
"Names": {
"ADP": [
"ADP",
Expand Down Expand Up @@ -772,11 +772,11 @@
],
"PEN": [
"PEN",
"nou sol peruà"
"sol peruà"
],
"PES": [
"PES",
"sol peruà"
"sol peruà (1863–1965)"
],
"PGK": [
"PGK",
Expand Down
@@ -1,5 +1,5 @@
{
"Version": "2.1.27.40",
"Version": "2.1.31.33",
"Names": {
"FRF": [
"F",
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/currencies/ce.json
@@ -1,5 +1,5 @@
{
"Version": "2.1.28.76",
"Version": "2.1.31.86",
"Names": {
"AED": [
"AED",
Expand Down Expand Up @@ -423,7 +423,7 @@
],
"PEN": [
"PEN",
"Перун керла соль"
"Перун соль"
],
"PGK": [
"PGK",
Expand Down

0 comments on commit b8c9597

Please sign in to comment.