mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Simplify compare
This commit is contained in:
parent
2e943461f8
commit
7accf04103
2 changed files with 23 additions and 19 deletions
|
@ -1,4 +1,3 @@
|
|||
|
||||
/* Definition of class NSDateInterval
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
|
|
|
@ -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…
Reference in a new issue