|
18 | 18 | # pylint: disable=protected-access |
19 | 19 | import base64 as _base64 |
20 | 20 | import dataclasses as _dataclasses |
21 | | -import datetime as _dt |
22 | 21 | import functools as _functools |
23 | 22 | import json as _json |
24 | 23 | import typing as _typing |
@@ -105,25 +104,9 @@ def _message_handler( |
105 | 104 | data = event_dict["data"] |
106 | 105 | message_dict = data["message"] |
107 | 106 |
|
108 | | - # if no microseconds are present, we should set them to 0 to prevent parsing from failing |
109 | | - if "." not in event_dict["time"]: |
110 | | - event_dict["time"] = event_dict["time"].replace("Z", ".000000Z") |
111 | | - if "." not in message_dict["publish_time"]: |
112 | | - message_dict["publish_time"] = message_dict["publish_time"].replace("Z", ".000000Z") |
113 | | - |
114 | | - time = _dt.datetime.strptime( |
115 | | - event_dict["time"], |
116 | | - "%Y-%m-%dT%H:%M:%S.%f%z", |
117 | | - ) |
118 | | - |
119 | | - publish_time = _dt.datetime.strptime( |
120 | | - message_dict["publish_time"], |
121 | | - "%Y-%m-%dT%H:%M:%S.%f%z", |
122 | | - ) |
123 | | - |
124 | 107 | # Convert the UTC string into a datetime object |
125 | | - event_dict["time"] = time |
126 | | - message_dict["publish_time"] = publish_time |
| 108 | + event_dict["time"] = _util.timestamp_conversion(event_dict["time"]) |
| 109 | + message_dict["publish_time"] = _util.timestamp_conversion(message_dict["publish_time"]) |
127 | 110 |
|
128 | 111 | # Pop unnecessary keys from the message data |
129 | 112 | # (we get these keys from the snake case alternatives that are provided) |
|
0 commit comments