Skip to content

Commit

Permalink
Fix issue with minute overwriting month in convert_timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
lanceris committed May 10, 2024
1 parent 055e43e commit a4e7543
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions peewee.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ def datetime_adapter(d): return d.isoformat(' ')
def convert_date(d): return datetime.date(*map(int, d.split(b'-')))
def convert_timestamp(t):
date, time = t.split(b' ')
y, m, d = map(int, date.split(b'-'))
year, month, day = map(int, date.split(b'-'))
t_full = time.split(b'.')
h, m, s = map(int, t_full[0].split(b':'))
hour, minute, second = map(int, t_full[0].split(b':'))
if len(t_full) == 2:
usec = int('{:0<6.6}'.format(t_full[1].decode()))
else:
usec = 0
return datetime.datetime(y, m, d, h, m, s, usec)
return datetime.datetime(year, month, day, hour, minute, second, usec)
sqlite3.register_adapter(datetime.datetime, datetime_adapter)
sqlite3.register_converter('date', convert_date)
sqlite3.register_converter('timestamp', convert_timestamp)
Expand Down

0 comments on commit a4e7543

Please sign in to comment.