Created
August 4, 2015 10:16
-
-
Save tonyedwardspz/9d9ecce60d4dd3aa26c8 to your computer and use it in GitHub Desktop.
Swift Dates plyground
This file contains 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
var date = NSDate() | |
var yesterday = date.dateByAddingTimeInterval(-24 * 60 * 60) | |
var dateComparisonResult: NSComparisonResult = date.compare(yesterday) | |
if dateComparisonResult == NSComparisonResult.OrderedAscending { | |
println("date is smaller than yesterday") | |
} else if dateComparisonResult == NSComparisonResult.OrderedDescending { | |
println("date is larger than yesterday") | |
} else { | |
println("Both dates are the smae") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment