Hacker News new | ask | show | jobs
by gh123man 1546 days ago
In swift I quite like DispatchTimeInterval's approach [1] (see Enumeration Cases). In most of my projects I end up adding a simple extension to TimeInterval to get the same behavior. Which makes reasoning about time very simple eg:

  Date().advanced(by: .hours(2) + .seconds(10))
I'm honestly not sure why TimeInterval doesn't include this representation by default.

1. https://developer.apple.com/documentation/dispatch/dispatcht...