summaryrefslogtreecommitdiffstats
path: root/index.php
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mageia.org>2011-01-18 12:54:14 +0000
committerPascal Terjan <pterjan@mageia.org>2011-01-18 12:54:14 +0000
commit7f761f00bfb538376a764f597a146b9ac2f76795 (patch)
tree0a56c9009a44a593e445fa31b09350331860051a /index.php
parent0e9f04ca7b9b4a2f80ceca39f084cb9f40bbb085 (diff)
downloadpkgsubmit-7f761f00bfb538376a764f597a146b9ac2f76795.tar
pkgsubmit-7f761f00bfb538376a764f597a146b9ac2f76795.tar.gz
pkgsubmit-7f761f00bfb538376a764f597a146b9ac2f76795.tar.bz2
pkgsubmit-7f761f00bfb538376a764f597a146b9ac2f76795.tar.xz
pkgsubmit-7f761f00bfb538376a764f597a146b9ac2f76795.zip
Better split of key2date
Diffstat (limited to 'index.php')
-rw-r--r--index.php25
1 files changed, 9 insertions, 16 deletions
diff --git a/index.php b/index.php
index c0f3db8..4b5be83 100644
--- a/index.php
+++ b/index.php
@@ -149,26 +149,19 @@ function key2timestamp($key) {
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 @@ if ($total > 0) {
$s .= sprintf($tmpl,
$p['type'],
- key2date($key) . ' ago',
+ timediff(key2timestamp($key)) . ' ago',
$p['user'], $p['user'],
$p['package'],
$p['version'],
@@ -313,7 +306,7 @@ if ($total > 0) {
$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>';