ICU-6726 Changes to dateTimePatterns lengths and default glue pattern usage
X-SVN-Rev: 25592
This commit is contained in:
parent
b6df6d78ec
commit
99ca0b9eac
@ -261,7 +261,30 @@ void RelativeDateFormat::loadDates(UErrorCode &status) {
|
||||
UResourceBundle *dateTimePatterns = calData.getByKey(DT_DateTimePatternsTag, tempStatus);
|
||||
if(U_SUCCESS(tempStatus) && ures_getSize(dateTimePatterns) > DateFormat::kDateTime) {
|
||||
int32_t resStrLen = 0;
|
||||
const UChar *resStr = ures_getStringByIndex(dateTimePatterns, (int32_t)DateFormat::kDateTime, &resStrLen, &tempStatus);
|
||||
|
||||
int32_t glueIndex = (int32_t)DateFormat::kDateTime;
|
||||
switch (fDateStyle) {
|
||||
case kFullRelative:
|
||||
case kFull:
|
||||
glueIndex = kDateTimeOffset + kFull;
|
||||
break;
|
||||
case kLongRelative:
|
||||
case kLong:
|
||||
glueIndex = kDateTimeOffset + kLong;
|
||||
break;
|
||||
case kMediumRelative:
|
||||
case kMedium:
|
||||
glueIndex = kDateTimeOffset + kMedium;
|
||||
break;
|
||||
case kShortRelative:
|
||||
case kShort:
|
||||
glueIndex = kDateTimeOffset + kShort;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const UChar *resStr = ures_getStringByIndex(dateTimePatterns, glueIndex, &resStrLen, &tempStatus);
|
||||
fCombinedFormat = new MessageFormat(UnicodeString(TRUE, resStr, resStrLen), fLocale, tempStatus);
|
||||
}
|
||||
|
||||
|
@ -567,7 +567,15 @@ void SimpleDateFormat::construct(EStyle timeStyle,
|
||||
}
|
||||
timeDateArray[1].adoptString(tempus2);
|
||||
|
||||
resStr = ures_getStringByIndex(dateTimePatterns, (int32_t)kDateTime, &resStrLen, &status);
|
||||
int32_t glueIndex = ures_getSize(dateTimePatterns);
|
||||
if (glueIndex > kDateTimeOffset) {
|
||||
glueIndex = (int32_t)(kDateTimeOffset + (dateStyle - kDateOffset));
|
||||
}
|
||||
else {
|
||||
glueIndex = kDateTime;
|
||||
}
|
||||
|
||||
resStr = ures_getStringByIndex(dateTimePatterns, glueIndex, &resStrLen, &status);
|
||||
MessageFormat::format(UnicodeString(TRUE, resStr, resStrLen), timeDateArray, 2, fPattern, status);
|
||||
}
|
||||
// if the pattern includes just time data or just date date, load the appropriate
|
||||
|
@ -161,7 +161,7 @@ public:
|
||||
// kShort + kDateOffset = 7
|
||||
|
||||
kDateTime = 8,
|
||||
|
||||
kDateTimeOffset = kDateTime + 1,
|
||||
|
||||
// relative dates
|
||||
kRelative = (1 << 7),
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
********************************************************************************
|
||||
* Copyright (C) 2005-2008, International Business Machines
|
||||
* Copyright (C) 2005-2009, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
********************************************************************************
|
||||
*
|
||||
@ -52,7 +52,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(Win32DateFormat)
|
||||
|
||||
#define STACK_BUFFER_SIZE 64
|
||||
|
||||
UnicodeString *getTimeDateFormat(const Calendar *cal, const Locale *locale, UErrorCode &status)
|
||||
UnicodeString* Win32DateFormat::getTimeDateFormat(const Calendar *cal, const Locale *locale, UErrorCode &status) const
|
||||
{
|
||||
UnicodeString *result = NULL;
|
||||
const char *type = cal->getType();
|
||||
@ -74,7 +74,14 @@ UnicodeString *getTimeDateFormat(const Calendar *cal, const Locale *locale, UErr
|
||||
}
|
||||
|
||||
int32_t resStrLen = 0;
|
||||
const UChar *resStr = ures_getStringByIndex(patBundle, (int32_t)DateFormat::kDateTime, &resStrLen, &status);
|
||||
int32_t glueIndex = ures_getSize(patBundle);
|
||||
if (glueIndex > DateFormat::kDateTimeOffset) {
|
||||
glueIndex = (int32_t)(DateFormat::kDateTimeOffset + (fDateStyle - DateFormat::kDateOffset));
|
||||
}
|
||||
else {
|
||||
glueIndex = DateFormat::kDateTime;
|
||||
}
|
||||
const UChar *resStr = ures_getStringByIndex(patBundle, glueIndex, &resStrLen, &status);
|
||||
|
||||
result = new UnicodeString(TRUE, resStr, resStrLen);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
********************************************************************************
|
||||
* Copyright (C) 2005-2007, International Business Machines
|
||||
* Copyright (C) 2005-2009, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
********************************************************************************
|
||||
*
|
||||
@ -125,6 +125,7 @@ private:
|
||||
void formatTime(const SYSTEMTIME *st, UnicodeString &appendTo) const;
|
||||
|
||||
UnicodeString setTimeZoneInfo(TIME_ZONE_INFORMATION *tzi, const TimeZone &zone) const;
|
||||
UnicodeString* getTimeDateFormat(const Calendar *cal, const Locale *locale, UErrorCode &status) const;
|
||||
|
||||
UnicodeString *fDateTimeMsg;
|
||||
DateFormat::EStyle fTimeStyle;
|
||||
|
@ -76,9 +76,10 @@ void DateFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &nam
|
||||
TESTCASE(36,TestTimeZoneDisplayName);
|
||||
TESTCASE(37,TestRoundtripWithCalendar);
|
||||
TESTCASE(38,Test6338);
|
||||
TESTCASE(39,Test6726);
|
||||
/*
|
||||
TESTCASE(39,TestRelativeError);
|
||||
TESTCASE(40,TestRelativeOther);
|
||||
TESTCASE(40,TestRelativeError);
|
||||
TESTCASE(41,TestRelativeOther);
|
||||
*/
|
||||
default: name = ""; break;
|
||||
}
|
||||
@ -3142,6 +3143,46 @@ void DateFormatTest::Test6338(void)
|
||||
|
||||
}
|
||||
|
||||
void DateFormatTest::Test6726(void)
|
||||
{
|
||||
// status
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
// fmtf, fmtl, fmtm, fmts;
|
||||
UnicodeString strf, strl, strm, strs;
|
||||
UDate dt = date(2008-1900, UCAL_JUNE, 10, 12, 00);
|
||||
|
||||
Locale loc("ja");
|
||||
DateFormat* fmtf = DateFormat::createDateTimeInstance(DateFormat::FULL, DateFormat::FULL, loc);
|
||||
DateFormat* fmtl = DateFormat::createDateTimeInstance(DateFormat::LONG, DateFormat::FULL, loc);
|
||||
DateFormat* fmtm = DateFormat::createDateTimeInstance(DateFormat::MEDIUM, DateFormat::FULL, loc);
|
||||
DateFormat* fmts = DateFormat::createDateTimeInstance(DateFormat::SHORT, DateFormat::FULL, loc);
|
||||
strf = fmtf->format(dt, strf);
|
||||
strl = fmtl->format(dt, strl);
|
||||
strm = fmtm->format(dt, strm);
|
||||
strs = fmts->format(dt, strs);
|
||||
|
||||
if (strf.charAt(13) == UChar(' ')) {
|
||||
errln((UnicodeString)"FAIL: Improper formated date: " + strf);
|
||||
}
|
||||
if (strl.charAt(10) == UChar(' ')) {
|
||||
errln((UnicodeString)"FAIL: Improper formated date: " + strl);
|
||||
}
|
||||
if (strm.charAt(10) != UChar(' ')) {
|
||||
errln((UnicodeString)"FAIL: Improper formated date: " + strm);
|
||||
}
|
||||
if (strs.charAt(8) != UChar(' ')) {
|
||||
errln((UnicodeString)"FAIL: Improper formated date: " + strs);
|
||||
}
|
||||
|
||||
delete fmtf;
|
||||
delete fmtl;
|
||||
delete fmtm;
|
||||
delete fmts;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
//eof
|
||||
|
@ -161,6 +161,7 @@ public: // package
|
||||
|
||||
void Test6338(void);
|
||||
|
||||
void Test6726(void);
|
||||
public:
|
||||
/**
|
||||
* Test host-specific formatting.
|
||||
|
Loading…
Reference in New Issue
Block a user