Created
April 8, 2013 23:24
-
-
Save nall/5341477 to your computer and use it in GitHub Desktop.
Relational operators for NSDate* objects
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
// | |
// NSDate+SZRelationalOperators.h | |
// | |
// Created by Jon Nall on 12/8/09. | |
// Copyright 2009 STUNTAZ!!! All rights reserved. | |
// | |
// Category to help make comparing NSDates a bit more readable | |
@interface NSDate(SZRelationalOperators) | |
-(BOOL)isLessThan:(NSDate*)theDate; | |
-(BOOL)isLessThanOrEqualTo:(NSDate*)theDate; | |
-(BOOL)isGreaterThan:(NSDate*)theDate; | |
-(BOOL)isGreaterThanOrEqualTo:(NSDate*)theDate; | |
@end |
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
// | |
// NSDate+SZRelationalOperators.m | |
// | |
// Created by Jon Nall on 12/8/09. | |
// Copyright 2009 STUNTAZ!!! All rights reserved. | |
// | |
#import "NSDate+SZRelationalOperators.h" | |
@implementation NSDate(SZRelationalOperators) | |
-(BOOL)isLessThan:(NSDate*)theDate | |
{ | |
return [self compare:theDate] == NSOrderedAscending; | |
} | |
-(BOOL)isLessThanOrEqualTo:(NSDate*)theDate | |
{ | |
return [self compare:theDate] != NSOrderedDescending; | |
} | |
-(BOOL)isGreaterThan:(NSDate*)theDate | |
{ | |
return [self compare:theDate] == NSOrderedDescending; | |
} | |
-(BOOL)isGreaterThanOrEqualTo:(NSDate*)theDate | |
{ | |
return [self compare:theDate] != NSOrderedAscending; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment