Merge branch 'jake' into loader

This commit is contained in:
Francisco Ryan Tolmasky I
2010-02-09 01:03:37 -08:00
2 changed files with 30 additions and 9 deletions
+10 -5
View File
@@ -26,7 +26,7 @@
var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0));
/*!
/*!
@class CPDate
@ingroup foundation
@brief A representation of a single point in time.
@@ -34,7 +34,7 @@ var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0));
*/
@implementation CPDate : CPObject
{
{
}
+ (id)alloc
@@ -52,7 +52,7 @@ var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0));
return [[CPDate alloc] initWithTimeIntervalSinceNow:seconds];
}
+ (id)dateWithTimeIntervalSince1970:(CPTimeInterval)seconds
+ (id)dateWithTimeIntervalSince1970:(CPTimeInterval)seconds
{
return [[CPDate alloc] initWithTimeIntervalSince1970:seconds];
}
@@ -116,7 +116,7 @@ var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0));
date.setHours(d[4]);
date.setMinutes(d[5]);
date.setSeconds(d[6]);
self = new Date(date.getTime() + (timeZoneOffset - date.getTimezoneOffset()) * 60 * 1000);
return self;
}
@@ -172,7 +172,7 @@ var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0));
}
/*!
Returns the date as a string in the international format
Returns the date as a string in the international format
YYYY-MM-DD HH:MM:SS ±HHMM.
*/
- (CPString)description
@@ -183,6 +183,11 @@ var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0));
return [CPString stringWithFormat:@"%04d-%02d-%02d %02d:%02d:%02d +%02d%02d", self.getFullYear(), self.getMonth()+1, self.getDate(), self.getHours(), self.getMinutes(), self.getSeconds(), hours, minutes];
}
- (id)copy
{
return new Date(self.getTime());
}
@end
var CPDateTimeKey = @"CPDateTimeKey";
+20 -4
View File
@@ -2,7 +2,7 @@
@implementation CPDateTest : OJTestCase
- (void)testSince1970
- (void)testSince1970
{
/* These two dates should be equal to Fri Feb 13 2009 15:31:30 GMT-0800 */
unixDate = [CPDate dateWithTimeIntervalSince1970: 1234567890];
@@ -17,10 +17,10 @@
var after = new Date();
var future = [CPDate distantFuture];
var past = [CPDate distantPast];
[self assertTrue:(before <= middle) message:"before not less than middle"];
[self assertTrue:(middle <= after) message:"middle not less than after ("+middle+","+after+")"];
[self assert:middle equals:[middle earlierDate:future] message:"earlierDate incorrect"];
[self assert:middle equals:[middle laterDate:past] message:"laterDate incorrect"];
}
@@ -34,7 +34,7 @@
["1970-01-02 00:00:00 +0000", 24*60*60],
["2009-11-17 17:52:04 +0000", 1258480324],
];
for (var i = 0; i < tests.length; i++)
{
var parsed = [[CPDate alloc] initWithString:tests[i][0]];
@@ -63,4 +63,20 @@
[self assert:expectedString equals: [[CPDate dateWithTimeIntervalSince1970: 1234567890] description]];
}
- (void)testCopy
{
var original = [[CPDate alloc] initWithString:"2009-11-17 17:52:04 +0000"],
original2 = [[CPDate alloc] initWithString:"2009-11-17 17:52:04 +0000"],
copy = [original copy];
// Now they're the same...
[self assert:original equals:original2];
[self assert:copy equals:original2];
original.setFullYear(2008);
// Now they better not be.
[self assert:original notEqual:original2];
[self assert:copy equals:original2];
}
@end