Small NSDate fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21517 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2005-07-22 19:36:33 +00:00
parent abb525365c
commit 5245059b2e
2 changed files with 20 additions and 5 deletions

View file

@ -1,3 +1,10 @@
2005-07-22 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSDate.m: ([isEqual:]),([isEqualToDate:]) change behavior to
match current MacOS-X rather than OpenStep spec, as the old version
was confusing and prevented dates being used as dictionary keys or
stored in sets properly.
2005-07-21 Adam Fedor <fedor@gnu.org>
* Version 1.11.0

View file

@ -1335,19 +1335,27 @@ GSTimeNow(void)
if (other == nil)
return NO;
if ([other isKindOfClass: abstractClass]
&& 1.0 > ABS(otherTime(self) - otherTime(other)))
&& otherTime(self) == otherTime(other))
return YES;
return NO;
}
/**
* Returns whether equal to other within one <code>NSTimeInterval</code> unit.
* Returns whether the receiver is exactly equal to other, to the limit
* of the NSTimeInterval precision.<br />
* This is the behavior of the current MacOS-X system, not that of the
* OpenStep specification (which counted two dates within a secfond of
* each other as being equal).<br />
* The old behavior meant that two dates equal to a third date were not
* necessarily equal to each other (confusing), and meant that there was
* no reasonable way to use a date as a dictionary key or store dates
* in a set.
*/
- (BOOL) isEqualToDate: (NSDate*)other
{
if (other == nil)
return NO;
if (1.0 > ABS(otherTime(self) - otherTime(other)))
if (otherTime(self) == otherTime(other))
return YES;
return NO;
}
@ -1473,7 +1481,7 @@ GSTimeNow(void)
if (other == nil)
return NO;
if ([other isKindOfClass: abstractClass]
&& 1.0 > ABS(_seconds_since_ref - otherTime(other)))
&& _seconds_since_ref == otherTime(other))
return YES;
return NO;
}
@ -1482,7 +1490,7 @@ GSTimeNow(void)
{
if (other == nil)
return NO;
if (1.0 > ABS(_seconds_since_ref - otherTime(other)))
if (_seconds_since_ref == otherTime(other))
return YES;
return NO;
}