DateFormatter.dateFormat(fromTemplate:options:locale:) doesn't support all UNICODE LDML for DATES symbols

Originator:ashrat07
Number:rdar://37569176 Date Originated:15/02/2018
Status:Closed Resolved:
Product:iOS Product Version:
Classification:Bug Reproducible:Yes
 
Area:
Foundation

Summary:
DateFormatter.dateFormat(fromTemplate:options:locale:) & dateFormatter.setLocalizedDateFormatFromTemplate don't support all UNICODE LDML for DATES symbols (http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Field_Symbol_Table) although dateFormatter.dateFormat does support them.

Steps to Reproduce:
A sample code below
let usLocale = Locale(identifier: "en_US")
let gbLocale = Locale(identifier: "en_GB")
let template = "yLLLLd"
let usDateFormat = DateFormatter.dateFormat(fromTemplate: template, options: 0, locale: usLocale)!
// Date format for English (United States): "MMMM d, y"
let gbDateFormat = DateFormatter.dateFormat(fromTemplate: template, options: 0, locale: gbLocale)!
// Date format for English (United Kingdom): "d MMMM y"


Expected Results:
Expected result for the above shared code should be
// Date format for English (United States): "LLLL d, y"
// Date format for English (United Kingdom): "d LLLL y"

Actual Results:
Actual result for the above shared code is
// Date format for English (United States): "MMMM d, y"
// Date format for English (United Kingdom): "d MMMM y"

Version/Build:


Configuration:

Comments

Apple Developer Relations

This is the intended behavior. In skeletons, all month-type pattern characters (L,M) are treated as equivalent, as are weekday-type pattern characters (E,c), etc. The code will match the desired type of field (e.g. abbreviated month) to the specific pattern character field that is appropriate for the desired combination of fields. For example in Russian, a full month should be MMMM if shown with a day-of-month number, but LLLL otherwise; the coe is supposed to figure this out from the CLDR data.

There is some documentation here: https://www.unicode.org/reports/tr35/tr35-dates.html#availableFormats_appendItems and a better description here: http://cldr.unicode.org/translation/date-time-patterns#TOC-Additional-Date-Time-Formats and here: http://userguide.icu-project.org/formatparse/datetime#TOC-DateTimePatternGenerator

Thank you for your feedback. Engineering has determined that this issue behaves as intended.

We are now closing this bug report.

If you just have questions about the resolution, then please update your bug report with that information so we can respond.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!