Revert "Didn't mean to include this"
[gitphp.git] / include / util.age_string.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
/*
 *  util.age_string.php
 *  gitphp: A PHP git repository browser
 *  Component: Utility - convert age to a readable string
 *
 *  Copyright (C) 2008 Christopher Han <xiphux@gmail.com>
 */
 
function age_string($age)
{
        if ($age > 60*60*24*365*2)
                return (int)($age/60/60/24/365) . " years ago";
        else if ($age > 60*60*24*(365/12)*2)
                return (int)($age/60/60/24/(365/12)) . " months ago";
        else if ($age > 60*60*24*7*2)
                return (int)($age/60/60/24/7) . " weeks ago";
        else if ($age > 60*60*24*2)
                return (int)($age/60/60/24) . " days ago";
        else if ($age > 60*60*2)
                return (int)($age/60/60) . " hours ago";
        else if ($age > 60*2)
                return (int)($age/60) . " min ago";
        else if ($age > 2)
                return (int)$age . " sec ago";
        return "right now";
}
 
?>
 
comments