def total_seconds(td):
    """Python 2.6 compatability"""
    if hasattr(td, 'total_seconds'):
        return td.total_seconds()
    ms = td.microseconds
    secs = td.seconds + td.days * 24 * 3600
    return (ms + secs * 10 ** 6) / 10 ** 6
