mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 14:31:31 +00:00
ICU-7652 Get correct week data from territory based locale
X-SVN-Rev: 28660
This commit is contained in:
parent
cbc567f055
commit
3c7ba0c2e4
3 changed files with 34 additions and 11 deletions
|
@ -4241,10 +4241,33 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
|
|||
WeekData data = cachedLocaleData.get(locale);
|
||||
|
||||
if (data == null) { /* cache miss */
|
||||
|
||||
// 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" )
|
||||
|
||||
ULocale useLocale;
|
||||
ULocale min = ULocale.minimizeSubtags(locale);
|
||||
if ( locale.getCountry().length() == 0 ||
|
||||
locale.getScript().length() > 0 && min.getScript().length() == 0 ) {
|
||||
ULocale max = ULocale.addLikelySubtags(locale);
|
||||
ULocale.Builder builder = new ULocale.Builder();
|
||||
builder.setLocale(max);
|
||||
if (min.getScript().length() == 0) {
|
||||
builder.setScript(null);
|
||||
}
|
||||
useLocale = builder.build();
|
||||
} else {
|
||||
useLocale = locale;
|
||||
}
|
||||
|
||||
CalendarData calData = new CalendarData(locale, getType());
|
||||
int[] dateTimeElements = calData.get("DateTimeElements").getIntVector();
|
||||
int[] weekend = calData.get("weekend").getIntVector();
|
||||
CalendarData wkData = new CalendarData(useLocale, getType());
|
||||
int[] dateTimeElements = wkData.get("DateTimeElements").getIntVector();
|
||||
int[] weekend = wkData.get("weekend").getIntVector();
|
||||
data = new WeekData(dateTimeElements[0],dateTimeElements[1],
|
||||
weekend[0],
|
||||
weekend[1],
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:977342bb1aba0c12fd661aa4476b63cad1e5603e99b1abaf4eec276b4e21740e
|
||||
size 7469197
|
||||
oid sha256:6c7451af00c4f9bcf0a42b126ff9170c525eb83849f01ff34245daf947875765
|
||||
size 7080727
|
||||
|
|
|
@ -901,17 +901,17 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk {
|
|||
final PatternAndResult[] tests = {
|
||||
new PatternAndResult( "dd MMM yyyy GGG", "02 Jul 2008 AD" ),
|
||||
new PatternAndResult( "dd MMM yyyy GGGGG", "02 Jul 2008 A" ),
|
||||
new PatternAndResult( "e dd MMM yyyy", "3 02 Jul 2008" ),
|
||||
new PatternAndResult( "ee dd MMM yyyy", "03 02 Jul 2008" ),
|
||||
new PatternAndResult( "c dd MMM yyyy", "3 02 Jul 2008" ),
|
||||
new PatternAndResult( "cc dd MMM yyyy", "3 02 Jul 2008" ),
|
||||
new PatternAndResult( "e dd MMM yyyy", "4 02 Jul 2008" ),
|
||||
new PatternAndResult( "ee dd MMM yyyy", "04 02 Jul 2008" ),
|
||||
new PatternAndResult( "c dd MMM yyyy", "4 02 Jul 2008" ),
|
||||
new PatternAndResult( "cc dd MMM yyyy", "4 02 Jul 2008" ),
|
||||
new PatternAndResult( "eee dd MMM yyyy", "Wed 02 Jul 2008" ),
|
||||
new PatternAndResult( "EEE dd MMM yyyy", "Wed 02 Jul 2008" ),
|
||||
new PatternAndResult( "EE dd MMM yyyy", "Wed 02 Jul 2008" ),
|
||||
new PatternAndResult( "eeee dd MMM yyyy", "Wednesday 02 Jul 2008" ),
|
||||
new PatternAndResult( "eeeee dd MMM yyyy", "W 02 Jul 2008" ),
|
||||
new PatternAndResult( "e ww YYYY", "3 27 2008" ),
|
||||
new PatternAndResult( "c ww YYYY", "3 27 2008" ),
|
||||
new PatternAndResult( "e ww YYYY", "4 27 2008" ),
|
||||
new PatternAndResult( "c ww YYYY", "4 27 2008" ),
|
||||
};
|
||||
ULocale loc = ULocale.ENGLISH;
|
||||
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
|
||||
|
|
Loading…
Add table
Reference in a new issue