Returns the timestamp (datetime.datetime) as ISO8601 formatted string.
(timestamp)
| 91 | |
| 92 | |
| 93 | def _to_iso_string(timestamp): |
| 94 | """Returns the timestamp (datetime.datetime) as ISO8601 formatted string.""" |
| 95 | # Without `timespec='microseconds`, the `isoformat` function would truncate |
| 96 | # the fractional seconds part if it’s zero. However, we store timestamps |
| 97 | # as plain strings in the database, so that inconsistent serialization |
| 98 | # behaviour would make it tricky to perform queries on that value. |
| 99 | # E.g.: 2000-01-01T00:00:00.000000 and 2000-01-01T00:00:00 are logically |
| 100 | # equal, but a text-based comparison would fail. |
| 101 | return timestamp.isoformat(timespec='microseconds') |
no outgoing calls
no test coverage detected