mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
@@ -146,6 +146,15 @@ var CPDateReferenceDate = new Date(Date.UTC(2001, 0, 1, 0, 0, 0, 0));
|
||||
return [[CPDate date] timeIntervalSinceReferenceDate];
|
||||
}
|
||||
|
||||
/**
|
||||
Return a new date representing the receiver's time plus the given interval into the future,
|
||||
or into the past for a negative interval.
|
||||
*/
|
||||
- (id)dateByAddingTimeInterval:(CPTimeInterval)seconds
|
||||
{
|
||||
return [[CPDate alloc] initWithTimeInterval:seconds sinceDate:self];
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(CPDate)aDate
|
||||
{
|
||||
if (self === aDate)
|
||||
|
||||
@@ -35,6 +35,30 @@
|
||||
[self assert:middle equals:[middle laterDate:past] message:"laterDate incorrect"];
|
||||
}
|
||||
|
||||
- (void)testDateByAddingTimeIntervalZeroShouldReturnSameDate
|
||||
{
|
||||
var a = [CPDate dateWithTimeIntervalSince1970:1231889490.0],
|
||||
b = [a dateByAddingTimeInterval:0];
|
||||
|
||||
[self assert:[b timeIntervalSince1970] equals:1231889490];
|
||||
}
|
||||
|
||||
- (void)testDateByAddingTimeIntervalPositiveShouldReturnNewerDate
|
||||
{
|
||||
var a = [CPDate dateWithTimeIntervalSince1970:1231889490.0],
|
||||
b = [a dateByAddingTimeInterval:789];
|
||||
|
||||
[self assert:[b timeIntervalSince1970] equals:1231889490 + 789];
|
||||
}
|
||||
|
||||
- (void)testDateByAddingTimeIntervalNegativeShouldReturnOlderDate
|
||||
{
|
||||
var a = [CPDate dateWithTimeIntervalSince1970:1231889490.0],
|
||||
b = [a dateByAddingTimeInterval:-789];
|
||||
|
||||
[self assert:[b timeIntervalSince1970] equals:1231889490 - 789];
|
||||
}
|
||||
|
||||
- (void)testEquals
|
||||
{
|
||||
var now = [CPDate date];
|
||||
|
||||
Reference in New Issue
Block a user