Skip to content

Commit 24d7976

Browse files
committed
[2025-02-03 08:22] Timezone fix patch
1 parent 437a63f commit 24d7976

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "weather_provider_api"
3-
version = "2.62.0"
3+
version = "2.62.50"
44
description = "Weather Provider Libraries and API"
55
authors = ["Verbindingsteam", "Raoul Linnenbank <[email protected]>"]
66
license = "MPL-2.0"

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)