Created
January 20, 2018 16:18
-
-
Save ishabazz/f5f5dbd811fd58e3855e8f99fa15a6f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func < (lhs:Date?, rhs:Date?) -> Bool { | |
let answer = false | |
if let lhs = lhs{ | |
if let rhs = rhs{ | |
return lhs.isBefore(date: rhs) | |
} | |
} | |
return answer | |
} | |
public func > (lhs:Date?, rhs:Date?) -> Bool { | |
let answer = false | |
if let lhs = lhs{ | |
if let rhs = rhs{ | |
return lhs.isAfter(date: rhs) | |
} | |
} | |
return answer | |
} | |
extension Date{ | |
func isBefore(date:Date?) -> Bool { | |
if let date = date { | |
if self.compare(date) == ComparisonResult.orderedAscending { | |
return true | |
} | |
} | |
return false | |
} | |
func isAfter(date:Date?) -> Bool { | |
let answer = false | |
if let date = date { | |
if self.compare(date) == ComparisonResult.orderedAscending { | |
return true | |
} | |
} | |
return answer | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment