Commit d231e700 authored by nmartensen's avatar nmartensen
Browse files

fix negative timedeltas with fractional seconds

--HG--
branch : 3.0
parent 27a2a16bf748
Pipeline #18855 passed with stage
in 2 minutes and 48 seconds
......@@ -97,7 +97,7 @@ def from_excel(value, epoch=WINDOWS_EPOCH, timedelta=False):
td = datetime.timedelta(days=value)
if td.microseconds:
# round to millisecond precision
td = datetime.timedelta(seconds=int(td.total_seconds()),
td = datetime.timedelta(seconds=td.total_seconds() // 1,
microseconds=round(td.microseconds, -3))
return td
......
......@@ -130,6 +130,10 @@ def test_from_excel(value, expected):
(-0.5, timedelta(hours=-12)),
(1.25, timedelta(hours=30)),
(-1.25, timedelta(hours=-30)),
(0.0006944443, timedelta(minutes=1)),
(-0.0006944443, timedelta(minutes=-1)),
(0.0006944328, timedelta(minutes=1, microseconds=-1000)),
(-0.0006944328, timedelta(minutes=-1, microseconds=1000)),
(59.5, timedelta(days=59, hours=12)),
(60.5, timedelta(days=60, hours=12)),
(61.5, timedelta(days=61, hours=12)),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment