DateComponentsFormatter returns incorrect string when formatting a TimeInterval
| Originator: | meteochu | ||
| Number: | rdar://32513237 | Date Originated: | 6/1/2017 |
| Status: | OPEN | Resolved: | |
| Product: | iOS SDK + Foundation | Product Version: | |
| Classification: | UI/Usability | Reproducible: | Always |
Area: Foundation Summary: DateComponentsFormatter.string(for: TimeInterval) will return an incorrect string when passing a TimeInterval greater than `Int32.max` (2.1B), and the result will be a string of an overflown Int32. Steps to Reproduce: 1. Create a DateComponentsFormatter instance. 2. Get the result from string(from: TimeInterval) of an `Int32.max + 1` Double. Expected Results: The expected string should be "68y 0m 2w 4d 3:14:07" Observed Results: The returned string is "-68y 0m 2w 4d 4:14:07" Version: iOS 10.3 SDK Foundation with Xcode 8.3 Notes: Current workaround is to use `string(from:Date, to:Date)` where the "to" date is a `.addingTimeInterval(timeInterval)` of the "from" date.
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!