[Mageia-sysadm] [314] Better split of key2date

root at mageia.org root at mageia.org
Tue Jan 18 13:54:14 CET 2011


Revision: 314
Author:   pterjan
Date:     2011-01-18 13:54:14 +0100 (Tue, 18 Jan 2011)
Log Message:
-----------
Better split of key2date

Modified Paths:
--------------
    build_system/web/index.php

Modified: build_system/web/index.php
===================================================================
--- build_system/web/index.php	2011-01-18 12:43:53 UTC (rev 313)
+++ build_system/web/index.php	2011-01-18 12:54:14 UTC (rev 314)
@@ -149,26 +149,19 @@
     return $date->getTimestamp();
 }
 
-function key2date($key, $diff = null) {
+function timediff($key, $end) {
 /**
- * Return human-readable time difference:
- * - against $key (YmdHis expected format)
- * - using only $diff (takes precedence over $key if provided)
+ * Return human-readable time difference
  *
- * @param string $key past date to diff against from now
- * @param integer $diff time difference in seconds
+ * @param integer $start timestamp
+ * @param integer $end timestamp, defaults to now
  *
  * @return string
 */
-    global $tz;
-
-    if (is_null($diff) || $diff <= 0) {
-        $t = key2timestamp($key);
-        if (is_null($t))
-            return null;
-
-        $diff = time() - $t;
+    if (is_null($end)) {
+	$end = time();
     }
+    $diff = $end - $start;
     if ($diff<60)
        return $diff . " second" . plural($diff);
     $diff = round($diff/60);
@@ -292,7 +285,7 @@
 
         $s .= sprintf($tmpl,
             $p['type'],
-            key2date($key) . ' ago',
+            timediff(key2timestamp($key)) . ' ago',
             $p['user'], $p['user'],
             $p['package'],
             $p['version'],
@@ -313,7 +306,7 @@
 
         $s .= '</td><td>';
         if ($p['type'] == 'uploaded')
-            $s .= key2date(null, $p['buildtime']['diff']);
+            $s .= timediff($p['buildtime']['start'], $p['buildtime']['end']);
         $s .= '</td>';
         //$s .= '<td>' . sprintf($badges[$p['type']], $p['user']) . '</td>';
         $s .= '</tr>';
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/mageia-sysadm/attachments/20110118/7d427c6a/attachment.html>


More information about the Mageia-sysadm mailing list