Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/mock_vws/_query_validators/date_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,16 @@
date_header = request_headers["Date"]
gmt = ZoneInfo(key="GMT")

date = datetime.datetime.fromtimestamp(timestamp=0, tz=gmt)
dates: list[datetime.datetime] = []

Check warning on line 91 in src/mock_vws/_query_validators/date_validators.py

View check run for this annotation

Codecov / codecov/patch

src/mock_vws/_query_validators/date_validators.py#L91

Added line #L91 was not covered by tests
for date_format in _accepted_date_formats():
with contextlib.suppress(ValueError):
date = datetime.datetime.strptime(
date_header,
date_format,
).astimezone()
dates.append(date)

Check warning on line 98 in src/mock_vws/_query_validators/date_validators.py

View check run for this annotation

Codecov / codecov/patch

src/mock_vws/_query_validators/date_validators.py#L98

Added line #L98 was not covered by tests

date = dates[0]

Check warning on line 100 in src/mock_vws/_query_validators/date_validators.py

View check run for this annotation

Codecov / codecov/patch

src/mock_vws/_query_validators/date_validators.py#L100

Added line #L100 was not covered by tests
now = datetime.datetime.now(tz=gmt)
date_from_header = date.replace(tzinfo=gmt)
time_difference = now - date_from_header
Expand Down
Loading