ICU-4823 Fix udat_open so that it doesn't ignore the timezone argument.

X-SVN-Rev: 18527
This commit is contained in:
George Rhoten 2005-09-15 04:28:26 +00:00
parent 39ad72f108
commit 182abf6aa2

View file

@ -35,54 +35,48 @@ udat_open(UDateFormatStyle timeStyle,
int32_t patternLength,
UErrorCode *status)
{
if(U_FAILURE(*status))
{
DateFormat *fmt;
if(U_FAILURE(*status)) {
return 0;
}
if(timeStyle != UDAT_IGNORE)
{
DateFormat *fmt;
if(locale == 0)
if(timeStyle != UDAT_IGNORE) {
if(locale == 0) {
fmt = DateFormat::createDateTimeInstance((DateFormat::EStyle)dateStyle,
(DateFormat::EStyle)timeStyle);
else
}
else {
fmt = DateFormat::createDateTimeInstance((DateFormat::EStyle)dateStyle,
(DateFormat::EStyle)timeStyle,
Locale(locale));
}
}
else {
UnicodeString pat((UBool)(patternLength == -1), pattern, patternLength);
if(fmt == 0) {
if(locale == 0) {
fmt = new SimpleDateFormat(pat, *status);
}
else {
fmt = new SimpleDateFormat(pat, Locale(locale), *status);
}
}
if(fmt == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
if(tzID != 0) {
TimeZone *zone = TimeZone::createTimeZone(UnicodeString((UBool)(tzIDLength == -1), tzID, tzIDLength));
if(zone == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
delete fmt;
return 0;
}
if(tzID != 0) {
TimeZone *zone = TimeZone::createTimeZone(UnicodeString((UBool)(tzIDLength == -1), tzID, tzIDLength));
if(zone == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
delete fmt;
return 0;
}
fmt->adoptTimeZone(zone);
}
return (UDateFormat*)fmt;
fmt->adoptTimeZone(zone);
}
else
{
const UnicodeString pat = UnicodeString((UBool)(patternLength == -1), pattern, patternLength);
UDateFormat *retVal = 0;
if(locale == 0)
retVal = (UDateFormat*)new SimpleDateFormat(pat, *status);
else
retVal = (UDateFormat*)new SimpleDateFormat(pat, Locale(locale), *status);
if(retVal == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
return retVal;
}
return (UDateFormat*)fmt;
}