@@ -60,9 +60,13 @@ def DateTime_or_None(s):
60
60
def TimeDelta_or_None (s ):
61
61
try :
62
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 ))
63
+ if '.' in s :
64
+ s , ms = s .split ('.' )
65
+ 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 )
66
70
if h < 0 :
67
71
return - td
68
72
else :
@@ -74,9 +78,13 @@ def TimeDelta_or_None(s):
74
78
def Time_or_None (s ):
75
79
try :
76
80
h , m , s = s .split (':' )
77
- h , m , s = int (h ), int (m ), float (s )
78
- return time (hour = h , minute = m , second = int (s ),
79
- microsecond = int (math .modf (s )[0 ] * 1000000 ))
81
+ if '.' in s :
82
+ s , ms = s .split ('.' )
83
+ else :
84
+ ms = 0
85
+ h , m , s , ms = int (h ), int (m ), int (s ), int (ms )
86
+ return time (hour = h , minute = m , second = s ,
87
+ microsecond = ms )
80
88
except ValueError :
81
89
return None
82
90
0 commit comments