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 a7c3ce4

Browse filesBrowse files
committed
Merge pull request PyMySQL#38 from olive-oasis/master
microsecond-bug-fix for datetime.datetime
2 parents c8b2744 + fb1c79d commit a7c3ce4
Copy full SHA for a7c3ce4

File tree

Expand file treeCollapse file tree

1 file changed

+8
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-1
lines changed

‎MySQLdb/times.py

Copy file name to clipboardExpand all lines: MySQLdb/times.py
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ def DateTime_or_None(s):
5151

5252
try:
5353
d, t = s.split(sep, 1)
54-
return datetime(*[ int(x) for x in d.split('-')+t.split(':') ])
54+
if '.' in t:
55+
t, ms = t.split('.',1)
56+
ms = ms.ljust(6, '0')
57+
else:
58+
ms = 0
59+
return datetime(*[ int(x) for x in d.split('-')+t.split(':')+[ms] ])
5560
except (SystemExit, KeyboardInterrupt):
5661
raise
5762
except:
@@ -62,6 +67,7 @@ def TimeDelta_or_None(s):
6267
h, m, s = s.split(':')
6368
if '.' in s:
6469
s, ms = s.split('.')
70+
ms = ms.ljust(6, '0')
6571
else:
6672
ms = 0
6773
h, m, s, ms = int(h), int(m), int(s), int(ms)
@@ -80,6 +86,7 @@ def Time_or_None(s):
8086
h, m, s = s.split(':')
8187
if '.' in s:
8288
s, ms = s.split('.')
89+
ms = ms.ljust(6, '0')
8390
else:
8491
ms = 0
8592
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.