Skip to content

Instantly share code, notes, and snippets.

@bryanoltman
Created December 6, 2012 16:57
Show Gist options
  • Save bryanoltman/4226018 to your computer and use it in GitHub Desktop.
Save bryanoltman/4226018 to your computer and use it in GitHub Desktop.
A simple category on NSDate to make comparison more human-readable
@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