From 2b3a72efcc47479a7bd3adef3a522d6550047ae1 Mon Sep 17 00:00:00 2001 From: Adam Holmberg Date: Thu, 11 Jun 2015 11:47:08 -0500 Subject: [PATCH] cqle: use integer division for converting timedelta to seconds Emulates the timedelta.total_seconds() function in python 2.7+ --- cassandra/cqlengine/functions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cassandra/cqlengine/functions.py b/cassandra/cqlengine/functions.py index 43c98afe..d69e16f1 100644 --- a/cassandra/cqlengine/functions.py +++ b/cassandra/cqlengine/functions.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division from datetime import datetime from cassandra.cqlengine import UnicodeMixin, ValidationError @@ -23,7 +24,9 @@ if sys.version_info >= (2, 7): return td.total_seconds() else: def get_total_seconds(td): - return 86400*td.days + td.seconds + td.microseconds/1e6 + # integer division used here to emulate built-in total_seconds + return ((86400 * td.days + td.seconds) * 10 ** 6 + td.microseconds) / 10 ** 6 + class QueryValue(UnicodeMixin): """