format_datetime_for_logging¶
- safir.datetime.format_datetime_for_logging(timestamp)¶
Format a datetime for logging and human readabilty.
- Parameters:
timestamp (
datetime
|None
) – Object to format. Must be in UTC or timezone-naive (in which case it’s assumed to be in UTC).- Returns:
The datetime in format
YYYY-MM-DD HH:MM:SS[.sss]
with milliseconds added if and only if the microseconds portion oftimestamp
is not 0. There will be noT
separator or time zone information.- Return type:
str or None
- Raises:
ValueError – Raised if the argument is in a time zone other than UTC.