diff --git a/src/plots/elexon_plots.py b/src/plots/elexon_plots.py index ea6edc65..d774b1f4 100644 --- a/src/plots/elexon_plots.py +++ b/src/plots/elexon_plots.py @@ -1,6 +1,6 @@ from typing import Callable, List, Optional, Tuple, Union import pandas as pd -from datetime import datetime, date, timedelta +from datetime import datetime, date, timedelta, UTC from plotly import graph_objects as go import streamlit as st from elexonpy.api_client import ApiClient @@ -132,7 +132,7 @@ def determine_start_and_end_datetimes( - start_datetime_utc: datetime object in UTC - end_datetime_utc: datetime object in UTC """ - now = datetime.utcnow() + now = datetime.now(UTC) # Determine start_datetime_utc if start_datetimes: diff --git a/tests/test_elexon_plot.py b/tests/test_elexon_plot.py index 2b94df0e..61ab68c6 100644 --- a/tests/test_elexon_plot.py +++ b/tests/test_elexon_plot.py @@ -1,7 +1,7 @@ from unittest.mock import Mock, patch import pandas as pd import pytest -from datetime import datetime +from datetime import datetime, UTC from plotly import graph_objects as go from plots.elexon_plots import add_elexon_plot, determine_start_and_end_datetimes, fetch_forecast_data from elexonpy.api_client import ApiClient @@ -9,7 +9,7 @@ def test_determine_start_and_end_datetimes_no_input(): # Test with no input - now = datetime.utcnow() + now = datetime.now(UTC) start, end = determine_start_and_end_datetimes([], []) assert start < now, "Start time should be before current time." assert end > start, "End time should be after start time."