Commit 86cd4e2d authored by tander67's avatar tander67 Committed by Olivier R-D

Added boolean support and fixed date time conversion

-) Added ability to handle Python booleans
-) Fixed issue with converting windows date time to unix date time on
systems where the clock is inaccurate
parent eb9980c4
...@@ -45,7 +45,12 @@ def datetime_to_win_epoch(dt): ...@@ -45,7 +45,12 @@ def datetime_to_win_epoch(dt):
def win_epoch_to_datetime(epch): def win_epoch_to_datetime(epch):
(s, ns100) = divmod(epch - EPOCH_AS_FILETIME, HUNDREDS_OF_NANOSECONDS) (s, ns100) = divmod(epch - EPOCH_AS_FILETIME, HUNDREDS_OF_NANOSECONDS)
dt = datetime.utcfromtimestamp(s) try:
# TDA, this generates exceptions on systems where RTC is really off
dt = datetime.utcfromtimestamp(s)
except:
logger.debug("Exception occurred during conversion within 'win_epoch_to_datetime'." )
return datetime.now()
dt = dt.replace(microsecond=(ns100 // 10)) dt = dt.replace(microsecond=(ns100 // 10))
return dt return dt
...@@ -610,6 +615,9 @@ class Variant(object): ...@@ -610,6 +615,9 @@ class Variant(object):
return VariantType.ByteString return VariantType.ByteString
elif type(val) == datetime: elif type(val) == datetime:
return VariantType.DateTime return VariantType.DateTime
elif type(val) == bool:
# TDA, added this because it was missing and causes exceptions when 'bool' type is used
return VariantType.Boolean
else: else:
if isinstance(val, object): if isinstance(val, object):
return getattr(VariantType, val.__class__.__name__) return getattr(VariantType, val.__class__.__name__)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment