Merge pull request #227 from datastax/PYTHON-119
PYTHON-119 - Timestamp deserialization workaround for Windows
This commit is contained in:
@@ -36,7 +36,7 @@ import io
|
|||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime, timedelta
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
@@ -565,7 +565,13 @@ class DateType(_CassandraType):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def deserialize(byts, protocol_version):
|
def deserialize(byts, protocol_version):
|
||||||
return datetime.utcfromtimestamp(int64_unpack(byts) / 1000.0)
|
timestamp = int64_unpack(byts) / 1000.0
|
||||||
|
if timestamp >= 0:
|
||||||
|
dt = datetime.utcfromtimestamp(timestamp)
|
||||||
|
else:
|
||||||
|
# PYTHON-119: workaround for Windows
|
||||||
|
dt = datetime(1970, 1, 1) + timedelta(seconds=timestamp)
|
||||||
|
return dt
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def serialize(v, protocol_version):
|
def serialize(v, protocol_version):
|
||||||
|
|||||||
Reference in New Issue
Block a user