From 55709cb83a4e81eea90d36053e0a21b5fd4e44e5 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Sat, 2 Jun 2012 13:18:58 -0700 Subject: [PATCH] Test CPDate testInitWithString with a date prior to 1970. This verifies that there are no problems with negative time intervals. --- Foundation/CPDate.j | 4 ++-- Tests/Foundation/CPDateTest.j | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Foundation/CPDate.j b/Foundation/CPDate.j index bd86a42f1..86bf25deb 100644 --- a/Foundation/CPDate.j +++ b/Foundation/CPDate.j @@ -167,7 +167,7 @@ var CPDateReferenceDate = new Date(Date.UTC(2001, 0, 1, 0, 0, 0, 0)); - (CPComparisonResult)compare:(CPDate)anotherDate { - return (self > anotherDate) ? CPOrderedDescending : ((self < anotherDate) ? CPOrderedAscending : CPOrderedSame); + return (self > anotherDate) ? CPOrderedDescending : ((self < anotherDate) ? CPOrderedAscending : CPOrderedSame); } - (CPDate)earlierDate:(CPDate)anotherDate @@ -198,7 +198,7 @@ var CPDateReferenceDate = new Date(Date.UTC(2001, 0, 1, 0, 0, 0, 0)); */ - (CPString)description { - return [CPString stringWithFormat:@"%04d-%02d-%02d %02d:%02d:%02d %s", self.getFullYear(), self.getMonth()+1, self.getDate(), self.getHours(), self.getMinutes(), self.getSeconds(), [CPDate timezoneOffsetString:self.getTimezoneOffset()]]; + return [CPString stringWithFormat:@"%04d-%02d-%02d %02d:%02d:%02d %s", self.getFullYear(), self.getMonth() + 1, self.getDate(), self.getHours(), self.getMinutes(), self.getSeconds(), [CPDate timezoneOffsetString:self.getTimezoneOffset()]]; } - (id)copy diff --git a/Tests/Foundation/CPDateTest.j b/Tests/Foundation/CPDateTest.j index 343d2227a..d719eee85 100644 --- a/Tests/Foundation/CPDateTest.j +++ b/Tests/Foundation/CPDateTest.j @@ -59,6 +59,7 @@ - (void)testInitWithString { var tests = [ + ["1800-01-01 00:00:00 +0000", -5364662400], ["1970-01-01 00:00:00 +0000", 0], ["1970-01-01 00:01:00 +0000", 60], ["1970-01-01 01:00:00 +0000", 60 * 60],