mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 08:26:27 +00:00
Date interval fixes
This commit is contained in:
parent
ea21e48218
commit
0eb0c75022
1 changed files with 13 additions and 0 deletions
|
@ -25,6 +25,7 @@
|
|||
#include <Foundation/NSDateInterval.h>
|
||||
#include <Foundation/NSDate.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSException.h>
|
||||
|
||||
@implementation NSDateInterval
|
||||
|
||||
|
@ -48,7 +49,13 @@
|
|||
if(self != nil)
|
||||
{
|
||||
ASSIGNCOPY(_startDate, startDate);
|
||||
if(duration < 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Duration %f is less than zero", duration];
|
||||
}
|
||||
_duration = duration;
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -61,6 +68,12 @@
|
|||
{
|
||||
ASSIGNCOPY(_startDate, startDate);
|
||||
_duration = [endDate timeIntervalSinceDate: startDate];
|
||||
if(_duration < 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Duration %f is less than zero", _duration];
|
||||
}
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue