import time


def format_expiration_time(expires):
    """Format expiration time in terms of days, hours, minutes, and seconds.

    Args:
        expires (int): Absolute UNIX time.

    Returns:
        str: Human-readable expiration time in terms of days, hours, minutes,
            and seconds.

    """
    delta = int(expires - time.time())

    if delta < 0:
        return "Expired at " + time.asctime(time.localtime(expires))

    days, r = divmod(delta, 86400)
    hours, r = divmod(r, 3600)
    minutes, r = divmod(r, 60)
    seconds = r

    if days > 0:
        return "{} days, {} hrs, {} min, {} sec".format(days, hours, minutes, seconds)
    elif hours > 0:
        return "{} hrs, {} min, {} sec".format(hours, minutes, seconds)
    elif minutes > 0:
        return "{} min, {} sec".format(minutes, seconds)
    else:
        return "{} sec".format(seconds)