Skip to content

Commit

Permalink
fix unconverted data remains error
Browse files Browse the repository at this point in the history
  • Loading branch information
jay0lee committed Aug 9, 2024
1 parent d537662 commit a139b8c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion gyb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1987,13 +1987,23 @@ def convert_timestamp(val):
# yuck, we aren't actually storing timestamps in the GYB
# database. I blame the original developer :-)
# return datetime.datetime.fromtimestamp(int(val))
return datetime.datetime.strptime(val.decode('UTF-8'), '%Y-%m-%d %H:%M:%S')
my_date = val.decode('UTF-8')
date_format = '%Y-%m-%d %H:%M:%S'
try:
return datetime.datetime.strptime(my_date, date_format)
except ValueError as v:
ulr = len(v.args[0].partition('unconverted data remains: ')[2])
if ulr:
my_date = datetime.datetime.strptime(my_date[:-ulr], date_format)
else:
raise v

def main(argv):
global options, gmail
options = SetupOptionParser(argv)
if options.debug:
httplib2.debuglevel = 4

doGYBCheckForUpdates(debug=options.debug)
if options.version:
print(getGYBVersion())
Expand Down

0 comments on commit a139b8c

Please sign in to comment.