Skip to content
Permalink
Browse files

Fix whitespace and formatting.

  • Loading branch information...
markstory committed May 13, 2012
1 parent a80a7da commit ca8046bfea49f988d090d670ed56b08bc1cb4486
Showing with 27 additions and 25 deletions.
  1. +2 −2 lib/Cake/Test/Case/Utility/CakeTimeTest.php
  2. +25 −23 lib/Cake/Utility/CakeTime.php
@@ -633,7 +633,7 @@ public function testWasWithinLast() {
$this->assertTrue($this->Time->wasWithinLast('1 ', '-1 minute'));
$this->assertTrue($this->Time->wasWithinLast('1 ', '-23 hours -59 minutes -59 seconds'));
}
/**
* testWasWithinLast method
*
@@ -677,7 +677,7 @@ public function testIsWithinNext() {
$this->assertFalse($this->Time->isWithinNext('1 ', '-1 hour'));
$this->assertFalse($this->Time->isWithinNext('1 ', '-1 minute'));
$this->assertFalse($this->Time->isWithinNext('1 ', '-23 hours -59 minutes -59 seconds'));
$this->assertTrue($this->Time->isWithinNext('7 days', '6 days, 23 hours, 59 minutes, 59 seconds'));
$this->assertFalse($this->Time->isWithinNext('7 days', '6 days, 23 hours, 59 minutes, 61 seconds'));
}
@@ -39,7 +39,7 @@ class CakeTime {
* @see CakeTime::format()
*/
public static $niceFormat = '%a, %b %eS %Y, %H:%M';
/**
* The format to use when formatting a time using `CakeTime::timeAgoInWords()`
* and the difference is more than `CakeTime::$wordEnd`
@@ -48,7 +48,7 @@ class CakeTime {
* @see CakeTime::timeAgoInWords()
*/
public static $wordFormat = 'j/n/y';
/**
* The format to use when formatting a time using `CakeTime::niceShort()`
* and the difference is between 3 and 7 days
@@ -57,7 +57,7 @@ class CakeTime {
* @see CakeTime::niceShort()
*/
public static $niceShortFormat = '%d/%m, %H:%M';
/**
* The format to use when formatting a time using `CakeTime::timeAgoInWords()`
* and the difference is less than `CakeTime::$wordEnd`
@@ -66,15 +66,15 @@ class CakeTime {
* @see CakeTime::timeAgoInWords()
*/
public static $wordAccuracy = array(
'year' => "day",
'month' => "day",
'week' => "day",
'day' => "hour",
'hour' => "minute",
'year' => "day",
'month' => "day",
'week' => "day",
'day' => "hour",
'hour' => "minute",
'minute' => "minute",
'second' => "second",
);
/**
* The end of relative time telling
*
@@ -375,10 +375,17 @@ public static function niceShort($dateString = null, $timezone = null) {
$date = $dateString ? self::fromString($dateString, $timezone) : time();
$y = self::isThisYear($date) ? '' : ' %Y';
$d = self::_strftime("%w", $date);
$day = array(__d('cake', 'Sunday'), __d('cake', 'Monday'), __d('cake', 'Tuesday'),
__d('cake', 'Wednesday'), __d('cake', 'Thursday'), __d('cake', 'Friday'), __d('cake', 'Saturday'));
$day = array(
__d('cake', 'Sunday'),
__d('cake', 'Monday'),
__d('cake', 'Tuesday'),
__d('cake', 'Wednesday'),
__d('cake', 'Thursday'),
__d('cake', 'Friday'),
__d('cake', 'Saturday')
);
if (self::isToday($dateString, $timezone)) {
$ret = __d('cake', 'Today, %s', self::_strftime("%H:%M", $date));
@@ -394,7 +401,6 @@ public static function niceShort($dateString = null, $timezone = null) {
$format = self::convertSpecifiers("%b %eS{$y}, %H:%M", $date);
$ret = self::_strftime($format, $date);
}
return $ret;
}
@@ -667,7 +673,7 @@ public static function timeAgoInWords($dateTime, $options = array()) {
$format = self::$wordFormat;
$end = self::$wordEnd;
$accuracy = self::$wordAccuracy;
if (is_array($options)) {
if (isset($options['userOffset'])) {
$timezone = $options['userOffset'];
@@ -735,7 +741,7 @@ public static function timeAgoInWords($dateTime, $options = array()) {
}
if ($future['m'] < $past['m'] && $future['Y'] - $past['Y'] == 1) {
$years --;
$years--;
}
}
}
@@ -753,13 +759,13 @@ public static function timeAgoInWords($dateTime, $options = array()) {
}
if ($future['m'] != $past['m']) {
$months --;
$months--;
}
}
if ($months == 0 && $years >= 1 && $diff < ($years * 31536000)) {
$months = 11;
$years --;
$years--;
}
if ($months >= 12) {
@@ -825,12 +831,11 @@ public static function timeAgoInWords($dateTime, $options = array()) {
if (self::wasWithinLast('7 days', $dateTime, $timezone) || self::isWithinNext('7 days', $dateTime, $timezone)) {
$relativeDate = self::niceShort($dateTime , $timezone);
}
// If now
if ($diff == 0) {
$relativeDate = __d('cake', 'just now', 'just now');
}
return $relativeDate;
}
@@ -856,10 +861,9 @@ public static function wasWithinLast($timeInterval, $dateString, $timezone = nul
if ($date >= $interval && $date <= time()) {
return true;
}
return false;
}
/**
* Returns true if specified datetime is within the interval specified, else false.
*
@@ -882,7 +886,6 @@ public static function isWithinNext($timeInterval, $dateString, $timezone = null
if ($date <= $interval && $date >= time()) {
return true;
}
return false;
}
@@ -905,7 +908,6 @@ public static function gmt($string = null) {
$month = intval(date("n", $string));
$day = intval(date("j", $string));
$year = intval(date("Y", $string));
return gmmktime($hour, $minute, $second, $month, $day, $year);
}

0 comments on commit ca8046b

Please sign in to comment.
You can’t perform that action at this time.