[swift-corelibs-dev] [swift-evolution] Proposal: Conforming NSDate to Comparable
James Lee
james at jelee.co.uk
Fri Dec 11 14:42:13 CST 2015
Hi all,
I wanted to pick up on this as I have done some work on implementing the comparable protocol for NSDate in a PR (119)
I fully agree that comparable should be implemented generally when comparing dates I want to know if it is one case. The current implementation feels clunky to use, especially isEqualTo:
I can see points where getting the enum value can be valuable for instance a switch control flow and don't think the current API should be deprecated immediately, but using the comparable operators feels more readable and fits in more with swift's style.
Strideable also seems very fitting and having looked up the reference, would cover comparable and equatable as well. I also feel that there could be some sort of enum built that would return the TimeInterval value for the human readable version. For example advanceBy(.Day) would fit dateByAddingTimeInterval(86400)
More information about the swift-corelibs-dev
mailing list