[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision
Martin Panter
report at bugs.python.org
Tue Feb 23 05:33:09 EST 2016
Martin Panter added the comment:
About rounding: I’m not too sure what people would expect. Obviously it is much easier to implement truncating to zero. But it is different to many other rounding cases in Python; that is why I thought to make it explicit.
>>> datetime.fromtimestamp(59.9999999).isoformat(timespec="microseconds")
'1970-01-01T00:01:00.000000'
>>> datetime.fromtimestamp(59.999999).isoformat(timespec="milliseconds")
'1970-01-01T00:00:59.999'
>>> format(59.999999, ".3f")
'60.000'
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19475>
_______________________________________
More information about the Python-bugs-list
mailing list