def dt_to_hms(td):
    """
    convert a datetime.timedelta object into days, hours,
    minutes and seconds
    """

    days, hours, minutes = td.days, td.seconds // 3600, td.seconds % 3600 // 60
    seconds = td.seconds - hours*3600 - minutes*60
    return days, hours, minutes, seconds