From 26f7e4b33d87fe12e10635858070d254c63efe80 Mon Sep 17 00:00:00 2001 From: rfm Date: Fri, 4 Nov 2011 10:38:16 +0000 Subject: [PATCH] SX compatibility tweak ... allow nil arg for -timeIntervalSinceDate: git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34117 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/NSDate.m | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e5c8e5aad..4aa624fa7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-04 Richard Frith-Macdonald + + * Source/NSDate.m: ([-timeIntervalSinceDate:]) return NaN if other + date is nil (OSX compatibility). + 2011-11-02 Richard Frith-Macdonald * Source/NSNumber.m: Fix alignment error when encoding/decoding ... diff --git a/Source/NSDate.m b/Source/NSDate.m index 4d7769859..3f56ff573 100644 --- a/Source/NSDate.m +++ b/Source/NSDate.m @@ -1226,15 +1226,20 @@ otherTime(NSDate* other) /** * Returns the time interval between the receivers value and that of the * otherDate argument. If otherDate is earlier than the receiver, the - * returned value will be positive, if it is later it will be negative. + * returned value will be positive, if it is later it will be negative.
+ * For current (2011) OSX compatibility, this method returns NaN if otherDate + * is nil ... do not write code depending on that behavior. */ - (NSTimeInterval) timeIntervalSinceDate: (NSDate*)otherDate { if (otherDate == nil) + return nan(""); +/* { [NSException raise: NSInvalidArgumentException format: @"nil argument for timeIntervalSinceDate:"]; } +*/ return otherTime(self) - otherTime(otherDate); }