Approximation Phrase of DateComponentsFormatter does not respect the calendar's locale

Originator:alx.tuerk
Number:rdar://FB9113411 Date Originated:2021-05-21
Status:Open Resolved:
Product:Foundation Product Version:14.5
Classification:Incorrect/Undefined Behavior Reproducible:Always
 
The DateComponentsFormatter’s behavior can be changed by setting a different calendar. To also change the locale we can set a different locale on the provided calendar. This is mostly respected by the formatter but when setting `includesApproximationPhrase = true` the approximation phrase uses the system’s current locale. 

Sample code (see attached Playground):
let dateComponentsFormatter = DateComponentsFormatter()
dateComponentsFormatter.calendar = Calendar(identifier: .gregorian)
dateComponentsFormatter.calendar?.locale = Locale(identifier: "de_DE")

dateComponentsFormatter.includesApproximationPhrase = true
dateComponentsFormatter.unitsStyle = .full

let output = dateComponentsFormatter.string(from: 1_000)

Expected: 
“Ungefähr 16 Minuten und 40 Sekunden"

Actual:
"About 16 Minuten und 40 Sekunden"

Suggestion:
To not break backwards compatibility for developers who don’t use the abbreviation the formatter should always use the calendar’s locale for localized String lookups (just like it does for he components). 

Attachments:
https://github.com/fruitcoder/radar.apple.com/tree/main/FB9113411%20-%20Approximation%20Phrase%20of%20DateComponentsFormatter%20does%20not%20respect%20the%20calendar%27s%20locale

Comments


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!