Skip to content

Commit a4fe5e0

Browse files
authored
Merge pull request #32 from simple-repository/feature/utc-timezones
Ensure that all release info upload times are UTC
2 parents 1d0d946 + 01cb02a commit a4fe5e0

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

simple_repository_browser/fetch_description.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,6 @@ async def _fetch_metadata_resource(
192192
if isinstance(resource, model.TextResource):
193193
with open(tmp_file_path, "wb") as tmp:
194194
tmp.write(resource.text.encode())
195-
if not file.upload_time:
196-
# If the repository doesn't provide information about the upload time, estimate
197-
# it from the headers of the resource, if they exist.
198-
if ct := resource.context.get("creation-date"):
199-
if isinstance(ct, str):
200-
file = dataclasses.replace(
201-
file, upload_time=datetime.datetime.fromisoformat(ct)
202-
)
203195
elif isinstance(resource, model.HttpResource):
204196
await fetch_file(resource.url, tmp_file_path)
205197
else:

simple_repository_browser/short_release_info.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import dataclasses
2-
from datetime import datetime
2+
from datetime import datetime, timezone
33
import functools
44
import types
55
import typing
@@ -135,9 +135,12 @@ def release_infos(
135135
quarantined_file: Quarantinefile = {
136136
"filename": file_info["filename"],
137137
"quarantine_release_time": datetime.strptime(
138-
file_info["quarantine_release_time"], date_format
139-
),
140-
"upload_time": datetime.strptime(file_info["upload_time"], date_format),
138+
file_info["quarantine_release_time"],
139+
date_format,
140+
).replace(tzinfo=timezone.utc),
141+
"upload_time": datetime.strptime(
142+
file_info["upload_time"], date_format
143+
).replace(tzinfo=timezone.utc),
141144
}
142145
version_str = None
143146
try:

0 commit comments

Comments
 (0)