Skip to content

Commit d694ac5

Browse files
committed
ICU-23517 Do not use GMT Zero Format.
1 parent 7132159 commit d694ac5

File tree

8 files changed

+16
-54
lines changed

8 files changed

+16
-54
lines changed

icu4c/source/i18n/tzfmt.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,12 +1559,6 @@ TimeZoneFormat::formatOffsetLocalizedGMT(int32_t offset, UBool isShort, UnicodeS
15591559
return result;
15601560
}
15611561

1562-
// Not using GMT zero format when long (ICU-23157)
1563-
if (offset == 0 && isShort) {
1564-
result.setTo(fGMTZeroFormat);
1565-
return result;
1566-
}
1567-
15681562
UBool positive = true;
15691563
if (offset < 0) {
15701564
offset = -offset;

icu4c/source/test/intltest/dtfmttst.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2858,7 +2858,7 @@ void DateFormatTest::TestTimeZoneDisplayName()
28582858

28592859
{ "de", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
28602860
{ "de", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+00:00", "+0:00" },
2861-
{ "de", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
2861+
{ "de", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT+0", "+0:00" },
28622862
{ "de", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "Mittlere Greenwich-Zeit", "+0:00" },
28632863
{ "de", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
28642864
{ "de", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+01:00", "+1:00" },
@@ -2962,9 +2962,9 @@ void DateFormatTest::TestTimeZoneDisplayName()
29622962

29632963
{ "zh", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
29642964
{ "zh", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+00:00", "+0:00" },
2965-
{ "zh", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
2965+
{ "zh", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT+0", "+0:00" },
29662966
{ "zh", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+00:00", "+0:00" },
2967-
{ "zh", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
2967+
{ "zh", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT+0", "+0:00" },
29682968
{ "zh", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "\\u683C\\u6797\\u5C3C\\u6CBB\\u6807\\u51C6\\u65F6\\u95F4", "+0:00" },
29692969
{ "zh", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
29702970
{ "zh", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+01:00", "+1:00" },
@@ -3067,7 +3067,7 @@ void DateFormatTest::TestTimeZoneDisplayName()
30673067

30683068
{ "hi", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
30693069
{ "hi", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+00:00", "+0:00" },
3070-
{ "hi", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
3070+
{ "hi", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT+0", "+0:00" },
30713071
{ "hi", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "\\u0917\\u094d\\u0930\\u0940\\u0928\\u0935\\u093f\\u091a \\u092e\\u0940\\u0928 \\u091f\\u093e\\u0907\\u092e", "+0:00" },
30723072
{ "hi", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
30733073
{ "hi", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+01:00", "+1:00" },
@@ -3171,7 +3171,7 @@ void DateFormatTest::TestTimeZoneDisplayName()
31713171

31723172
{ "bg", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
31733173
{ "bg", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u043D\\u0443\\u0438\\u0447+00:00", "+0:00" },
3174-
{ "bg", "Europe/London", "2004-01-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u043D\\u0443\\u0438\\u0447", "+0:00" },
3174+
{ "bg", "Europe/London", "2004-01-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u043D\\u0443\\u0438\\u0447+0", "+0:00" },
31753175
{ "bg", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "\\u0421\\u0440\\u0435\\u0434\\u043d\\u043e \\u0433\\u0440\\u0438\\u043d\\u0443\\u0438\\u0447\\u043a\\u043e \\u0432\\u0440\\u0435\\u043c\\u0435", "+0:00" },
31763176
{ "bg", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
31773177
{ "bg", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u043D\\u0443\\u0438\\u0447+01:00", "+1:00" },
@@ -3276,7 +3276,7 @@ void DateFormatTest::TestTimeZoneDisplayName()
32763276

32773277
{ "ja", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
32783278
{ "ja", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+00:00", "+0:00" },
3279-
{ "ja", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
3279+
{ "ja", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT+0", "+0:00" },
32803280
{ "ja", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "\\u30B0\\u30EA\\u30CB\\u30C3\\u30B8\\u6A19\\u6E96\\u6642", "+0:00" },
32813281
{ "ja", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
32823282
{ "ja", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+01:00", "+1:00" },
@@ -3379,7 +3379,7 @@ void DateFormatTest::TestTimeZoneDisplayName()
33793379

33803380
{ "ti", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
33813381
{ "ti", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+00:00", "+0:00" },
3382-
{ "ti", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
3382+
{ "ti", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT+0", "+0:00" },
33833383
{ "ti", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "GMT", "+0:00" },
33843384
{ "ti", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
33853385
{ "ti", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+01:00", "+1:00" },

icu4c/source/test/intltest/tzfmttst.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,6 @@ TimeZoneFormatTest::TestTimeZoneRoundTrip() {
181181
)) {
182182
continue;
183183
}
184-
UnicodeString localShortGMTString;
185-
SimpleDateFormat shortGmtFmt(UnicodeString("O"), LOCALES[locidx], status);
186-
if (U_FAILURE(status)) {
187-
dataerrln("Error creating SimpleDateFormat - %s", u_errorName(status));
188-
continue;
189-
}
190-
shortGmtFmt.setTimeZone(*TimeZone::getGMT());
191-
shortGmtFmt.format(0.0, localShortGMTString);
192184

193185
for (int32_t patidx = 0; patidx < UPRV_LENGTHOF(PATTERNS); patidx++) {
194186
SimpleDateFormat* sdf = new SimpleDateFormat(UnicodeString(PATTERNS[patidx]), LOCALES[locidx], status);
@@ -199,15 +191,6 @@ TimeZoneFormatTest::TestTimeZoneRoundTrip() {
199191
continue;
200192
}
201193

202-
UnicodeString* localGMTString = nullptr;
203-
if (uprv_strcmp(PATTERNS[patidx], "z") == 0
204-
|| uprv_strcmp(PATTERNS[patidx],"Z") == 0
205-
|| uprv_strcmp(PATTERNS[patidx],"v") == 0
206-
|| uprv_strcmp(PATTERNS[patidx],"V") == 0
207-
|| uprv_strcmp(PATTERNS[patidx],"O") == 0) {
208-
localGMTString = &localShortGMTString;
209-
}
210-
211194
tzids->reset(status);
212195
const UnicodeString *tzid;
213196
while ((tzid = tzids->snext(status))) {
@@ -340,7 +323,7 @@ TimeZoneFormatTest::TestTimeZoneRoundTrip() {
340323
}
341324
isOffsetFormat = (numDigits > 0);
342325
}
343-
if (isOffsetFormat || (localGMTString != nullptr && localGMTString->compare(tzstr) == 0)) {
326+
if (isOffsetFormat) {
344327
// Localized GMT or ISO: total offset (raw + dst) must be preserved.
345328
int32_t inOffset = inRaw + inDst;
346329
int32_t outOffset = outRaw + outDst;

icu4c/source/test/testdata/format.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ format:table(nofallback) {
149149
"GMT",
150150
"DATE=RELATIVE_FULL,TIME=LONG",
151151
"ERA=1,YEAR=2012,MONTH=OCTOBER,DATE=8,HOUR_OF_DAY=23,MINUTE=59,SECOND=0",
152-
"segunda-feira, 8 de outubro de 2012 23:59:00 GMT"
152+
"segunda-feira, 8 de outubro de 2012 23:59:00 GMT+0"
153153
},
154154
// vi combined formats have time first
155155
{

icu4j/main/common_tests/src/test/java/com/ibm/icu/dev/test/format/DateFormatTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ public void TestTimeZoneInLocale() {
10711071

10721072
{ "de", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
10731073
{ "de", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+00:00", "+0:00" },
1074-
{ "de", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
1074+
{ "de", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT+0", "+0:00" },
10751075
{ "de", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "Mittlere Greenwich-Zeit", "+0:00" },
10761076
{ "de", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
10771077
{ "de", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+01:00", "+1:00" },
@@ -1175,7 +1175,7 @@ public void TestTimeZoneInLocale() {
11751175

11761176
{ "zh", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
11771177
{ "zh", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", GMT_ZH+"+00:00", "+0:00" },
1178-
{ "zh", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
1178+
{ "zh", "Europe/London", "2004-01-15T00:00:00Z", "z", GMT_ZH+"+0", "+0:00" },
11791179
{ "zh", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "\u683C\u6797\u5C3C\u6CBB\u6807\u51C6\u65F6\u95F4", "+0:00" },
11801180
{ "zh", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
11811181
{ "zh", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", GMT_ZH+"+01:00", "+1:00" },
@@ -1278,7 +1278,7 @@ public void TestTimeZoneInLocale() {
12781278

12791279
{ "hi", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
12801280
{ "hi", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+00:00", "+0:00" },
1281-
{ "hi", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
1281+
{ "hi", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT+0", "+0:00" },
12821282
{ "hi", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "\u0917\u094d\u0930\u0940\u0928\u0935\u093f\u091a \u092e\u0940\u0928 \u091f\u093e\u0907\u092e", "+0:00" },
12831283
{ "hi", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
12841284
{ "hi", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+01:00", "+1:00" },
@@ -1382,7 +1382,7 @@ public void TestTimeZoneInLocale() {
13821382

13831383
{ "bg", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
13841384
{ "bg", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", GMT_BG+"+00:00", "+0:00" },
1385-
{ "bg", "Europe/London", "2004-01-15T00:00:00Z", "z", GMT_BG, "+0:00" },
1385+
{ "bg", "Europe/London", "2004-01-15T00:00:00Z", "z", GMT_BG+"+0", "+0:00" },
13861386
{ "bg", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "\u0421\u0440\u0435\u0434\u043d\u043e \u0433\u0440\u0438\u043d\u0443\u0438\u0447\u043a\u043e \u0432\u0440\u0435\u043c\u0435", "+0:00" },
13871387
{ "bg", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
13881388
{ "bg", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", GMT_BG+"+01:00", "+1:00" },
@@ -1489,7 +1489,7 @@ public void TestTimeZoneInLocale() {
14891489

14901490
{ "ja", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
14911491
{ "ja", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+00:00", "+0:00" },
1492-
{ "ja", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
1492+
{ "ja", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT+0", "+0:00" },
14931493
{ "ja", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "\u30B0\u30EA\u30CB\u30C3\u30B8\u6A19\u6E96\u6642", "+0:00" },
14941494
{ "ja", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
14951495
{ "ja", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+01:00", "+1:00" },
@@ -1595,7 +1595,7 @@ public void TestTimeZoneInLocale() {
15951595

15961596
{ "ti", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
15971597
{ "ti", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+00:00", "+0:00" },
1598-
{ "ti", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
1598+
{ "ti", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT+0", "+0:00" },
15991599
{ "ti", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "GMT", "+0:00" },
16001600
{ "ti", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
16011601
{ "ti", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+01:00", "+1:00" },

icu4j/main/common_tests/src/test/java/com/ibm/icu/dev/test/format/TimeZoneFormatTest.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,9 @@ public void TestTimeZoneRoundTrip() {
156156
}
157157
logln("Locale: " + LOCALES[locidx].toString());
158158

159-
String localShortGMTString = TimeZoneFormat.getInstance(LOCALES[locidx]).formatOffsetShortLocalizedGMT(0);
160-
161159
for (int patidx = 0; patidx < PATTERNS.length; patidx++) {
162160
logln(" pattern: " + PATTERNS[patidx]);
163161
SimpleDateFormat sdf = new SimpleDateFormat(PATTERNS[patidx], LOCALES[locidx]);
164-
String localGMTString = null;
165-
if (PATTERNS[patidx].equals("z")
166-
|| PATTERNS[patidx].equals("Z")
167-
|| PATTERNS[patidx].equals("v")
168-
|| PATTERNS[patidx].equals("V")
169-
|| PATTERNS[patidx].equals("O")) {
170-
localGMTString = localShortGMTString;
171-
}
172162

173163
for (int tzidx = 0; tzidx < tzids.length; tzidx++) {
174164
if (EXCL_TZ_PATTERN.matcher(tzids[tzidx]).matches()) {
@@ -276,7 +266,7 @@ public void TestTimeZoneRoundTrip() {
276266
isOffsetFormat = (numDigits > 0);
277267
}
278268

279-
if (isOffsetFormat || tzstr.equals(localGMTString)) {
269+
if (isOffsetFormat) {
280270
// Localized GMT or ISO: total offset (raw + dst) must be preserved.
281271
int inOffset = inOffsets[0] + inOffsets[1];
282272
int outOffset = outOffsets[0] + outOffsets[1];

icu4j/main/core/src/main/java/com/ibm/icu/text/TimeZoneFormat.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,11 +1634,6 @@ public Object parseObject(String source, ParsePosition pos) {
16341634
* @return the localized GMT string
16351635
*/
16361636
private String formatOffsetLocalizedGMT(int offset, boolean isShort) {
1637-
// Not using GMT zero format when long (ICU-23157)
1638-
if (offset == 0 && isShort) {
1639-
return _gmtZeroFormat;
1640-
}
1641-
16421637
StringBuilder buf = new StringBuilder();
16431638
boolean positive = true;
16441639
if (offset < 0) {
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)