Test CPDate testInitWithString with a date prior to 1970.

This verifies that there are no problems with negative time intervals.
This commit is contained in:
Alexander Ljungberg
2012-06-02 13:18:58 -07:00
parent d0c7796e7c
commit 55709cb83a
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -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
+1
View File
@@ -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],