Permalink
Browse files

CakeTime functions can now use timezone string or DateTimeZone object…

… for user offsets. (Passing numeric offsets has been kept for BC)
  • Loading branch information...
ADmad committed Apr 11, 2012
1 parent 287c657 commit d34f0c2bd8f533052022f5c2105181ccb793f258
Showing with 156 additions and 123 deletions.
  1. +12 −0 lib/Cake/Test/Case/Utility/CakeTimeTest.php
  2. +90 −69 lib/Cake/Utility/CakeTime.php
  3. +54 −54 lib/Cake/View/Helper/TimeHelper.php
@@ -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));
}
}
}
@@ -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);
}
/**
@@ -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);
}
/**
Oops, something went wrong.

0 comments on commit d34f0c2

Please sign in to comment.