Skip to content

Commit

Permalink
Change secondary bias
Browse files Browse the repository at this point in the history
  • Loading branch information
hmelder committed Sep 24, 2024
1 parent 26e0e52 commit 9ea2887
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 9 additions & 7 deletions Source/NSDate.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@

// 1-5 are already used by NSNumber and GSString
#define SMALL_DATE_MASK 6
#define EXPONENT_BIAS 0x3FF
#define EXPONENT_BIAS 0x3EF

#define GET_INTERVAL(obj) decompressTimeInterval((uintptr_t)obj)
#define SET_INTERVAL(obj, interval) (obj = (id)(compressTimeInterval(interval) | SMALL_DATE_MASK))
Expand Down Expand Up @@ -257,6 +257,11 @@ - (id) copy
return self;
}

- (id) copyWithZone: (NSZone*)aZone
{
return self;
}

- (id) retain
{
return self;
Expand Down Expand Up @@ -332,8 +337,7 @@ - (id) initWithTimeIntervalSinceReferenceDate: (NSTimeInterval)secs
}
#endif

SET_INTERVAL(self, secs);
return self;
return CREATE_SMALL_DATE(secs);
}

- (id) initWithCoder: (NSCoder*)coder
Expand All @@ -349,9 +353,7 @@ - (id) initWithCoder: (NSCoder*)coder
at: &secondsSinceRef];
}

SET_INTERVAL(self, secondsSinceRef);

return self;
return CREATE_SMALL_DATE(secondsSinceRef);
}

// NSDate Hashing, Comparison and Equality
Expand Down Expand Up @@ -1494,7 +1496,7 @@ + (instancetype) distantFuture
if (_distantFuture == nil)
{
#if USE_SMALL_DATE
_distantPast = CREATE_SMALL_DATE(DISTANT_FUTURE);
_distantFuture = CREATE_SMALL_DATE(DISTANT_FUTURE);
#else
_distantFuture = [GSDateFuture allocWithZone: 0];
#endif
Expand Down
3 changes: 2 additions & 1 deletion Tests/base/NSFileManager/general.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#ifdef EQ
#undef EQ
#endif
#define EPSILON (FLT_EPSILON*100)
#define EPSILON (DBL_EPSILON*100)
#define EQ(x,y) ((x >= y - EPSILON) && (x <= y + EPSILON))

@interface MyHandler : NSObject
Expand Down Expand Up @@ -204,6 +204,7 @@ int main()
NSTimeInterval ot, nt;
ot = [[oa fileCreationDate] timeIntervalSinceReferenceDate];
nt = [[na fileCreationDate] timeIntervalSinceReferenceDate];
NSLog(@"ot = %f, nt = %f", ot, nt);
PASS(EQ(ot, nt), "copy creation date equals original")
ot = [[oa fileModificationDate] timeIntervalSinceReferenceDate];
nt = [[na fileModificationDate] timeIntervalSinceReferenceDate];
Expand Down

0 comments on commit 9ea2887

Please sign in to comment.