def total_seconds(td):
    """Given a timedelta object, return the total number of seconds it
    represents.

    We avoid using .total_seconds(), since that requires Python 2.7.

    """
    return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6
        ) / 10 ** 6
