def total_seconds(td):
    """
    Total seconds in the duration.

    :type td: :class:`timedelta`
    """
    # Keep backward compatibility with Python 2.6 which
    # doesn't have this method
    if hasattr(td, 'total_seconds'):
        return td.total_seconds()
    else:
        return ((td.days * 86400 + td.seconds) * 10**6 +
                td.microseconds) / 10**6