DateTimeFormat: set the locale to the pattern generator.

Unfortunately this isn't enough to fix the bug shown by the test just
added.
This commit is contained in:
Adrien Destugues 2014-10-20 17:24:50 +02:00
parent 980b1bd045
commit bb2a5b4db5
2 changed files with 5 additions and 5 deletions

View File

@ -48,7 +48,8 @@ BDateTimeFormat::SetDateTimeFormat(BDateFormatStyle dateStyle,
BTimeFormatStyle timeStyle, int32 elements) {
UErrorCode error = U_ZERO_ERROR;
DateTimePatternGenerator* generator
= DateTimePatternGenerator::createInstance(error);
= DateTimePatternGenerator::createInstance(
*BLanguage::Private(&fLanguage).ICULocale(), error);
BString skeleton;
if (elements & B_DATE_ELEMENT_YEAR)
@ -63,9 +64,9 @@ BDateTimeFormat::SetDateTimeFormat(BDateFormatStyle dateStyle,
skeleton << "a";
if (elements & B_DATE_ELEMENT_HOUR) {
if (fConventions.Use24HourClock())
skeleton << "HH";
skeleton << "k";
else
skeleton << "KK";
skeleton << "K";
}
if (elements & B_DATE_ELEMENT_MINUTE)
skeleton << "mm";
@ -80,6 +81,7 @@ BDateTimeFormat::SetDateTimeFormat(BDateFormatStyle dateStyle,
BString buffer;
BStringByteSink stringConverter(&buffer);
pattern.toUTF8(stringConverter);
fConventions.SetExplicitDateTimeFormat(dateStyle, timeStyle, buffer);
delete generator;

View File

@ -234,8 +234,6 @@ BTimeFormat::Parse(BString source, BTimeFormatStyle style, BTime& output)
UDate date = timeFormatter->parse(UnicodeString::fromUTF8(source.String()),
p);
printf("T %f\n", date);
output.SetTime(0, 0, 0);
output.AddMilliseconds(date);