fixed issue with timestamp and DST
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import copy
|
import copy
|
||||||
|
import time
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from cqlengine import BaseContainerColumn, Map, columns
|
from cqlengine import BaseContainerColumn, Map, columns
|
||||||
from cqlengine.columns import Counter, List, Set
|
from cqlengine.columns import Counter, List, Set
|
||||||
@@ -150,10 +151,11 @@ class BatchQuery(object):
|
|||||||
|
|
||||||
if isinstance(self.timestamp, (int, long)):
|
if isinstance(self.timestamp, (int, long)):
|
||||||
ts = self.timestamp
|
ts = self.timestamp
|
||||||
elif isinstance(self.timestamp, timedelta):
|
elif isinstance(self.timestamp, (datetime, timedelta)):
|
||||||
ts = long((datetime.now() + self.timestamp - datetime.fromtimestamp(0)).total_seconds() * 1000000)
|
ts = self.timestamp
|
||||||
elif isinstance(self.timestamp, datetime):
|
if isinstance(self.timestamp, timedelta):
|
||||||
ts = long((self.timestamp - datetime.fromtimestamp(0)).total_seconds() * 1000000)
|
ts += datetime.now() # Apply timedelta
|
||||||
|
long(time.mktime(ts.timetuple()) * 1e+6 + ts.microsecond)
|
||||||
else:
|
else:
|
||||||
raise ValueError("Batch expects a long, a timedelta, or a datetime")
|
raise ValueError("Batch expects a long, a timedelta, or a datetime")
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import time
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from cqlengine.functions import QueryValue
|
from cqlengine.functions import QueryValue
|
||||||
from cqlengine.operators import BaseWhereOperator, InOperator
|
from cqlengine.operators import BaseWhereOperator, InOperator
|
||||||
@@ -496,7 +497,7 @@ class BaseCQLStatement(object):
|
|||||||
else:
|
else:
|
||||||
tmp = self.timestamp
|
tmp = self.timestamp
|
||||||
|
|
||||||
return long(((tmp - datetime.fromtimestamp(0)).total_seconds()) * 1000000)
|
return long(time.mktime(tmp.timetuple()) * 1e+6 + tmp.microsecond)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|||||||
Reference in New Issue
Block a user