def _total_secs(td):
    """
    python 2.6 compatible timedelta total seconds calculation
    backport from
    https://docs.python.org/2.7/library/datetime.html#datetime.timedelta.total_seconds
    """
    if hasattr(td, 'total_seconds'):
        return td.total_seconds()
    else:
        return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6
            ) / 10.0 ** 6
