Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:
Does timespec fulfill this use case to always return microseconds? https://docs.python.org/3/library/datetime.html#datetime.datetime.isoformat Return a string representing the date and time in ISO 8601 format: YYYY-MM-DDTHH:MM:SS.ffffff, if microsecond is not 0 YYYY-MM-DDTHH:MM:SS, if microsecond is 0 The optional argument timespec specifies the number of additional components of the time to include (the default is 'auto'). It can be one of the following: 'auto': Same as 'seconds' if microsecond is 0, same as 'microseconds' otherwise. 'hours': Include the hour in the two-digit HH format. 'minutes': Include hour and minute in HH:MM format. 'seconds': Include hour, minute, and second in HH:MM:SS format. 'milliseconds': Include full time, but truncate fractional second part to milliseconds. HH:MM:SS.sss format. 'microseconds': Include full time in HH:MM:SS.ffffff format. ./python Python 3.9.0a4+ (heads/master:6723e933c4, Mar 21 2020, 06:54:01) [GCC 7.5.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import datetime >>> datetime.datetime(1, 1, 1).isoformat(timespec='auto') '0001-01-01T00:00:00' >>> datetime.datetime(1, 1, 1).isoformat(timespec='microseconds') '0001-01-01T00:00:00.000000' ---------- nosy: +xtreak _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40076> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com