Remove _endDate from NSDateInterval

This commit is contained in:
Gregory John Casamento 2019-10-21 16:55:51 -04:00
parent 66277860cc
commit f34c95edda
2 changed files with 6 additions and 7 deletions

View file

@ -48,7 +48,6 @@
if(self != nil)
{
ASSIGNCOPY(_startDate, startDate);
ASSIGNCOPY(_endDate, [startDate dateByAddingTimeInterval: duration]);
_duration = duration;
}
return self;
@ -102,12 +101,11 @@
- (NSDate *) endDate
{
return _endDate;
return [_startDate dateByAddingTimeInterval: _duration];
}
- (void) setEndDate: (NSDate *)endDate
{
ASSIGNCOPY(_endDate, endDate);
_duration = [endDate timeIntervalSinceDate: _startDate];
}
@ -118,9 +116,7 @@
- (void) setDuration: (NSTimeInterval)duration
{
NSDate *newEndDate = [_startDate dateByAddingTimeInterval: duration];
_duration = duration;
[self setEndDate: newEndDate];
}
// Compare
@ -206,10 +202,11 @@
// Contain
- (BOOL) containsDate: (NSDate *)date
{
NSDate *endDate = [self endDate];
return ([_startDate compare: date] == NSOrderedSame ||
[_endDate compare: date] == NSOrderedSame ||
[endDate compare: date] == NSOrderedSame ||
([_startDate compare: date] == NSOrderedAscending &&
[_endDate compare: date] == NSOrderedDescending));
[endDate compare: date] == NSOrderedDescending));
}

View file

@ -220,6 +220,8 @@
constant: constant];
NSDimension *result = [[[self class] alloc] initWithSymbol: symbol
converter: converter];
AUTORELEASE(converter);
AUTORELEASE(result);
return result;
}