From d0c7796e7c0f543485cd29d6250ebd7ddf70e158 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Sat, 2 Jun 2012 13:17:34 -0700 Subject: [PATCH] Match CPDate distantPast and distantFuture with Cocoa. --- Foundation/CPDate.j | 4 ++-- Tests/Foundation/CPDateTest.j | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Foundation/CPDate.j b/Foundation/CPDate.j index 7825a4a97..bd86a42f1 100644 --- a/Foundation/CPDate.j +++ b/Foundation/CPDate.j @@ -64,12 +64,12 @@ var CPDateReferenceDate = new Date(Date.UTC(2001, 0, 1, 0, 0, 0, 0)); + (id)distantPast { - return new Date(-10000, 1, 1, 0, 0, 0, 0); + return [CPDate dateWithTimeIntervalSinceReferenceDate:-63113817600.0]; } + (id)distantFuture { - return new Date(10000, 1, 1, 0, 0, 0, 0); + return [CPDate dateWithTimeIntervalSinceReferenceDate:63113990400.0]; } - (id)initWithTimeIntervalSinceNow:(CPTimeInterval)seconds diff --git a/Tests/Foundation/CPDateTest.j b/Tests/Foundation/CPDateTest.j index 48a514923..343d2227a 100644 --- a/Tests/Foundation/CPDateTest.j +++ b/Tests/Foundation/CPDateTest.j @@ -10,6 +10,16 @@ [self assertTrue:[unixDate isEqualToDate:cocoaDate] message:[unixDate description] + " isEqualToDate: " + [cocoaDate description]]; } +- (void)testDistantPast +{ + [self assert:[CPDate dateWithTimeIntervalSinceReferenceDate:-63113817600.0] equals:[CPDate distantPast]]; +} + +- (void)testDistantFuture +{ + [self assert:[CPDate dateWithTimeIntervalSinceReferenceDate:63113990400.0] equals:[CPDate distantFuture]]; +} + - (void)testDate { var before = new Date(),