1717import tempfile
1818import time
1919from binascii import unhexlify
20+ from datetime import tzinfo
21+
22+ from dateutil .tz import tzlocal
2023
2124import cassandra
2225from cassandra import util
4144from cassandra .util import (
4245 OPEN_BOUND , Date , DateRange , DateRangeBound ,
4346 DateRangePrecision , Time , ms_timestamp_from_datetime ,
44- datetime_from_timestamp
47+ datetime_from_timestamp , utcfromtimestamp
4548)
4649from tests .unit .util import check_sequence_consistency
4750
@@ -200,7 +203,7 @@ def test_empty_value(self):
200203
201204 def test_datetype (self ):
202205 now_time_seconds = time .time ()
203- now_datetime = datetime . datetime . utcfromtimestamp (now_time_seconds )
206+ now_datetime = utcfromtimestamp (now_time_seconds )
204207
205208 # Cassandra timestamps in millis
206209 now_timestamp = now_time_seconds * 1e3
@@ -211,7 +214,7 @@ def test_datetype(self):
211214 # deserialize
212215 # epoc
213216 expected = 0
214- self .assertEqual (DateType .deserialize (int64_pack (1000 * expected ), 0 ), datetime . datetime . utcfromtimestamp (expected ))
217+ self .assertEqual (DateType .deserialize (int64_pack (1000 * expected ), 0 ), utcfromtimestamp (expected ))
215218
216219 # beyond 32b
217220 expected = 2 ** 33
@@ -738,7 +741,7 @@ def get_upper_bound(seconds):
738741 The way to do this is to add one month and leave the date at YEAR-MONTH-01 00:00:00 000000.
739742 Then substract one millisecond.
740743 """
741- dt = datetime . datetime . fromtimestamp (seconds / 1000.0 , tz = utc_timezone )
744+ dt = utcfromtimestamp (seconds / 1000.0 )
742745 dt = dt + datetime .timedelta (days = 32 )
743746 dt = dt .replace (day = 1 ) - datetime .timedelta (microseconds = 1 )
744747 return int ((dt - self .epoch ).total_seconds () * 1000 )
@@ -765,7 +768,7 @@ def get_upper_bound(seconds):
765768 The way to do this is to add one year and leave the date at YEAR-01-01 00:00:00 000000.
766769 Then substract one millisecond.
767770 """
768- dt = datetime . datetime . fromtimestamp (seconds / 1000.0 , tz = utc_timezone )
771+ dt = utcfromtimestamp (seconds / 1000.0 )
769772 dt = dt + datetime .timedelta (days = 370 )
770773 dt = dt .replace (day = 1 ) - datetime .timedelta (microseconds = 1 )
771774
@@ -812,7 +815,7 @@ def truncate_date(number):
812815 For example if truncate_kwargs = {"hour": 0, "minute": 0, "second": 0, "microsecond": 0} the returned
813816 value will be the original given date but with the hours, minutes, seconds and microseconds set to 0
814817 """
815- dt = datetime . datetime . fromtimestamp (number / 1000.0 , tz = utc_timezone )
818+ dt = utcfromtimestamp (number / 1000.0 )
816819 dt = dt .replace (** truncate_kwargs )
817820 return round ((dt - self .epoch ).total_seconds () * 1000.0 )
818821
0 commit comments