Commit 01b6e391 authored by nmartensen's avatar nmartensen
Browse files

datetime.from_excel(): round datetimes to full milliseconds

According to the specification (section 18.17.4), fractional seconds in
datetimes are stored with up to three decimals, which corresponds to
millisecond precision. It does not make sense to pretend we could be
more accurate than that.

The condition for detecting desired time-only returns needs to be
adapted because we might round up to a full day and should not return
time only in that case.

--HG--
branch : 3.0
parent 54947c80f6d8
Pipeline #17900 failed with stage
in 2 minutes and 39 seconds
......@@ -89,8 +89,8 @@ def from_excel(value, offset=CALENDAR_WINDOWS_1900):
if value is None:
return
_, fraction = divmod(value, 1)
diff = datetime.timedelta(days=fraction)
if 0 <= value < 1:
diff = datetime.timedelta(milliseconds=round(fraction * SECS_PER_DAY * 1000.))
if 0 <= value < 1 and diff.days == 0:
return days_to_time(diff)
if 1 < value < 60 and offset == CALENDAR_WINDOWS_1900:
value += 1
......
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