mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2025-08-15 02:54:29 +08:00
microsecond-bug-fix
When the MySQL Datetime Fraction is less than 6, microseconds set incorrectly. For example, you set the field, Datetime(3). Then this library read the time `2013-11-07 10:27:35.705` as `2013-11-08 10:27:35.000705`.
This commit is contained in:
@ -52,10 +52,11 @@ def DateTime_or_None(s):
|
||||
try:
|
||||
d, t = s.split(sep, 1)
|
||||
if '.' in t:
|
||||
t, m = t.split('.',1)
|
||||
t, ms = t.split('.',1)
|
||||
ms = ms.ljust(6, '0')
|
||||
else:
|
||||
m = 0
|
||||
return datetime(*[ int(x) for x in d.split('-')+t.split(':')+[m] ])
|
||||
ms = 0
|
||||
return datetime(*[ int(x) for x in d.split('-')+t.split(':')+[ms] ])
|
||||
except (SystemExit, KeyboardInterrupt):
|
||||
raise
|
||||
except:
|
||||
@ -66,6 +67,7 @@ def TimeDelta_or_None(s):
|
||||
h, m, s = s.split(':')
|
||||
if '.' in s:
|
||||
s, ms = s.split('.')
|
||||
ms = ms.ljust(6, '0')
|
||||
else:
|
||||
ms = 0
|
||||
h, m, s, ms = int(h), int(m), int(s), int(ms)
|
||||
@ -84,6 +86,7 @@ def Time_or_None(s):
|
||||
h, m, s = s.split(':')
|
||||
if '.' in s:
|
||||
s, ms = s.split('.')
|
||||
ms = ms.ljust(6, '0')
|
||||
else:
|
||||
ms = 0
|
||||
h, m, s, ms = int(h), int(m), int(s), int(ms)
|
||||
|
Reference in New Issue
Block a user