-
Notifications
You must be signed in to change notification settings - Fork 41
/
NSDate+SafeCompare.h
42 lines (31 loc) · 1.02 KB
/
NSDate+SafeCompare.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#import <Cocoa/Cocoa.h>
/*!
@ @brief defined to be NSOrderedAscending
@details So I don't have to look at documentation every
time I use -[NSDate compare:]
*/
#define NSDateIsEarlierThan NSOrderedAscending
/*!
@ @brief defined to be NSOrderedDescending
@details So I don't have to look at documentation every
time I use -[NSDate compare:]
*/
#define NSDateIsLaterThan NSOrderedDescending
/*
NSDate's instance methods such as -laterDate: may not give the
sensible result when one of the dates is nil. These class methods
give sensible results in all cases.
*/
@interface NSDate (SafeCompare)
/*!
@brief Returns the later of two dates, even if either is nil.
@details If either date is nil, returns the other date. If
both dates are nil, returns nil.
@result date1, date2, or nil.
*/
+ (NSDate*)laterDate:(NSDate*)date1
date:(NSDate*)date2 ;
+ (BOOL)isEqualHandlesNilDate1:(NSDate*)date1
date2:(NSDate*)date2
tolerance:(NSTimeInterval)tolerance ;
@end