def total_seconds(timedelta):
    """ Convert timedelta to seconds as an integer. """
    delta_seconds = timedelta.seconds + timedelta.days * 24 * 3600
    return (timedelta.microseconds + delta_seconds * 10 ** 6) // 10 ** 6