Skip to content

Commit

Permalink
CakeTime functions can now use timezone string or DateTimeZone object…
Browse files Browse the repository at this point in the history
… for user offsets. (Passing numeric offsets has been kept for BC)
  • Loading branch information
ADmad committed Apr 21, 2012
1 parent 287c657 commit d34f0c2
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 123 deletions.
12 changes: 12 additions & 0 deletions lib/Cake/Test/Case/Utility/CakeTimeTest.php
Expand Up @@ -418,6 +418,7 @@ public function testToRss() {
$yourTime = new DateTime('now', $yourTimezone);
$userOffset = $yourTimezone->getOffset($yourTime) / HOUR;
$this->assertEquals($yourTime->format('r'), $this->Time->toRss(time(), $userOffset));
$this->assertEquals($yourTime->format('r'), $this->Time->toRss(time(), $timezone));
}
}
}
Expand Down Expand Up @@ -623,6 +624,12 @@ public function testUserOffset() {
$expected = time();
$result = $this->Time->fromString(time(), $yourTimezone);
$this->assertEquals($expected, $result);

$result = $this->Time->fromString(time(), $timezoneServer->getName());
$this->assertEquals($expected, $result);

$result = $this->Time->fromString(time(), $timezoneServer);
$this->assertEquals($expected, $result);
}

/**
Expand All @@ -645,6 +652,11 @@ public function testFromString() {
$result = $this->Time->fromString('+1 hour', $timezone);
$expected = $this->Time->convert(strtotime('+1 hour'), $timezone);
$this->assertEquals($expected, $result);

$timezone = date_default_timezone_get();
$result = $this->Time->fromString('+1 hour', $timezone);
$expected = $this->Time->convert(strtotime('+1 hour'), $timezone);
$this->assertEquals($expected, $result);
}

/**
Expand Down

0 comments on commit d34f0c2

Please sign in to comment.