RelativeDateTimeFormatter returns wrong localizedString
Originator: | cmenschel54 | ||
Number: | rdar://FB9080980 | Date Originated: | Apr 16, 2021 at 4:45 PM |
Status: | Open | Resolved: | |
Product: | Foundation | Product Version: | |
Classification: | Reproducible: | Always |
RelativeDateTimeFormatter returns wrong localizedString for the date in 2 two days. see the following code snippet ``` var comps1 = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute], from: date) comps1.setValue(16, for: .day) comps1.setValue(11, for: .hour) comps1.setValue(00, for: .minute) let today = Calendar.current.date(from: comps1)! var comps2 = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute], from: date) comps2.setValue(18, for: .day) comps2.setValue(10, for: .hour) comps2.setValue(00, for: .minute) let date = Calendar.current.date(from: comps2)! let local = RelativeDateTimeFormatter().localizedString(for: date, relativeTo: today) ``` Current behavior: local ==> "in 1 day" with German locale local ===> "morgen" Expected behavior: local ==> "in 2 days" with German locale local ===> "übermorgen" When you change the hour in comps2 from 10 to 11 you get the correct result (in 2 days)
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!