Skip to content

Commit

Permalink
Further improved date comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
nrbrook authored and ffried committed May 16, 2023
1 parent 31f3ff9 commit 448f131
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions Sources/CocoaLumberjack/DDFileLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -1784,22 +1784,21 @@ - (NSUInteger)hash {
return [filePath hash];
}

- (NSComparisonResult)reverseCompareByCreationDate:(DDLogFileInfo *)another {
__auto_type us = [self creationDate];
__auto_type them = [another creationDate];
if (us != nil) {
- (NSComparisonResult)reverseCompareDatesUs:(NSDate *_Nullable)us them:(NSDate *_Nullable)them {
if (us != nil && them != nil) {
return [them compare:(NSDate * _Nonnull)us];
} else if (us == nil && them == nil) {
return NSOrderedSame;
}
return NSOrderedSame;
return them == nil ? NSOrderedAscending : NSOrderedDescending;
}

- (NSComparisonResult)reverseCompareByCreationDate:(DDLogFileInfo *)another {
return [self reverseCompareDatesUs:[self creationDate] them:[another creationDate]];
}

- (NSComparisonResult)reverseCompareByModificationDate:(DDLogFileInfo *)another {
__auto_type us = [self modificationDate];
__auto_type them = [another modificationDate];
if (us != nil) {
return [them compare:(NSDate * _Nonnull)us];
}
return NSOrderedSame;
return [self reverseCompareDatesUs:[self modificationDate] them:[another modificationDate]];
}

@end
Expand Down

0 comments on commit 448f131

Please sign in to comment.