Skip to content

Commit

Permalink
Fix issues with timestamps: traffic issue xoolive#338
Browse files Browse the repository at this point in the history
  • Loading branch information
figuetbe committed Apr 30, 2023
1 parent e433e95 commit 399bce3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/traffic/data/weather/metar.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from datetime import datetime, timedelta, timezone
from typing import List, Optional, Union

import pandas as pd
import requests
from metar import Metar

import pandas as pd

from ...core.structure import Airport
from ...core.time import timelike, to_datetime

Expand Down Expand Up @@ -56,6 +55,8 @@ def get(
if stop is not None
else start + timedelta(hours=24)
)
if stop == start:
stop += timedelta(hours=1)

str_ap = ""
for ap in self.airports:
Expand All @@ -70,7 +71,7 @@ def get(
f"year2={stop.year}&"
f"month2={stop.month}&"
f"day2={stop.day}&"
f"hour2={stop.hour+1}&"
f"hour2={stop.hour}&"
f"tz=Etc%2FUTC&format=onlycomma&latlon=no&elev=no&"
f"missing=M&trace=T&direct=no&report_type=3&report_type=4"
)
Expand All @@ -84,15 +85,14 @@ def get(
m.split(",")[-1],
month=datetime.strptime(
m.split(",")[1], "%Y-%m-%d %H:%M"
)
.astimezone(timezone.utc)
.month,
).month,
year=datetime.strptime(
m.split(",")[1], "%Y-%m-%d %H:%M"
)
.astimezone(timezone.utc)
.year,
strict=False,
utcdelta=timedelta(hours=0),
)
)
for m in list_[1:]
Expand Down

0 comments on commit 399bce3

Please sign in to comment.