Skip to content

Commit

Permalink
Simplify Swiss public transport coordinator (#128891)
Browse files Browse the repository at this point in the history
  • Loading branch information
miaucl authored Oct 21, 2024
1 parent 28a8ed6 commit 62773fa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ def remaining_time(self, departure) -> timedelta | None:
return departure_datetime - dt_util.as_local(dt_util.utcnow())
return None

def nth_departure_time(self, i: int) -> datetime | None:
"""Get nth departure time."""
connections = self._opendata.connections
if len(connections) > i and connections[i] is not None:
return dt_util.parse_datetime(connections[i]["departure"])
return None

async def _async_update_data(self) -> list[DataConnection]:
return await self.fetch_connections(limit=CONNECTIONS_COUNT)

Expand All @@ -101,7 +94,7 @@ async def fetch_connections(self, limit: int) -> list[DataConnection]:
connections = self._opendata.connections
return [
DataConnection(
departure=self.nth_departure_time(i),
departure=dt_util.parse_datetime(connections[i]["departure"]),
train_number=connections[i]["number"],
platform=connections[i]["platform"],
transfers=connections[i]["transfers"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"line": "T10"
},
{
"departure": "2024-01-06T18:14:00+0100",
"departure": "invalid",
"number": 11,
"platform": 11,
"transfers": 0,
Expand Down

0 comments on commit 62773fa

Please sign in to comment.