def _total_seconds(td):
    """Wrapper to work around lack of .total_seconds() method in Python 3.1.
    """
    if hasattr(td, 'total_seconds'):
        return td.total_seconds()
    return td.days * 3600 * 24 + td.seconds + td.microseconds / 100000.0
