Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fb1c79d

Browse filesBrowse files
author
Jinuk
committed
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`.
1 parent 100485f commit fb1c79d
Copy full SHA for fb1c79d

File tree

Expand file treeCollapse file tree

1 file changed

+6
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-3
lines changed

‎MySQLdb/times.py

Copy file name to clipboardExpand all lines: MySQLdb/times.py
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ def DateTime_or_None(s):
5252
try:
5353
d, t = s.split(sep, 1)
5454
if '.' in t:
55-
t, m = t.split('.',1)
55+
t, ms = t.split('.',1)
56+
ms = ms.ljust(6, '0')
5657
else:
57-
m = 0
58-
return datetime(*[ int(x) for x in d.split('-')+t.split(':')+[m] ])
58+
ms = 0
59+
return datetime(*[ int(x) for x in d.split('-')+t.split(':')+[ms] ])
5960
except (SystemExit, KeyboardInterrupt):
6061
raise
6162
except:
@@ -66,6 +67,7 @@ def TimeDelta_or_None(s):
6667
h, m, s = s.split(':')
6768
if '.' in s:
6869
s, ms = s.split('.')
70+
ms = ms.ljust(6, '0')
6971
else:
7072
ms = 0
7173
h, m, s, ms = int(h), int(m), int(s), int(ms)
@@ -84,6 +86,7 @@ def Time_or_None(s):
8486
h, m, s = s.split(':')
8587
if '.' in s:
8688
s, ms = s.split('.')
89+
ms = ms.ljust(6, '0')
8790
else:
8891
ms = 0
8992
h, m, s, ms = int(h), int(m), int(s), int(ms)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.