Created
December 6, 2012 16:57
-
-
Save bryanoltman/4226018 to your computer and use it in GitHub Desktop.
A simple category on NSDate to make comparison more human-readable
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
@interface NSDate (Comparators) | |
- (BOOL)isEarlierThan:(NSDate*)otherDate; | |
- (BOOL)isLaterThan:(NSDate*)otherDate; | |
@end | |
@implementation NSDate (Comparators) | |
- (BOOL)isEarlierThan:(NSDate*)otherDate | |
{ | |
return [self compare:otherDate] == NSOrderedAscending; | |
} | |
- (BOOL)isLaterThan:(NSDate*)otherDate | |
{ | |
return [self compare:otherDate] == NSOrderedDescending; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment