Skip to content

Commit 4acdccf

Browse files
authored
Release 2.62 (#143)
* [2025-01-30 17:12] Partial CDS update * [2025-02-03 08:22] Timezone fix patch
1 parent 74115e3 commit 4acdccf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

weather_provider_api/routers/weather/utils/date_helpers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pandas as pd
1212
from fastapi import HTTPException
1313
from loguru import logger
14+
from pytz import UTC
1415

1516

1617
def parse_datetime(
@@ -66,9 +67,14 @@ def validate_begin_and_end(
6667
"""Checks the given date parameters and replaces them with default values if they aren't valid.
6768
The resulting values are then returned.
6869
"""
70+
start = start.astimezone(UTC) if start else None
71+
end = end.astimezone(UTC) if end else None
72+
data_start = data_start.astimezone(UTC) if data_start else None
73+
data_end = data_end.astimezone(UTC) if data_end else None
74+
6975
if data_end is None:
7076
# Assuming predictions fill in this value, the most recent value for the past is before "now".
71-
data_end = datetime.utcnow()
77+
data_end = datetime.now(UTC)
7278

7379
if data_start is not None and data_start > start:
7480
# If the starting moment lies before what can be requested, put it at the moment from which it can be requested

0 commit comments

Comments
 (0)