def td_to_dict(td):
    """
    Takes a timedelta and returns a dict with the following keys:

    * days
    * hours
    * minutes
    * seconds

    """

    return {
        'days': td.days,
        'hours': td.seconds // 3600 % 24,
        'minutes': td.seconds // 60 % 60,
        'seconds': td.seconds % 60,
    }