aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions.inc.php
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2012-02-10 17:02:54 +0000
committermistic100 <mistic@piwigo.org>2012-02-10 17:02:54 +0000
commitb82ddfb655145a59feee7ce3e7cefa6c6a2c3084 (patch)
tree222fe093aa816df672fe140a0ef55f2bbc75aaa8 /include/functions.inc.php
parent69a704f13875cfbc1c090239d9d54d871f2ff8f7 (diff)
feature 2564: small changes in infos list
git-svn-id: http://piwigo.org/svn/trunk@13086 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/functions.inc.php27
1 files changed, 15 insertions, 12 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 925e43848..4a4677b8a 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -546,34 +546,37 @@ function time_since($original, $stop = 'minute')
$ymdhms[] = $tok;
$tok = strtok('- :');
}
+
+ if ($ymdhms[0] < 1970) return false;
+ if (!isset($ymdhms[3])) $ymdhms[3] = 12;
+ if (!isset($ymdhms[4])) $ymdhms[4] = 0;
+ if (!isset($ymdhms[5])) $ymdhms[5] = 0;
$original = mktime($ymdhms[3],$ymdhms[4],$ymdhms[5],$ymdhms[1],$ymdhms[2],$ymdhms[0]);
}
// array of time period chunks
$chunks = array(
- array(60 * 60 * 24 * 365 , 'year'),
- array(60 * 60 * 24 * 30 , 'month'),
- array(60 * 60 * 24 * 7, 'week'),
- array(60 * 60 * 24 , 'day'),
- array(60 * 60 , 'hour'),
- array(60 , 'minute'),
- array(1 , 'second'),
+ 'year' => 60 * 60 * 24 * 365,
+ 'month' => 60 * 60 * 24 * 30,
+ 'week' => 60 * 60 * 24 * 7,
+ 'day' => 60 * 60 * 24,
+ 'hour' => 60 * 60,
+ 'minute' => 60,
+ 'second' => 1,
);
$today = time(); /* Current unix time */
$since = abs($today - $original);
$print = null;
- for ($i = 0, $j = count($chunks); $i < $j; $i++)
+ foreach ($chunks as $name => $seconds)
{
- $seconds = $chunks[$i][0];
- $name = $chunks[$i][1];
if (($count = floor($since / $seconds)) != 0)
{
- $print.= ($count == 1) ? '1 '.l10n($name).' ' : $count.' '.l10n($name.'s').' ';
+ $print.= l10n_dec('%d '.$name, '%d '.$name.'s', $count);
$since-= $count*$seconds;
}
- if ($name == $stop)
+ if (!empty($print) and $chunks[$name] <= $chunks[$stop])
{
break;
}