summaryrefslogtreecommitdiff
path: root/MySQLdb/times.py
diff options
context:
space:
mode:
authorAndy Dustman <farcepest@gmail.com>2013-08-18 18:24:17 -0400
committerAndy Dustman <farcepest@gmail.com>2013-08-18 18:24:17 -0400
commit32d0364176d350cdc2701d63c4f9b1f711ecbb44 (patch)
treea49154fbafc0f1bdfd12240ed66e0e8d15112772 /MySQLdb/times.py
parentefb3bc3531d9c16da436423e7c496f7f819da3b6 (diff)
parentc8b2744ea2b1e4419b7e3d93928e92c95f366815 (diff)
downloadmysqldb1-MySQLdb-1.3.tar.gz
Merge branch 'master' into MySQLdb-1.3MySQLdb-1.3
Conflicts: MySQLdb/connections.py
Diffstat (limited to 'MySQLdb/times.py')
-rw-r--r--MySQLdb/times.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/MySQLdb/times.py b/MySQLdb/times.py
index bc92eb4..f3a92d7 100644
--- a/MySQLdb/times.py
+++ b/MySQLdb/times.py
@@ -60,9 +60,13 @@ def DateTime_or_None(s):
def TimeDelta_or_None(s):
try:
h, m, s = s.split(':')
- h, m, s = int(h), int(m), float(s)
- td = timedelta(hours=abs(h), minutes=m, seconds=int(s),
- microseconds=int(math.modf(s)[0] * 1000000))
+ if '.' in s:
+ s, ms = s.split('.')
+ else:
+ ms = 0
+ h, m, s, ms = int(h), int(m), int(s), int(ms)
+ td = timedelta(hours=abs(h), minutes=m, seconds=s,
+ microseconds=ms)
if h < 0:
return -td
else:
@@ -74,9 +78,13 @@ def TimeDelta_or_None(s):
def Time_or_None(s):
try:
h, m, s = s.split(':')
- h, m, s = int(h), int(m), float(s)
- return time(hour=h, minute=m, second=int(s),
- microsecond=int(math.modf(s)[0] * 1000000))
+ if '.' in s:
+ s, ms = s.split('.')
+ else:
+ ms = 0
+ h, m, s, ms = int(h), int(m), int(s), int(ms)
+ return time(hour=h, minute=m, second=s,
+ microsecond=ms)
except ValueError:
return None