mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 17:24:01 +00:00
ICU-12527 Updating data loading in SimpleDateFormatter, C++
X-SVN-Rev: 38824
This commit is contained in:
parent
e49518937c
commit
457938ebc2
1 changed files with 27 additions and 8 deletions
|
@ -50,10 +50,10 @@
|
|||
#include "unicode/vtzone.h"
|
||||
#include "unicode/udisplaycontext.h"
|
||||
#include "unicode/brkiter.h"
|
||||
#include "uresimp.h"
|
||||
#include "olsontz.h"
|
||||
#include "patternprops.h"
|
||||
#include "fphdlimp.h"
|
||||
#include "gregoimp.h"
|
||||
#include "hebrwcal.h"
|
||||
#include "cstring.h"
|
||||
#include "uassert.h"
|
||||
|
@ -164,9 +164,6 @@ static const UChar SUPPRESS_NEGATIVE_PREFIX[] = {0xAB00, 0};
|
|||
* These are the tags we expect to see in normal resource bundle files associated
|
||||
* with a locale.
|
||||
*/
|
||||
static const char gDateTimePatternsTag[]="DateTimePatterns";
|
||||
|
||||
//static const UChar gEtcUTC[] = {0x45, 0x74, 0x63, 0x2F, 0x55, 0x54, 0x43, 0x00}; // "Etc/UTC"
|
||||
static const UChar QUOTE = 0x27; // Single quote
|
||||
|
||||
/*
|
||||
|
@ -702,12 +699,34 @@ void SimpleDateFormat::construct(EStyle timeStyle,
|
|||
initializeCalendar(NULL, locale, status);
|
||||
if (U_FAILURE(status)) return;
|
||||
|
||||
CalendarData calData(locale, fCalendar?fCalendar->getType():NULL, status);
|
||||
UResourceBundle *dateTimePatterns = calData.getByKey(gDateTimePatternsTag, status);
|
||||
UResourceBundle *currentBundle;
|
||||
|
||||
// Load date time patterns directly from resources.
|
||||
const char* cType = fCalendar ? fCalendar->getType() : NULL;
|
||||
const UResourceBundle *bundle = ures_open(NULL, locale.getBaseName(), &status);
|
||||
if (U_FAILURE(status)) return;
|
||||
|
||||
UBool cTypeIsGregorian = TRUE;
|
||||
UResourceBundle* dateTimePatterns;
|
||||
if (cType != NULL && uprv_strcmp(cType, "gregorian") != 0) {
|
||||
CharString resourcePath("calendar/", status);
|
||||
resourcePath.append(cType, status).append("/DateTimePatterns", status);
|
||||
dateTimePatterns =
|
||||
ures_getByKeyWithFallback(bundle, resourcePath.data(),
|
||||
(UResourceBundle*)NULL, &status);
|
||||
cTypeIsGregorian = FALSE;
|
||||
}
|
||||
|
||||
// Check for "gregorian" fallback.
|
||||
if (cTypeIsGregorian || status == U_MISSING_RESOURCE_ERROR) {
|
||||
status = U_ZERO_ERROR;
|
||||
dateTimePatterns =
|
||||
ures_getByKeyWithFallback(bundle,
|
||||
"calendar/gregorian/DateTimePatterns",
|
||||
(UResourceBundle*)NULL, &status);
|
||||
}
|
||||
if (U_FAILURE(status)) return;
|
||||
|
||||
UResourceBundle *currentBundle;
|
||||
|
||||
if (ures_getSize(dateTimePatterns) <= kDateTime)
|
||||
{
|
||||
status = U_INVALID_FORMAT_ERROR;
|
||||
|
|
Loading…
Add table
Reference in a new issue