Ticket #5702 (assigned defect)

Bug contains 1 commit(s) | SVN Diffs for #5702

 

Opened 2 years ago

Last modified 2 days ago

Support calendars with eras in flexible date/time; use correct availableFormats

Reported by: deborah Assigned to: pedberg (accepted)
Priority: critical Milestone: 4.1.2
Component: formatting Version: Current
Keywords: Cc:
Load: Apple:100 Xref: 6626
Java Version: Operating System:
Project (C/J): ICU4C Weeks:
Review: mark

Description

From the CLDR list:

There are a couple of cases where two fields are tied together in availableFormats, and need to be handled specially. One is h/a, which we already deal with. The other, which we don't deal with, is y/G.

This comes in to play with certain calendars, such as Japanese, that require an era field. A client requesting a format string via the availableFormats data is not going to know whether they are using the Gregorian or Japanese or Thai Buddhist calendars. They will request something like yyyy or yy. For Japanese, the appropriate format string for both of those is Gy.

It gets more complex. For date format strings, I might request yyyyMMMMdd or yyMMdd. For the first, the appropriate Japanese string would be something like:

Gy年MM月dd日

For the second, the appropriate string might be:

GGGGGyy/MM/dd

to get the one-character abbreviated era names, e.g. "H17/04/16".

Right now, if a client requests yyyy or yy, they're not going to get an era in the result even if the Japanese calendar is requested.

Here's a strawman proposal for discussion tomorrow:

If a client requests a format string containing a year, and all the availableFormat strings with a year also contain an era, then silently include the era as part of the result. We may need to modify this to something else if the first approach doesn't work.

For calendars that care, we'd need to provide a separate set of availableFormats that follow these rules.

Attachments

Change History

05/10/07 15:52:50 changed by grhoten

  • owner changed from somebody to deborah.

02/18/08 16:03:42 changed by pedberg

  • owner changed from deborah to pedberg.
  • milestone changed from UNSCH to 4.0.

02/18/08 16:06:19 changed by pedberg

  • status changed from new to assigned.

06/18/08 00:42:30 changed by pedberg

  • status changed from assigned to new.

06/25/08 11:03:57 changed by pedberg

  • milestone changed from 4.0 to 4.2.

07/23/08 10:55:57 changed by pedberg

  • load set to Apple:100.

11/12/08 21:38:47 changed by pedberg

OK, the problem is in the DateTimePatternGenerator constructor from a locale, DateTimePatternGenerator::DateTimePatternGenerator(const Locale& locale, UErrorCode &status), and its internal call to initData(locale, status).

That initData function builds up a list of patterns with corresponding base patterns and skeletons and patterns: It goes through the canonical pattern fields, the standard date/time formats for the locale, and the availableFormats from the gregorian calendar bundle for the locale; for each it calls addPattern to derive a corresponding basePattern and skeleton, and to add the pattern with base & skeleton to its list if the base & skeleton do not match something already in its list. The problem is that for availableFormats it ignores the actual calendar type and always uses gregorian; the gregorian availableFormats have many patterns that do not include era with year.

11/13/08 11:56:52 changed by pedberg

  • status changed from new to assigned.
  • summary changed from Support for calendars with eras in flexible date/time to Support calendars with eras in flexible date/time; use correct availableFormats.

To bridge the gap between the original description and my previous comment... The behavior requested in the original description will automatically happen if the availableFormats data is set up so all skeletons that include a year correspond to patterns that also include era. This is currently true for the availableFormats data for the Japanese calendar, but not for the Gregorian calendar. If we fix DateTimePatternGenerator to use the availableFormats data for the correct calendar, the desired behavior will result.

11/14/08 10:10:44 changed by pedberg

  • xref set to 6626.

11/18/08 20:32:29 changed by pedberg

  • project changed from all to ICU4C.
  • revw set to mark.

As part of this, I also needed to further update the availableFormats entries for japanese calendar in the ICU ja.txt locale file to override some root locale entries for the japanese calendar. The corresponding CLDR updates are added to cldrbug:1975.

Note, we also need a bug to fix this for ICU4J, but need to wait until the ICU4J locale data is updated (to get the updated availableFormats entries).

11/18/08 20:32:38 changed by pedberg

  • milestone changed from 4.2 to 4.1.2.

Add/Change #5702 (Support calendars with eras in flexible date/time; use correct availableFormats)




Anti spam check: