Open bschoening opened 1 year ago
datetime
objects only supports microsecond precision see. The isodate
library parses the format then creates a datatime
objects date
, datetime
, and time
. timedelta
do include milliseconds. The incompatibility is the Python standard library not supporting more precise divisions of the seconds.
isodate has its own Duration class, which could be extended. There would still be conversion issues from Duration to timedelta
.
Here's an article which briefly discusses nanosecond support with a few examples and suggests using NumPy's datetime64
.
Edit: Python 3.7 PEP 564 added nanoseconds functions. This does not impact what I discussed above. It added functions but did not seem to change existing functions. Provided for context.
ISO 8601 supports nanosecond level formats. For compatibility with implementations which utilize nanoseconds, its difficult to work around this incompatibility.
I realize the documentation mentions "fractional seconds are limited to microseconds", but no rationale is given for not aligning with the ISO 8601 precision.