Modify DateComponentsFormatter to support elapsed time

Originator:steven.baranski
Number:rdar://47749160 Date Originated:2/1/2019
Status:Duplicate/8176702 Resolved:Closed
Product:iOS + SDK Foundation Product Version:iOS 12 SDK
Classification:Suggestion Reproducible:Yes
 
We currently use an OSS component called FormatterKit specifically for formatting time intervals (e.g., a post occurred "6h 15m ago" or "2 days ago"). The key bit is the "ago" suffix in a locale-sensitive way.

https://github.com/mattt/FormatterKit/blob/master/FormatterKit/TTTTimeIntervalFormatter.h#L81

DateComponentsFormatter provides rich formatting support, and include options for approximation & time remaining phrases. It would be great if it was enhanced to offer this support as well.

I've attached a Swift playground for illustrative purposes, in the event that it proves useful. Thanks for your time and consideration!

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!