FOUNDATION_EXPORTNSString *const NSSystemClockDidChangeNotificationNS_AVAILABLE(10_6,4_0);
@interface NSDate (NSExtendedDate)
// 时间间隔
@property (readonly)NSTimeInterval timeIntervalSinceNow;
@property (readonly)NSTimeInterval timeIntervalSince1970;
+ (NSTimeInterval)timeIntervalSinceReferenceDate;
- (NSTimeInterval)timeIntervalSinceDate:(NSDate *)anotherDate;
[date1 timeIntervalSinceNow];
[date1 timeIntervalSince1970];
[date1 timeIntervalSinceReferenceDate];
[date1 timeIntervalSinceDate:date1];
// 拼接时间间隔
- (instancetype)dateByAddingTimeInterval:(NSTimeInterval)tiNS_AVAILABLE(10_6,2_0);
NSDate *date = [date1 dateByAddingTimeInterval:60];
//判断 返回符合条件的 date
- (NSDate *)earlierDate:(NSDate *)anotherDate;
- (NSDate *)laterDate:(NSDate *)anotherDate;
// NSDate *date = [date1 earlierDate:date2];
NSDate *date = [date2 laterDate:date1];
//比较时间先后顺序
- (NSComparisonResult)compare:(NSDate *)other;
- (BOOL)isEqualToDate:(NSDate *)otherDate;
NSComparisonResult comper = [date1 compare:date2];
if (comper == NSOrderedAscending) {
NSLog(@"升");
}else if (comper == NSOrderedSame){
NSLog(@"same");
}else if (comper == NSOrderedDescending){
NSLog(@"降");
}else{
NSLog(@"error");
}
if ([date1 isEqualToDate:date2]) {
NSLog(@"eq");
}else{
NSLog(@"noeq");
}
// 0 时区 的时间 现在 (本地化时间 研究 NSLocale)
@property (readonly, copy) NSString *description;
- (NSString *)descriptionWithLocale:(id)locale;
NSLog(@"description:%@",date1.description);
NSLog(@"description:%@",[date1 descriptionWithLocale:@8]);
@end