Permalink
Browse files

Sync with local changes

  • Loading branch information...
1 parent 83999d4 commit e00f6ada69effc4c94a20579ec3dcfac22cdd089 unknown committed Jul 10, 2012
Showing with 10 additions and 5 deletions.
  1. +10 −5 src/classes/shared/date.php
@@ -44,7 +44,7 @@ public static function ago($timestamp, $comparison = null) {
_('%d months ago'),
_('%d years ago'));
- $lengths = array(60, 60, 24, 7, 4.35, 12);
+ $lengths = array(60, 60, 24, 7, 4.35, 12, 1);
// process input?
if (!is_int($timestamp)) {
@@ -61,14 +61,19 @@ public static function ago($timestamp, $comparison = null) {
// find correct period
for ($j = 0; $difference >= $lengths[$j]; $j++) {
- if ($j > 5) {
+ $difference = $difference / $lengths[$j];
+
+ if ($j >= 6) {
break;
}
-
- $difference /= $lengths[$j];
}
- $difference = round($difference);
+ // handle years string better
+ if ($j == 6) {
+ $difference = round($difference, 2);
+ } else {
+ $difference = round($difference);
+ }
return sprintf($periods[$j], $difference);
}

0 comments on commit e00f6ad

Please sign in to comment.