Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Sync with local changes

  • Loading branch information...
commit e00f6ada69effc4c94a20579ec3dcfac22cdd089 1 parent 83999d4
unknown authored

Showing 1 changed file with 10 additions and 5 deletions. Show diff stats Hide diff stats

  1. +10 5 src/classes/shared/date.php
15 src/classes/shared/date.php
@@ -44,7 +44,7 @@ public static function ago($timestamp, $comparison = null) {
44 44 _('%d months ago'),
45 45 _('%d years ago'));
46 46
47   - $lengths = array(60, 60, 24, 7, 4.35, 12);
  47 + $lengths = array(60, 60, 24, 7, 4.35, 12, 1);
48 48
49 49 // process input?
50 50 if (!is_int($timestamp)) {
@@ -61,14 +61,19 @@ public static function ago($timestamp, $comparison = null) {
61 61
62 62 // find correct period
63 63 for ($j = 0; $difference >= $lengths[$j]; $j++) {
64   - if ($j > 5) {
  64 + $difference = $difference / $lengths[$j];
  65 +
  66 + if ($j >= 6) {
65 67 break;
66 68 }
67   -
68   - $difference /= $lengths[$j];
69 69 }
70 70
71   - $difference = round($difference);
  71 + // handle years string better
  72 + if ($j == 6) {
  73 + $difference = round($difference, 2);
  74 + } else {
  75 + $difference = round($difference);
  76 + }
72 77
73 78 return sprintf($periods[$j], $difference);
74 79 }

0 comments on commit e00f6ad

Please sign in to comment.
Something went wrong with that request. Please try again.