Skip to content

Commit

Permalink
fix timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
drosoCode committed Sep 22, 2022
1 parent 8d597cb commit 1819c02
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions idfm_api/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from datetime import datetime
from datetime import datetime, timezone
from functools import total_ordering
from enum import Enum, unique

Expand Down Expand Up @@ -65,8 +65,8 @@ def from_json(data: dict):
name=name,
id=data.get("id"),
message=message,
start_time=datetime.strptime(data.get("RecordedAtTime"), '%Y-%m-%dT%H:%M:%S.%fZ'),
end_time=datetime.strptime(data.get("ValidUntilTime"), '%Y-%m-%dT%H:%M:%S.%fZ'),
start_time=datetime.strptime(data.get("RecordedAtTime"), '%Y-%m-%dT%H:%M:%S.%fZ').replace(tzinfo=timezone.utc),
end_time=datetime.strptime(data.get("ValidUntilTime"), '%Y-%m-%dT%H:%M:%S.%fZ').replace(tzinfo=timezone.utc),
type=data["InfoChannelRef"]["value"],
severity=data.get("InfoMessageVersion")
)
Expand Down Expand Up @@ -99,9 +99,9 @@ def from_json(data: dict):

sch = None
if "ExpectedArrivalTime" in data["MonitoredVehicleJourney"]["MonitoredCall"]:
sch = datetime.strptime(data["MonitoredVehicleJourney"]["MonitoredCall"]["ExpectedArrivalTime"], '%Y-%m-%dT%H:%M:%S.%fZ')
sch = datetime.strptime(data["MonitoredVehicleJourney"]["MonitoredCall"]["ExpectedArrivalTime"], '%Y-%m-%dT%H:%M:%S.%fZ').replace(tzinfo=timezone.utc)
elif "ExpectedDepartureTime" in data["MonitoredVehicleJourney"]["MonitoredCall"]:
sch = datetime.strptime(data["MonitoredVehicleJourney"]["MonitoredCall"]["ExpectedDepartureTime"], '%Y-%m-%dT%H:%M:%S.%fZ')
sch = datetime.strptime(data["MonitoredVehicleJourney"]["MonitoredCall"]["ExpectedDepartureTime"], '%Y-%m-%dT%H:%M:%S.%fZ').replace(tzinfo=timezone.utc)
else:
return None

Expand Down

0 comments on commit 1819c02

Please sign in to comment.