diff options
author | Andreas Gohr <gohr@cosmocode.de> | 2009-10-07 14:22:32 +0200 |
---|---|---|
committer | Andreas Gohr <gohr@cosmocode.de> | 2009-10-07 14:22:32 +0200 |
commit | c57e365ef97272cc08601374e4de2f5bcd614335 (patch) | |
tree | 8ed3504112d74466200927ae2519860789060075 /inc/common.php | |
parent | 47583ff0428eaa0d97e26f61f81ac6d199e9b446 (diff) | |
download | rpg-c57e365ef97272cc08601374e4de2f5bcd614335.tar.gz rpg-c57e365ef97272cc08601374e4de2f5bcd614335.tar.bz2 |
Added datetime to fuzzy age function
Ignore-this: 6d0e4f4fce5911667467f92cefaabaef
This still needs to be made accessible within the dtformat config option.
darcs-hash:20091007122232-6e07b-bbb6f97ae84bc9aa079fe328665f8164ae119804.gz
Diffstat (limited to 'inc/common.php')
-rw-r--r-- | inc/common.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/inc/common.php b/inc/common.php index 069314273..82d5f69ee 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1193,6 +1193,37 @@ function filesize_h($size, $dec = 1){ } /** + * Return the given timestamp as human readable, fuzzy age + * + * @author Andreas Gohr <gohr@cosmocode.de> + */ +function datetime_h($dt){ + global $lang; + + $ago = time() - $dt; + if($ago > 24*60*60*30*12*2){ + return sprintf($lang['years'], round($ago/(24*60*60*30*12))); + } + if($ago > 24*60*60*30*2){ + return sprintf($lang['months'], round($ago/(24*60*60*30))); + } + if($ago > 24*60*60*7*2){ + return sprintf($lang['weeks'], round($ago/(24*60*60*7))); + } + if($ago > 24*60*60*2){ + return sprintf($lang['days'], round($ago/(24*60*60))); + } + if($ago > 60*60*2){ + return sprintf($lang['hours'], round($ago/(60*60))); + } + if($ago > 60*2){ + return sprintf($lang['minutes'], round($ago/(60))); + } + return sprintf($lang['seconds'], $ago); + +} + +/** * return an obfuscated email address in line with $conf['mailguard'] setting * * @author Harry Fuecks <hfuecks@gmail.com> |