Skip to content

Commit

Permalink
Fixed return type of toQuarter in CakeTime and TimeHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdriel committed Mar 2, 2015
1 parent a6ceec1 commit ed5da19
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/Cake/Test/Case/Utility/CakeTimeTest.php
Expand Up @@ -72,13 +72,13 @@ protected function _restoreSystemTimezone() {
*/ */
public function testToQuarter() { public function testToQuarter() {
$result = $this->Time->toQuarter('2007-12-25'); $result = $this->Time->toQuarter('2007-12-25');
$this->assertEquals(4, $result); $this->assertSame(4, $result);


$result = $this->Time->toQuarter('2007-9-25'); $result = $this->Time->toQuarter('2007-9-25');
$this->assertEquals(3, $result); $this->assertSame(3, $result);


$result = $this->Time->toQuarter('2007-3-25'); $result = $this->Time->toQuarter('2007-3-25');
$this->assertEquals(1, $result); $this->assertSame(1, $result);


$result = $this->Time->toQuarter('2007-3-25', true); $result = $this->Time->toQuarter('2007-3-25', true);
$this->assertEquals(array('2007-01-01', '2007-03-31'), $result); $this->assertEquals(array('2007-01-01', '2007-03-31'), $result);
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Utility/CakeTime.php
Expand Up @@ -575,12 +575,12 @@ public static function isTomorrow($dateString, $timezone = null) {
* *
* @param int|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object * @param int|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param bool $range if true returns a range in Y-m-d format * @param bool $range if true returns a range in Y-m-d format
* @return mixed 1, 2, 3, or 4 quarter of year or array if $range true * @return int|array 1, 2, 3, or 4 quarter of year or array if $range true
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toQuarter * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toQuarter
*/ */
public static function toQuarter($dateString, $range = false) { public static function toQuarter($dateString, $range = false) {
$time = self::fromString($dateString); $time = self::fromString($dateString);
$date = ceil(date('m', $time) / 3); $date = (int)ceil(date('m', $time) / 3);
if ($range === false) { if ($range === false) {
return $date; return $date;
} }
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper/TimeHelper.php
Expand Up @@ -316,7 +316,7 @@ public function isTomorrow($dateString, $timezone = null) {
* *
* @param int|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object * @param int|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param bool $range if true returns a range in Y-m-d format * @param bool $range if true returns a range in Y-m-d format
* @return mixed 1, 2, 3, or 4 quarter of year or array if $range true * @return int|array 1, 2, 3, or 4 quarter of year or array if $range true
* @see CakeTime::toQuarter() * @see CakeTime::toQuarter()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
*/ */
Expand Down

0 comments on commit ed5da19

Please sign in to comment.