mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Simplify compare
This commit is contained in:
parent
2e943461f8
commit
7accf04103
2 changed files with 23 additions and 19 deletions
|
@ -134,27 +134,32 @@
|
|||
// Compare
|
||||
- (NSComparisonResult) compare: (NSDateInterval *)dateInterval
|
||||
{
|
||||
// NSOrderedAscending
|
||||
NSComparisonResult result = NSOrderedSame;
|
||||
|
||||
if([_startDate isEqualToDate: [dateInterval startDate]] &&
|
||||
_duration < [dateInterval duration])
|
||||
return NSOrderedAscending;
|
||||
{
|
||||
result = NSOrderedAscending;
|
||||
}
|
||||
else if([_startDate compare: [dateInterval startDate]] == NSOrderedAscending)
|
||||
{
|
||||
result = NSOrderedAscending;
|
||||
}
|
||||
else if([self isEqualToDateInterval: dateInterval])
|
||||
{
|
||||
result = NSOrderedSame;
|
||||
}
|
||||
else if([_startDate isEqualToDate: [dateInterval startDate]] &&
|
||||
_duration > [dateInterval duration])
|
||||
{
|
||||
result = NSOrderedDescending;
|
||||
}
|
||||
else if([_startDate compare: [dateInterval startDate]] == NSOrderedDescending)
|
||||
{
|
||||
result = NSOrderedDescending;
|
||||
}
|
||||
|
||||
if([_startDate compare: [dateInterval startDate]] == NSOrderedAscending)
|
||||
return NSOrderedAscending;
|
||||
|
||||
// NSOrderedSame
|
||||
if([self isEqualToDateInterval: dateInterval])
|
||||
return NSOrderedSame;
|
||||
|
||||
// NSOrderedDescending
|
||||
if([_startDate isEqualToDate: [dateInterval startDate]] &&
|
||||
_duration > [dateInterval duration])
|
||||
return NSOrderedDescending;
|
||||
|
||||
if([_startDate compare: [dateInterval startDate]] == NSOrderedDescending)
|
||||
return NSOrderedDescending;
|
||||
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
- (BOOL) isEqualToDateInterval: (NSDateInterval *)dateInterval
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue