ICU-7652 Get correct week data from territory based locale
X-SVN-Rev: 28658
This commit is contained in:
parent
41e92c0c68
commit
cd3f6237f9
@ -93,9 +93,11 @@ likelySubtags:table(nofallback){
|
||||
ig{"ig_Latn_NG"}
|
||||
ii{"ii_Yiii_CN"}
|
||||
ilo{"ilo_Latn_PH"}
|
||||
in{"in_Latn_ID"}
|
||||
inh{"inh_Cyrl_RU"}
|
||||
is{"is_Latn_IS"}
|
||||
it{"it_Latn_IT"}
|
||||
iw{"iw_Hebr_IL"}
|
||||
ja{"ja_Jpan_JP"}
|
||||
jmc{"jmc_Latn_TZ"}
|
||||
jv{"jv_Latn_ID"}
|
||||
|
@ -3242,7 +3242,31 @@ Calendar::setWeekData(const Locale& desiredLocale, const char *type, UErrorCode&
|
||||
fWeekendCease = UCAL_SUNDAY;
|
||||
fWeekendCeaseMillis = 86400000; // 24*60*60*1000
|
||||
|
||||
CalendarData calData(desiredLocale, type, status);
|
||||
// Since week and weekend data is territory based instead of language based,
|
||||
// we may need to tweak the locale that we are using to try to get the appropriate
|
||||
// values, using the following logic:
|
||||
// 1). If the locale has a language but no territory, use the territory as defined by
|
||||
// the likely subtags.
|
||||
// 2). If the locale has a script designation then we ignore it,
|
||||
// then remove it ( i.e. "en_Latn_US" becomes "en_US" )
|
||||
|
||||
char minLocaleID[ULOC_FULLNAME_CAPACITY];
|
||||
UErrorCode myStatus = U_ZERO_ERROR;
|
||||
uloc_minimizeSubtags(desiredLocale.getName(),minLocaleID,ULOC_FULLNAME_CAPACITY,&myStatus);
|
||||
Locale min = Locale::createFromName(minLocaleID);
|
||||
Locale useLocale;
|
||||
if ( uprv_strlen(desiredLocale.getCountry()) == 0 ||
|
||||
uprv_strlen(desiredLocale.getScript()) > 0 && uprv_strlen(min.getScript()) == 0 ) {
|
||||
char maxLocaleID[ULOC_FULLNAME_CAPACITY];
|
||||
myStatus = U_ZERO_ERROR;
|
||||
uloc_addLikelySubtags(desiredLocale.getName(),maxLocaleID,ULOC_FULLNAME_CAPACITY,&myStatus);
|
||||
Locale max = Locale::createFromName(maxLocaleID);
|
||||
useLocale = Locale(max.getLanguage(),max.getCountry());
|
||||
} else {
|
||||
useLocale = Locale(desiredLocale);
|
||||
}
|
||||
|
||||
CalendarData calData(useLocale, type, status);
|
||||
// If the resource data doesn't seem to be present at all, then use last-resort
|
||||
// hard-coded data.
|
||||
UResourceBundle *dateTimeElements = calData.getByKey(gDateTimeElements, status);
|
||||
|
@ -514,8 +514,8 @@ static const UChar edMyPattern[] = { 0x65,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D
|
||||
static const UChar eedMyPattern[] = { 0x65,0x65,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "ee dd MMM yyyy" */
|
||||
static const UChar cdMyPattern[] = { 0x63,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "c dd MMM yyyy" */
|
||||
static const UChar ccdMyPattern[] = { 0x63,0x63,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "cc dd MMM yyyy" */
|
||||
static const UChar edMyText[] = { 0x33,0x20,0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0 }; /* "3 02 Jul 2008" */
|
||||
static const UChar eedMyText[] = { 0x30,0x33,0x20,0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0 }; /* "03 02 Jul 2008" */
|
||||
static const UChar edMyText[] = { 0x34,0x20,0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0 }; /* "3 02 Jul 2008" */
|
||||
static const UChar eedMyText[] = { 0x30,0x34,0x20,0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0 }; /* "03 02 Jul 2008" */
|
||||
static const UChar eeedMyPattern[] = { 0x65,0x65,0x65,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "eee dd MMM yyyy" */
|
||||
static const UChar EEEdMyPattern[] = { 0x45,0x45,0x45,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "EEE dd MMM yyyy" */
|
||||
static const UChar EEdMyPattern[] = { 0x45,0x45,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "EE dd MMM yyyy" */
|
||||
@ -526,7 +526,7 @@ static const UChar eeeeedMyPattern[] = { 0x65,0x65,0x65,0x65,0x65,0x20,0x64,0x64
|
||||
static const UChar eeeeedMyText[] = { 0x57,0x20,0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0 }; /* "W 02 Jul 2008" */
|
||||
static const UChar ewYPattern[] = { 0x65,0x20,0x77,0x77,0x20,0x59,0x59,0x59,0x59,0 }; /* "e ww YYYY" */
|
||||
static const UChar cwYPattern[] = { 0x63,0x20,0x77,0x77,0x20,0x59,0x59,0x59,0x59,0 }; /* "c ww YYYY" */
|
||||
static const UChar ewYText[] = { 0x33,0x20,0x32,0x37,0x20,0x32,0x30,0x30,0x38,0 }; /* "3 27 2008" */
|
||||
static const UChar ewYText[] = { 0x34,0x20,0x32,0x37,0x20,0x32,0x30,0x30,0x38,0 }; /* "3 27 2008" */
|
||||
static const UChar HHmmssPattern[] = { 0x48,0x48,0x3A,0x6D,0x6D,0x3A,0x73,0x73,0 }; /* "HH:mm:ss" */
|
||||
static const UChar HHmmssText[] = { 0x30,0x35,0x3A,0x30,0x30,0x3A,0x30,0x31,0 }; /* "05:00:01" */
|
||||
static const UChar ssSPattern[] = { 0x73,0x73,0x2E,0x53,0 }; /* "ss.S" */
|
||||
|
@ -1323,7 +1323,7 @@ CalendarTest::TestEpochStartFields()
|
||||
}
|
||||
|
||||
int32_t CalendarTest::EPOCH_FIELDS[] = {
|
||||
1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, - 28800000, 0
|
||||
1, 1970, 0, 53, 0, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, - 28800000, 0
|
||||
};
|
||||
|
||||
// -------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user