mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-13 08:53:20 +00:00
ICU-4823 Fix udat_open so that it doesn't ignore the timezone argument.
X-SVN-Rev: 18527
This commit is contained in:
parent
39ad72f108
commit
182abf6aa2
1 changed files with 29 additions and 35 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue