def _total_seconds(t):
    '''
    Takes a `datetime.timedelta` object and returns the delta in seconds.

    >>> _total_seconds(datetime.timedelta(23, 42, 123456))
    1987242
    >>> _total_seconds(datetime.timedelta(23, 42, 654321))
    1987243
    '''
    return sum([
        int(t.days * 86400 + t.seconds),
        int(round(t.microseconds / 1000000.0))
    ])