We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 63ab179 commit 0226f1aCopy full SHA for 0226f1a
MySQLdb/times.py
@@ -60,9 +60,13 @@ def DateTime_or_None(s):
60
def TimeDelta_or_None(s):
61
try:
62
h, m, s = s.split(':')
63
- h, m, s = int(h), int(m), float(s)
64
- td = timedelta(hours=abs(h), minutes=m, seconds=int(s),
65
- microseconds=int(math.modf(s)[0] * 1000000))
+ if '.' in s:
+ s, ms = s.split('.')
+ else:
66
+ ms = 0
67
+ h, m, s, ms = int(h), int(m), int(s), int(ms)
68
+ td = timedelta(hours=abs(h), minutes=m, seconds=s,
69
+ microseconds=ms)
70
if h < 0:
71
return -td
72
else:
@@ -74,9 +78,13 @@ def TimeDelta_or_None(s):
74
78
def Time_or_None(s):
75
79
76
80
77
- return time(hour=h, minute=m, second=int(s),
- microsecond=int(math.modf(s)[0] * 1000000))
81
82
83
84
85
86
+ return time(hour=h, minute=m, second=s,
87
+ microsecond=ms)
88
except ValueError:
89
return None
90
0 commit comments