Raise exception if smeone tries to initialise a date with NaN

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26865 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2008-09-23 08:22:15 +00:00
parent 132c0a285d
commit 7da55c5e34
3 changed files with 17 additions and 0 deletions

View file

@ -46,6 +46,8 @@
#include "GSPrivate.h"
#include <math.h>
/* These constants seem to be what MacOS-X uses */
#define DISTANT_FUTURE 63113990400.0
#define DISTANT_PAST -63113817600.0
@ -1354,6 +1356,12 @@ otherTime(NSDate* other)
- (id) initWithTimeIntervalSinceReferenceDate: (NSTimeInterval)secs
{
if (isnan(secs))
{
[NSException raise: NSInvalidArgumentException
format: @"[%@-%@] interval is not a number",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
}
_seconds_since_ref = secs;
return self;
}