Fix whitespace and formatting.

This commit is contained in:
mark_story 2012-05-12 21:25:57 -04:00
parent a80a7dadf8
commit ca8046bfea
2 changed files with 27 additions and 25 deletions

View file

@ -633,7 +633,7 @@ class CakeTimeTest extends CakeTestCase {
$this->assertTrue($this->Time->wasWithinLast('1 ', '-1 minute')); $this->assertTrue($this->Time->wasWithinLast('1 ', '-1 minute'));
$this->assertTrue($this->Time->wasWithinLast('1 ', '-23 hours -59 minutes -59 seconds')); $this->assertTrue($this->Time->wasWithinLast('1 ', '-23 hours -59 minutes -59 seconds'));
} }
/** /**
* testWasWithinLast method * testWasWithinLast method
* *
@ -677,7 +677,7 @@ class CakeTimeTest extends CakeTestCase {
$this->assertFalse($this->Time->isWithinNext('1 ', '-1 hour')); $this->assertFalse($this->Time->isWithinNext('1 ', '-1 hour'));
$this->assertFalse($this->Time->isWithinNext('1 ', '-1 minute')); $this->assertFalse($this->Time->isWithinNext('1 ', '-1 minute'));
$this->assertFalse($this->Time->isWithinNext('1 ', '-23 hours -59 minutes -59 seconds')); $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->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')); $this->assertFalse($this->Time->isWithinNext('7 days', '6 days, 23 hours, 59 minutes, 61 seconds'));
} }

View file

@ -39,7 +39,7 @@ class CakeTime {
* @see CakeTime::format() * @see CakeTime::format()
*/ */
public static $niceFormat = '%a, %b %eS %Y, %H:%M'; public static $niceFormat = '%a, %b %eS %Y, %H:%M';
/** /**
* The format to use when formatting a time using `CakeTime::timeAgoInWords()` * The format to use when formatting a time using `CakeTime::timeAgoInWords()`
* and the difference is more than `CakeTime::$wordEnd` * and the difference is more than `CakeTime::$wordEnd`
@ -48,7 +48,7 @@ class CakeTime {
* @see CakeTime::timeAgoInWords() * @see CakeTime::timeAgoInWords()
*/ */
public static $wordFormat = 'j/n/y'; public static $wordFormat = 'j/n/y';
/** /**
* The format to use when formatting a time using `CakeTime::niceShort()` * The format to use when formatting a time using `CakeTime::niceShort()`
* and the difference is between 3 and 7 days * and the difference is between 3 and 7 days
@ -57,7 +57,7 @@ class CakeTime {
* @see CakeTime::niceShort() * @see CakeTime::niceShort()
*/ */
public static $niceShortFormat = '%d/%m, %H:%M'; public static $niceShortFormat = '%d/%m, %H:%M';
/** /**
* The format to use when formatting a time using `CakeTime::timeAgoInWords()` * The format to use when formatting a time using `CakeTime::timeAgoInWords()`
* and the difference is less than `CakeTime::$wordEnd` * and the difference is less than `CakeTime::$wordEnd`
@ -66,15 +66,15 @@ class CakeTime {
* @see CakeTime::timeAgoInWords() * @see CakeTime::timeAgoInWords()
*/ */
public static $wordAccuracy = array( public static $wordAccuracy = array(
'year' => "day", 'year' => "day",
'month' => "day", 'month' => "day",
'week' => "day", 'week' => "day",
'day' => "hour", 'day' => "hour",
'hour' => "minute", 'hour' => "minute",
'minute' => "minute", 'minute' => "minute",
'second' => "second", 'second' => "second",
); );
/** /**
* The end of relative time telling * The end of relative time telling
* *
@ -375,10 +375,17 @@ class CakeTime {
$date = $dateString ? self::fromString($dateString, $timezone) : time(); $date = $dateString ? self::fromString($dateString, $timezone) : time();
$y = self::isThisYear($date) ? '' : ' %Y'; $y = self::isThisYear($date) ? '' : ' %Y';
$d = self::_strftime("%w", $date); $d = self::_strftime("%w", $date);
$day = array(__d('cake', 'Sunday'), __d('cake', 'Monday'), __d('cake', 'Tuesday'), $day = array(
__d('cake', 'Wednesday'), __d('cake', 'Thursday'), __d('cake', 'Friday'), __d('cake', 'Saturday')); __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)) { if (self::isToday($dateString, $timezone)) {
$ret = __d('cake', 'Today, %s', self::_strftime("%H:%M", $date)); $ret = __d('cake', 'Today, %s', self::_strftime("%H:%M", $date));
@ -394,7 +401,6 @@ class CakeTime {
$format = self::convertSpecifiers("%b %eS{$y}, %H:%M", $date); $format = self::convertSpecifiers("%b %eS{$y}, %H:%M", $date);
$ret = self::_strftime($format, $date); $ret = self::_strftime($format, $date);
} }
return $ret; return $ret;
} }
@ -667,7 +673,7 @@ class CakeTime {
$format = self::$wordFormat; $format = self::$wordFormat;
$end = self::$wordEnd; $end = self::$wordEnd;
$accuracy = self::$wordAccuracy; $accuracy = self::$wordAccuracy;
if (is_array($options)) { if (is_array($options)) {
if (isset($options['userOffset'])) { if (isset($options['userOffset'])) {
$timezone = $options['userOffset']; $timezone = $options['userOffset'];
@ -735,7 +741,7 @@ class CakeTime {
} }
if ($future['m'] < $past['m'] && $future['Y'] - $past['Y'] == 1) { if ($future['m'] < $past['m'] && $future['Y'] - $past['Y'] == 1) {
$years --; $years--;
} }
} }
} }
@ -753,13 +759,13 @@ class CakeTime {
} }
if ($future['m'] != $past['m']) { if ($future['m'] != $past['m']) {
$months --; $months--;
} }
} }
if ($months == 0 && $years >= 1 && $diff < ($years * 31536000)) { if ($months == 0 && $years >= 1 && $diff < ($years * 31536000)) {
$months = 11; $months = 11;
$years --; $years--;
} }
if ($months >= 12) { if ($months >= 12) {
@ -825,12 +831,11 @@ class CakeTime {
if (self::wasWithinLast('7 days', $dateTime, $timezone) || self::isWithinNext('7 days', $dateTime, $timezone)) { if (self::wasWithinLast('7 days', $dateTime, $timezone) || self::isWithinNext('7 days', $dateTime, $timezone)) {
$relativeDate = self::niceShort($dateTime , $timezone); $relativeDate = self::niceShort($dateTime , $timezone);
} }
// If now // If now
if ($diff == 0) { if ($diff == 0) {
$relativeDate = __d('cake', 'just now', 'just now'); $relativeDate = __d('cake', 'just now', 'just now');
} }
return $relativeDate; return $relativeDate;
} }
@ -856,10 +861,9 @@ class CakeTime {
if ($date >= $interval && $date <= time()) { if ($date >= $interval && $date <= time()) {
return true; return true;
} }
return false; return false;
} }
/** /**
* Returns true if specified datetime is within the interval specified, else false. * Returns true if specified datetime is within the interval specified, else false.
* *
@ -882,7 +886,6 @@ class CakeTime {
if ($date <= $interval && $date >= time()) { if ($date <= $interval && $date >= time()) {
return true; return true;
} }
return false; return false;
} }
@ -905,7 +908,6 @@ class CakeTime {
$month = intval(date("n", $string)); $month = intval(date("n", $string));
$day = intval(date("j", $string)); $day = intval(date("j", $string));
$year = intval(date("Y", $string)); $year = intval(date("Y", $string));
return gmmktime($hour, $minute, $second, $month, $day, $year); return gmmktime($hour, $minute, $second, $month, $day, $year);
} }