mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-25 16:33:22 +00:00
Monotone-Parent: 73df13fd7742a193f9bf1842a6f410e95c3c2e91
Monotone-Revision: 9327fed453d6acee03f0449816dbb2b401353927 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-10-11T18:51:30 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -26,32 +26,49 @@
|
||||
|
||||
@implementation NSObject (SOGoAptComparison)
|
||||
|
||||
- (NSComparisonResult)compareAptsAscending:(id)_other {
|
||||
- (NSComparisonResult) compareAptsAscending: (id) _other
|
||||
{
|
||||
NSCalendarDate *sd, *ed;
|
||||
NGCalendarDateRange *r1, *r2;
|
||||
NSComparisonResult result;
|
||||
NSTimeInterval t1, t2;
|
||||
|
||||
sd = [self valueForKey:@"startDate"];
|
||||
ed = [self valueForKey:@"endDate"];
|
||||
r1 = [NGCalendarDateRange calendarDateRangeWithStartDate:sd
|
||||
endDate:ed];
|
||||
|
||||
sd = [_other valueForKey:@"startDate"];
|
||||
ed = [_other valueForKey:@"endDate"];
|
||||
r2 = [NGCalendarDateRange calendarDateRangeWithStartDate:sd
|
||||
endDate:ed];
|
||||
|
||||
result = [r1 compare:r2];
|
||||
if (result != NSOrderedSame)
|
||||
return result;
|
||||
|
||||
t1 = [r1 duration];
|
||||
t2 = [r2 duration];
|
||||
if (t1 == t2)
|
||||
return NSOrderedSame;
|
||||
if (t1 > t2)
|
||||
return NSOrderedDescending;
|
||||
|
||||
sd = [self valueForKey: @"startDate"];
|
||||
ed = [self valueForKey: @"endDate"];
|
||||
if (sd && ed)
|
||||
r1 = [NGCalendarDateRange calendarDateRangeWithStartDate: sd
|
||||
endDate: ed];
|
||||
else
|
||||
r1 = nil;
|
||||
|
||||
sd = [_other valueForKey: @"startDate"];
|
||||
ed = [_other valueForKey: @"endDate"];
|
||||
if (sd && ed)
|
||||
r2 = [NGCalendarDateRange calendarDateRangeWithStartDate: sd
|
||||
endDate: ed];
|
||||
else
|
||||
r2 = nil;
|
||||
|
||||
if (r1)
|
||||
if (r2)
|
||||
{
|
||||
result = [r1 compare: r2];
|
||||
if (result != NSOrderedSame)
|
||||
return result;
|
||||
|
||||
t1 = [r1 duration];
|
||||
t2 = [r2 duration];
|
||||
if (t1 == t2)
|
||||
return NSOrderedSame;
|
||||
if (t1 > t2)
|
||||
return NSOrderedDescending;
|
||||
}
|
||||
else
|
||||
return NSOrderedDescending;
|
||||
else
|
||||
if (!r2)
|
||||
return NSOrderedSame;
|
||||
|
||||
return NSOrderedAscending;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user