fix to compatible with Python2.6

total_seconds() method only for Python2.7 or later, so I change it to compatible with Python2.6.