Add days and weeks to relative time.
authorJan Schneider <jan@horde.org>
Wed, 2 Dec 2009 23:37:21 +0000 (00:37 +0100)
committerJan Schneider <jan@horde.org>
Thu, 3 Dec 2009 10:14:42 +0000 (11:14 +0100)
framework/Date/lib/Horde/Date/Utils.php

index 919bdde..3598707 100644 (file)
@@ -95,6 +95,16 @@ class Horde_Date_Utils
             return sprintf(_("yesterday at %s"), $date->strftime($time_format));
         }
 
+        $delta = round($delta / 24);
+        if ($delta < 7) {
+            return sprintf(_("%d days ago"), $delta);
+        }
+
+        if (round($delta / 7) < 5) {
+            $delta = round($delta / 7);
+            return sprintf(ngettext("%d week ago", "%d weeks ago", $delta), $delta);
+        }
+
         // Default to the user specified date format.
         $date = new Horde_Date($timestamp);
         return $date->strftime($date_format);