def extract_time(seconds):
    """
    extract_time(seconds) -> String

    Turn the time in seconds to a string containing the time formatted into
    day, hours, minutes and seconds.
    """

    m, s = divmod(seconds, 60)
    h, m = divmod(m, 60)
    d, h = divmod(h, 24)

    if d == 0 and h == 0 and m == 0:
        return "%ds" % s
    if d == 0 and h == 0:
        return "%dm %ds" % (m, s)
    elif d == 0:
        return "%dh %dm %ds" % (h, m, s)
    else:
        return "%dd %dh %dm %ds" % (d, h, m, s)