def total_seconds(offset):
    """Backport of offset.total_seconds() from python 2.7+."""
    seconds = offset.days * 24 * 60 * 60 + offset.seconds
    microseconds = seconds * 10**6 + offset.microseconds
    return microseconds / (10**6 * 1.0)