We're updating the issue view to help you get more done. 

In GregorianCalendar, week numbering is inconsistent for different languages in same country

Description

Is the concept of week numbering something that depends more on language or more on country?
I claim that it depends more on country, because different workers in the same working location
must have a common understanding when their work is planned. Whereas there is much less reason
for French speaking people in France and French speaking people in Canada to share the same
week numbering scheme.

So, the week numbering ought to depend on the country, but not on the language, of the locale.

This is not so in ICU (and the JRE likewise, by the way).

Test case (note that is cannot use the method getMinimalDaysInFirstWeek() directly, due
to bug #8331 <http://www.icu-project.org/trac/ticket/8331>):
================================ TestICUMinDaysInWeekBug4.java ==========================

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 import java.util.Locale; import com.ibm.icu.util.Calendar; import com.ibm.icu.util.GregorianCalendar; import com.ibm.icu.util.ULocale; public class TestICUMinDaysInWeekBug4 { private static boolean isLocaleSupported(ULocale locale) { ULocale[] supported = ULocale.getAvailableLocales(); for (ULocale l : supported) if (l.equals(locale)) return true; return false; } private static boolean isCalendarSupported(ULocale locale) { ULocale[] supported = Calendar.getAvailableULocales(); for (ULocale l : supported) if (l.equals(locale)) return true; return false; } private static void showMultipleMinDaysInFirstWeek(Locale[] locales) { String spaces = " "; for (Locale locale : locales) { ULocale ulocale = ULocale.forLocale(locale); Calendar cal = new GregorianCalendar(locale); cal.set(2011, 1-1, 8); String l = locale.toString(); System.out.println(l+spaces.substring(l.length())+(isLocaleSupported(ulocale) ? "*" : "-")+" "+(isCalendarSupported(ulocale) ? "*" : "-")+" "+(7-3*cal.get(Calendar.WEEK_OF_YEAR))); } System.out.println(); } public static void main(String[] args) { showMultipleMinDaysInFirstWeek( new Locale[] { new Locale("aa", "DJ"), new Locale("so", "DJ") }); showMultipleMinDaysInFirstWeek( new Locale[] { new Locale("ar", "DZ"), new Locale("ber", "DZ") }); showMultipleMinDaysInFirstWeek( new Locale[] { new Locale("aa", "ER"), new Locale("byn", "ER"), new Locale("gez", "ER"), new Locale("ti", "ER"), new Locale("tig", "ER") }); showMultipleMinDaysInFirstWeek( new Locale[] { new Locale("aa", "ET"), new Locale("am", "ET"), new Locale("gez", "ET"), new Locale("om", "ET"), new Locale("sid", "ET"), new Locale("so", "ET"), new Locale("ti", "ET"), new Locale("wal", "ET") }); showMultipleMinDaysInFirstWeek( new Locale[] { new Locale("ar", "MA"), new Locale("ber", "MA") }); } }

=========================================================================================

Actual output:

aa_DJ - - 4
so_DJ * * 1

ar_DZ * * 1
ber_DZ - - 4

aa_ER - - 4
byn_ER - - 4
gez_ER - - 4
ti_ER * * 1
tig_ER - - 4

aa_ET - - 4
am_ET * * 1
gez_ET - - 4
om_ET * * 1
sid_ET - - 4
so_ET * * 1
ti_ET * * 1
wal_ET - - 4

ar_MA * * 1
ber_MA - - 4

Expected output:

aa_DJ - - 1
so_DJ * * 1

ar_DZ * * 1
ber_DZ - - 1

aa_ER - - 1
byn_ER - - 1
gez_ER - - 1
ti_ER * * 1
tig_ER - - 1

aa_ET - - 1
am_ET * * 1
gez_ET - - 1
om_ET * * 1
sid_ET - - 1
so_ET * * 1
ti_ET * * 1
wal_ET - - 1

ar_MA * * 1
ber_MA - - 1

A possible fix would be for ICU to build a HashMap that maps a country name (String) to the
desired value of minimumDaysInFirstWeek (Integer), and use that in the constructor of
GregorianCalendar.

Status

Assignee

Dragan Besevic

Reporter

TracBot

Labels

None

Reviewer

None

Time Needed

Days

Start date

None

Components

Priority

medium