Add >= and <= to Date - #2223
Conversation
Without these, we fall back on the default implementations from Comparable, which do not handle NaN correctly.
| } | ||
|
|
||
| /// Returns true if the left hand `Date` is earlier in time than or equal to the right hand `Date`. | ||
| public static func <=(lhs: Date, rhs: Date) -> Bool { |
There was a problem hiding this comment.
I think these will need to be @export(implementation) or @backDeployed since they can't have stricter availability than the protocol conformance, is that correct?
There was a problem hiding this comment.
IIRC the symbols are already there because the protocol requires them and provides defaults, so we shouldn't need availability, but we can export them and get the fix to more targets.
There was a problem hiding this comment.
Oh right sorry, I confused declarations that the compiler synthesizes (and creates the ABI symbol for) with default implementations inherited from extensions on the protocol (which don't create a symbol since it uses the symbol from the default implementation instead) - my bad.
I think @export(implementation) would actually now remove that symbol right? So maybe just leaving it as it was without availability is the way to go 😅
This way we can get the right behavior on older systems too (after a recompile).
Without these, Date falls back on the default implementations from Comparable, which do not handle NaN correctly.
Before this change, both
Date(timeIntervalSince1970: .nan) <= Date(timeIntervalSince1970: 0)andDate(timeIntervalSince1970: .nan) >= Date(timeIntervalSince1970: 0)would betrue. Now they are false.