|
|
@@ -858,48 +858,76 @@ class CakeTime {
|
|
|
return sprintf($absoluteString, date($format, $inSeconds));
|
|
|
}
|
|
|
|
|
|
- $f = $accuracy['second'];
|
|
|
+ $fWord = $accuracy['second'];
|
|
|
if ($years > 0) {
|
|
|
- $f = $accuracy['year'];
|
|
|
+ $fWord = $accuracy['year'];
|
|
|
} elseif (abs($months) > 0) {
|
|
|
- $f = $accuracy['month'];
|
|
|
+ $fWord = $accuracy['month'];
|
|
|
} elseif (abs($weeks) > 0) {
|
|
|
- $f = $accuracy['week'];
|
|
|
+ $fWord = $accuracy['week'];
|
|
|
} elseif (abs($days) > 0) {
|
|
|
- $f = $accuracy['day'];
|
|
|
+ $fWord = $accuracy['day'];
|
|
|
} elseif (abs($hours) > 0) {
|
|
|
- $f = $accuracy['hour'];
|
|
|
+ $fWord = $accuracy['hour'];
|
|
|
} elseif (abs($minutes) > 0) {
|
|
|
- $f = $accuracy['minute'];
|
|
|
+ $fWord = $accuracy['minute'];
|
|
|
}
|
|
|
|
|
|
- $f = str_replace(array('year', 'month', 'week', 'day', 'hour', 'minute', 'second'), array(1, 2, 3, 4, 5, 6, 7), $f);
|
|
|
+ $fNum = str_replace(array('year', 'month', 'week', 'day', 'hour', 'minute', 'second'), array(1, 2, 3, 4, 5, 6, 7), $fWord);
|
|
|
|
|
|
$relativeDate = '';
|
|
|
- if ($f >= 1 && $years > 0) {
|
|
|
+ if ($fNum >= 1 && $years > 0) {
|
|
|
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d year', '%d years', $years, $years);
|
|
|
}
|
|
|
- if ($f >= 2 && $months > 0) {
|
|
|
+ if ($fNum >= 2 && $months > 0) {
|
|
|
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d month', '%d months', $months, $months);
|
|
|
}
|
|
|
- if ($f >= 3 && $weeks > 0) {
|
|
|
+ if ($fNum >= 3 && $weeks > 0) {
|
|
|
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d week', '%d weeks', $weeks, $weeks);
|
|
|
}
|
|
|
- if ($f >= 4 && $days > 0) {
|
|
|
+ if ($fNum >= 4 && $days > 0) {
|
|
|
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d day', '%d days', $days, $days);
|
|
|
}
|
|
|
- if ($f >= 5 && $hours > 0) {
|
|
|
+ if ($fNum >= 5 && $hours > 0) {
|
|
|
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d hour', '%d hours', $hours, $hours);
|
|
|
}
|
|
|
- if ($f >= 6 && $minutes > 0) {
|
|
|
+ if ($fNum >= 6 && $minutes > 0) {
|
|
|
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d minute', '%d minutes', $minutes, $minutes);
|
|
|
}
|
|
|
- if ($f >= 7 && $seconds > 0) {
|
|
|
+ if ($fNum >= 7 && $seconds > 0) {
|
|
|
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d second', '%d seconds', $seconds, $seconds);
|
|
|
}
|
|
|
|
|
|
+ $aboutAgo = array(
|
|
|
+ 'second' => __d('cake', 'about a second ago'),
|
|
|
+ 'minute' => __d('cake', 'about a minute ago'),
|
|
|
+ 'hour' => __d('cake', 'about an hour ago'),
|
|
|
+ 'day' => __d('cake', 'about a day ago'),
|
|
|
+ 'week' => __d('cake', 'about a week ago'),
|
|
|
+ 'year' => __d('cake', 'about a year ago')
|
|
|
+ );
|
|
|
+
|
|
|
+ $aboutIn = array(
|
|
|
+ 'second' => __d('cake', 'in about a second'),
|
|
|
+ 'minute' => __d('cake', 'in about a minute'),
|
|
|
+ 'hour' => __d('cake', 'in about an hour'),
|
|
|
+ 'day' => __d('cake', 'in about a day'),
|
|
|
+ 'week' => __d('cake', 'in about a week'),
|
|
|
+ 'year' => __d('cake', 'in about a year')
|
|
|
+ );
|
|
|
+
|
|
|
+ // When time has passed
|
|
|
if (!$backwards) {
|
|
|
- return sprintf($relativeString, $relativeDate);
|
|
|
+ if ($relativeDate) {
|
|
|
+ return __d('cake', '%s ago', $relativeDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $aboutAgo[$fWord];
|
|
|
+ }
|
|
|
+
|
|
|
+ // When time is to come
|
|
|
+ if (!$relativeDate) {
|
|
|
+ return $aboutIn[$fWord];
|
|
|
}
|
|
|
|
|
|
return $relativeDate;
|