Skip to content

Commit

Permalink
fix(locforecast): Converting time when hour is 23
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroWave022 committed Oct 11, 2023
1 parent 52ed0cd commit 43854f3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions yr_weather/data/locationforecast.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Classes storing data used by yr_weather.locationforecast"""

from datetime import datetime
from datetime import datetime, timedelta
from typing import Optional, List
from dataclasses import dataclass, fields

Expand Down Expand Up @@ -198,7 +198,9 @@ def __init__(self, forecast_data: APIForecast) -> None:

def _conv_to_nearest_hour(self, date: datetime) -> datetime:
if date.minute >= 30:
return date.replace(microsecond=0, second=0, minute=0, hour=date.hour + 1)
return date.replace(
microsecond=0, second=0, minute=0, hour=date.hour
) + timedelta(hours=1)

return date.replace(microsecond=0, second=0, minute=0)

Expand Down

0 comments on commit 43854f3

Please sign in to comment.