format_datetime_for_logging#

safir.datetime.format_datetime_for_logging(timestamp)#

Format a datetime for logging and human readabilty.

Parameters:

timestamp (Optional[datetime]) – 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 of timestamp is not 0. There will be no T separator or time zone information.

Return type:

str or None

Raises:

ValueError – Raised if the argument is in a time zone other than UTC.