def second_to_human(time_in_sec):#{{{
    """
    Returns a humanized string given the time in seconds

    The output rounds up to days, hours, minutes, or seconds.
    4 days 5 hours returns '4 days 5 hours'
    0 days 4 hours 3 minutes returns '4 hours 3 mins', etc...
    """

    days = int(time_in_sec)/3600/24
    hours = int(time_in_sec - 3600*24*days)/3600
    minutes = int(time_in_sec - 3600*24*days - 3600*hours)%3600/60
    seconds = time_in_sec%3600%60

    ss = ""
    tStr = ""
    if days > 0:
        if days == 1:   tStr = "day"
        else:           tStr = "days"
        ss += " %s %s" %(days, tStr)
    if hours > 0:
        if hours == 1:  tStr = "hour"
        else:           tStr = "hours"
        ss += " %s %s" %(hours, tStr)
    if minutes > 0:
        if minutes == 1:tStr = "min"
        else:           tStr = "mins"
        ss += " %s %s" %(minutes, tStr)
    if seconds > 0 or (seconds == 0 and days == 0 and hours == 0 and minutes == 0):
        if seconds <= 1:tStr = "sec"
        else:           tStr = "secs"
        ss += " %g %s" %(seconds, tStr)

    ss = ss.strip()
    if ss != "":
        return ss
    else:
        return None