Skip to content

Commit

Permalink
try to parse datetime columns as iso-format string first
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanljones committed Oct 7, 2023
1 parent ad9911c commit 991b0f7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pyrekordbox/db6/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,18 @@ def process_bind_param(self, value, dialect):

def process_result_value(self, value, dialect):
if value:
if len(value.strip()) > 23:
datestr, tzinfo = value[:23], value[23:]
datestr = datestr.strip()
tzinfo = tzinfo.strip()
assert tzinfo == "+00:00", tzinfo
else:
datestr, tzinfo = value, ""
return datetime.fromisoformat(datestr)
try:
dt = datetime.fromisoformat(value)
except ValueError:
if len(value.strip()) > 23:
datestr, tzinfo = value[:23], value[23:]
datestr = datestr.strip()
tzinfo = tzinfo.strip()
assert tzinfo == "+00:00", tzinfo
else:
datestr, tzinfo = value, ""
dt = datetime.fromisoformat(datestr)
return dt
return None


Expand Down

0 comments on commit 991b0f7

Please sign in to comment.