Skip to content

Commit 9eff7f0

Browse files
committed
Fix timezone parse for non-UTC timezone
1 parent 1986d06 commit 9eff7f0

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

ADDING-A-DATA-SOURCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def _fetch_channel(self, channel: Channel) -> None:
238238
```
239239
5. Before adding to queue, check whether document is newer than self._last_indexed_at, if not, skip it.
240240
```python
241-
last_modified = datetime.strptime(message["updated_at"], "%Y-%m-%dT%H:%M:%S.%fZ")
241+
last_modified = datetime.strptime(message["updated_at"], "%Y-%m-%dT%H:%M:%S.%f%z")
242242
if last_modified < self._last_index_time:
243243
logger.info(f"Message {message['id']} is too old, skipping")
244244
continue

app/data_source/sources/bookstack/bookstack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def _feed_book(self, book: Dict):
165165
self.add_task_to_queue(self._feed_page, raw_page=page)
166166

167167
def _feed_page(self, raw_page: Dict):
168-
last_modified = datetime.strptime(raw_page["updated_at"], "%Y-%m-%dT%H:%M:%S.%fZ")
168+
last_modified = datetime.strptime(raw_page["updated_at"], "%Y-%m-%dT%H:%M:%S.%f%z")
169169
if last_modified < self._last_index_time:
170170
return
171171

app/data_source/sources/google_drive/google_drive.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def _should_index_file(self, file):
7777
f"Skipping file {file['name']} because it's mime type is {file['mimeType']} which is not supported.")
7878
return False
7979

80-
last_modified = datetime.strptime(file['modifiedTime'], "%Y-%m-%dT%H:%M:%S.%fZ")
80+
last_modified = datetime.strptime(file['modifiedTime'], "%Y-%m-%dT%H:%M:%S.%f%z")
8181
if last_modified < self._last_index_time:
8282
return False
8383

@@ -170,7 +170,7 @@ def _feed_file(self, file):
170170

171171
parent_name = self._get_parents_string(file)
172172

173-
last_modified = datetime.strptime(file['modifiedTime'], "%Y-%m-%dT%H:%M:%S.%fZ")
173+
last_modified = datetime.strptime(file['modifiedTime'], "%Y-%m-%dT%H:%M:%S.%f%z")
174174

175175
author = file['lastModifyingUser'].get('displayName')
176176
author_image_url = file['lastModifyingUser'].get('photoLink')

app/data_source/sources/rocketchat/rocketchat.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __init__(self, *args, **kwargs):
7272
self._authors_cache: Dict[str, RocketchatAuthor] = {}
7373

7474
def _list_rooms(self) -> List[RocketchatRoom]:
75-
oldest = self._last_index_time.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
75+
oldest = self._last_index_time.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
7676
r = self._rocket_chat.call_api_get("rooms.get", updatedSince=oldest)
7777
json = r.json()
7878
data = json.get("update")
@@ -112,7 +112,7 @@ def _list_threads(self, channel: RocketchatRoom) -> List[RocketchatThread]:
112112
return [RocketchatThread(id=trds["_id"], name=trds["msg"], channel_id=trds["rid"]) for trds in data]
113113

114114
def _list_messages(self, channel: RocketchatRoom):
115-
oldest = self._last_index_time.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
115+
oldest = self._last_index_time.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
116116
data = []
117117
while oldest:
118118
r = self._rocket_chat.call_api_get("chat.syncMessages", roomId=channel.id, lastUpdate=oldest)
@@ -126,7 +126,7 @@ def _list_messages(self, channel: RocketchatRoom):
126126
return data
127127

128128
def _list_thread_messages(self, thread: RocketchatThread):
129-
oldest = self._last_index_time.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
129+
oldest = self._last_index_time.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
130130
data = []
131131
records = 0
132132
total = 1 # Set 1 to enter the loop
@@ -186,7 +186,7 @@ def _feed_channel(self, channel):
186186

187187
timestamp = message["ts"]
188188
message_id = message["_id"]
189-
readable_timestamp = datetime.datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%fZ")
189+
readable_timestamp = datetime.datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%f%z")
190190
message_url = f"{self._raw_config.get('url')}/{channel.id}?msg={message_id}"
191191
last_msg = BasicDocument(title=channel.name, content=text, author=author.name,
192192
timestamp=readable_timestamp, id=message_id,

0 commit comments

Comments
 (0)