diff options
author | Jinuk <jinuk84.kim@lge.com> | 2013-11-08 12:18:55 +0900 |
---|---|---|
committer | Jinuk <jinuk84.kim@lge.com> | 2013-11-08 12:18:55 +0900 |
commit | fb1c79d85a87345525ba82cfdca470c4ef565a3c (patch) | |
tree | 3568609a6c2b088e8f4767b44b4a8fc82400dbf1 | |
parent | 100485f627be833caa11e68e4cf11d89db5fcd86 (diff) | |
download | mysqldb1-fb1c79d85a87345525ba82cfdca470c4ef565a3c.tar.gz |
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`.
-rw-r--r-- | MySQLdb/times.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/MySQLdb/times.py b/MySQLdb/times.py index 4040f8e..0ff7476 100644 --- a/MySQLdb/times.py +++ b/MySQLdb/times.py @@ -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) |