ICU-8346 ICU4C TimeZone::createTimeZone to return Etc/Unknown when the given ID is unknown/unparsable. Also added UCAL_UNKNOWN_ZONE_ID.
X-SVN-Rev: 29462
This commit is contained in:
parent
80237b4a8c
commit
d7c7514920
@ -411,13 +411,8 @@ TimeZone::createTimeZone(const UnicodeString& ID)
|
||||
result = createCustomTimeZone(ID);
|
||||
}
|
||||
if (result == 0) {
|
||||
U_DEBUG_TZ_MSG(("failed to load time zone with id - falling to GMT"));
|
||||
const TimeZone* temptz = getGMT();
|
||||
if (temptz == NULL) {
|
||||
result = NULL;
|
||||
} else {
|
||||
result = temptz->clone();
|
||||
}
|
||||
U_DEBUG_TZ_MSG(("failed to load time zone with id - falling to Etc/Unknown(GMT)"));
|
||||
result = new SimpleTimeZone(0, UNKNOWN_ZONE_ID);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2010, International Business Machines Corporation and
|
||||
* Copyright (C) 1996-2011, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -140,6 +140,12 @@
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* The time zone ID reserved for unknown time zone.
|
||||
* @draft ICU 4.8
|
||||
*/
|
||||
#define UCAL_UNKNOWN_ZONE_ID "Etc/Unknown"
|
||||
|
||||
/** A calendar.
|
||||
* For usage in C programs.
|
||||
* @stable ICU 2.0
|
||||
|
@ -502,7 +502,7 @@ TimeZoneTest::TestGetAvailableIDs913()
|
||||
UnicodeString temp;
|
||||
if (tz == 0)
|
||||
errln("FAIL: getTimeZone(NON_EXISTENT) = null");
|
||||
else if (tz->getID(temp) != "GMT")
|
||||
else if (tz->getID(temp) != UCAL_UNKNOWN_ZONE_ID)
|
||||
errln("FAIL: getTimeZone(NON_EXISTENT) = " + temp);
|
||||
delete tz;
|
||||
|
||||
@ -963,7 +963,7 @@ void TimeZoneTest::TestCustomParse()
|
||||
formatOffset(ioffset, offset);
|
||||
formatTZID(ioffset, expectedID);
|
||||
logln(id + " -> " + itsID + " " + offset);
|
||||
if (exp == kUnparseable && itsID != "GMT") {
|
||||
if (exp == kUnparseable && itsID != UCAL_UNKNOWN_ZONE_ID) {
|
||||
errln("Expected parse failure for " + id +
|
||||
", got offset of " + offset +
|
||||
", id " + itsID);
|
||||
|
Loading…
Reference in New Issue
Block a user