Pastie: Use Horde_Date_Util to calculate time delta
authorBen Klang <ben@alkaloid.net>
Tue, 8 Jun 2010 19:36:34 +0000 (15:36 -0400)
committerBen Klang <ben@alkaloid.net>
Tue, 8 Jun 2010 19:36:55 +0000 (15:36 -0400)
pastie/templates/recent.inc

index 79a669b..30ad398 100644 (file)
@@ -10,14 +10,7 @@ foreach ($recent as $r) {
     if (empty($r['title'])) {
       $r['title'] = _("[Untitled]");
     }
-    $then = new DateTime('@' . $r['timestamp']->timestamp());
-    $ago = $now->diff($then, true);
-    $days = $ago->format("%a");
-    if ($days > 0) {
-        $ago = $ago->format("%a days %H:%i ago");
-    } else {
-        $ago = $ago->format("%H:%i min ago");
-    }
+    $ago = Horde_Date_Util::relativeDateTime($r['timestamp']->timestamp());
 ?>
     <div class="recentPaste">
         <span class="pasteTitle"><a href="<?php echo $uuid . '/' . $r['uuid']; ?>"><?php echo $r['title']; ?></a></span><br>