MCPcopy Index your code
hub / github.com/webpy/webpy / convert_timestamp

Function convert_timestamp

tests/test_session.py:23–30  ·  view source on GitHub ↗

Convert an ISO 8601 formatted bytestring to a datetime.datetime object. >>> convert_timestamp(b'2023-04-05T06:07:08.000009') datetime.datetime(2023, 4, 5, 6, 7, 8, 9)

(time_stamp: bytes)

Source from the content-addressed store, hash-verified

21
22
23def convert_timestamp(time_stamp: bytes) -> datetime:
24 """
25 Convert an ISO 8601 formatted bytestring to a datetime.datetime object.
26
27 >>> convert_timestamp(b'2023-04-05T06:07:08.000009')
28 datetime.datetime(2023, 4, 5, 6, 7, 8, 9)
29 """
30 return datetime.strptime(time_stamp.decode("utf-8"), "%Y-%m-%dT%H:%M:%S.%f")
31
32
33sqlite3.register_adapter(datetime, adapt_datetime_iso)

Callers

nothing calls this directly

Calls 1

decodeMethod · 0.80

Tested by

no test coverage detected