ICU-6820 Insert colon as hour/minute/second delimitter in custom time zone ID format.

X-SVN-Rev: 25710
This commit is contained in:
Yoshito Umaoka 2009-04-01 17:13:40 +00:00
parent 0944c728e4
commit e88550b04d
2 changed files with 14 additions and 11 deletions

View File

@ -93,6 +93,7 @@ static char gStrBuf[256];
#define MINUS 0x002D
#define PLUS 0x002B
#define ZERO_DIGIT 0x0030
#define COLON 0x003A
// Static data and constants
@ -1298,7 +1299,7 @@ TimeZone::parseCustomID(const UnicodeString& id, int32_t& sign,
if (pos.getIndex() < id.length()) {
if (pos.getIndex() - start > 2
|| id[pos.getIndex()] != 0x003A /*':'*/) {
|| id[pos.getIndex()] != COLON) {
delete numberFormat;
return FALSE;
}
@ -1314,7 +1315,7 @@ TimeZone::parseCustomID(const UnicodeString& id, int32_t& sign,
}
min = n.getLong();
if (pos.getIndex() < id.length()) {
if (id[pos.getIndex()] != 0x003A /*':'*/) {
if (id[pos.getIndex()] != COLON) {
delete numberFormat;
return FALSE;
}
@ -1393,7 +1394,7 @@ TimeZone::formatCustomID(int32_t hour, int32_t min, int32_t sec,
id += (UChar)(ZERO_DIGIT + hour/10);
}
id += (UChar)(ZERO_DIGIT + hour%10);
id += (UChar)COLON;
if (min < 10) {
id += (UChar)ZERO_DIGIT;
} else {
@ -1402,6 +1403,7 @@ TimeZone::formatCustomID(int32_t hour, int32_t min, int32_t sec,
id += (UChar)(ZERO_DIGIT + min%10);
if (sec) {
id += (UChar)COLON;
if (sec < 10) {
id += (UChar)ZERO_DIGIT;
} else {

View File

@ -872,7 +872,7 @@ UnicodeString& TimeZoneTest::formatTZID(int32_t offset, UnicodeString &rv) {
rv += (UChar)0x0030;
}
rv += (UChar)(0x0030 + (h%10));
rv += (UChar)0x003A;
if (m >= 10) {
rv += (UChar)(0x0030 + (m/10));
} else {
@ -881,6 +881,7 @@ UnicodeString& TimeZoneTest::formatTZID(int32_t offset, UnicodeString &rv) {
rv += (UChar)(0x0030 + (m%10));
if (s) {
rv += (UChar)0x003A;
if (s >= 10) {
rv += (UChar)(0x0030 + (s/10));
} else {
@ -961,7 +962,7 @@ void TimeZoneTest::TestCustomParse()
}
// JDK 1.3 creates custom zones with the ID "Custom"
// JDK 1.4 creates custom zones with IDs of the form "GMT+02:00"
// ICU creates custom zones with IDs of the form "GMT+0200"
// ICU creates custom zones with IDs of the form "GMT+02:00"
else if (exp != kUnparseable && (ioffset != exp || itsID != expectedID)) {
errln("Expected offset of " + formatOffset(exp, temp) +
", id " + expectedID +
@ -1815,12 +1816,12 @@ void TimeZoneTest::TestCanonicalID() {
const char *expected;
UBool isSystem;
} data[] = {
{"GMT-03", "GMT-0300", FALSE},
{"GMT+4", "GMT+0400", FALSE},
{"GMT-055", "GMT-0055", FALSE},
{"GMT+430", "GMT+0430", FALSE},
{"GMT-12:15", "GMT-1215", FALSE},
{"GMT-091015", "GMT-091015", FALSE},
{"GMT-03", "GMT-03:00", FALSE},
{"GMT+4", "GMT+04:00", FALSE},
{"GMT-055", "GMT-00:55", FALSE},
{"GMT+430", "GMT+04:30", FALSE},
{"GMT-12:15", "GMT-12:15", FALSE},
{"GMT-091015", "GMT-09:10:15", FALSE},
{"GMT+1:90", 0, FALSE},
{"America/Argentina/Buenos_Aires", "America/Buenos_Aires", TRUE},
{"bogus", 0, FALSE},