round microseconds up to a whole number and zero-pad to 3 chars
This commit is contained in:
parent
d3ed08e336
commit
58a4fd7e74
1 changed files with 2 additions and 1 deletions
|
@ -20,7 +20,8 @@ def iso8601_format(dt: datetime.datetime, milliseconds: bool=False) -> str:
|
||||||
|
|
||||||
ms_format = ""
|
ms_format = ""
|
||||||
if milliseconds:
|
if milliseconds:
|
||||||
ms_format = ".%d" % (dt.microsecond/1000)
|
ms_format = ".%s" % str(int(dt.microsecond/1000)).zfill(3)
|
||||||
|
|
||||||
return "%s%s%s" % (dt_format, ms_format, tz_format)
|
return "%s%s%s" % (dt_format, ms_format, tz_format)
|
||||||
def iso8601_format_now(milliseconds: bool=False) -> str:
|
def iso8601_format_now(milliseconds: bool=False) -> str:
|
||||||
now = datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc)
|
now = datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc)
|
||||||
|
|
Loading…
Reference in a new issue