Skip to content

Commit

Permalink
Merge pull request #32 from endor-force:Fix-TrainStopStatus
Browse files Browse the repository at this point in the history
Fix TrainStopStatus
  • Loading branch information
gjohansson-ST committed May 7, 2023
2 parents 5133edc + 1949d8b commit 69f7596
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pytrafikverket/trafikverket_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,20 @@ def __init__(
def get_state(self) -> TrainStopStatus:
"""Retrieve the state of the departure."""
if self.canceled:
return TrainStopStatus.CANCELED.value
return TrainStopStatus.CANCELED
if (
self.advertised_time_at_location is not None
and self.time_at_location is not None
and self.advertised_time_at_location != self.time_at_location
):
return TrainStopStatus.DELAYED.value
return TrainStopStatus.DELAYED
if (
self.advertised_time_at_location is not None
and self.estimated_time_at_location is not None
and self.advertised_time_at_location != self.estimated_time_at_location
):
return TrainStopStatus.DELAYED.value
return TrainStopStatus.ON_TIME.value
return TrainStopStatus.DELAYED
return TrainStopStatus.ON_TIME

def get_delay_time(self) -> timedelta | None:
"""Calculate the delay of a departure."""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name="pytrafikverket",
version="0.3.2",
version="0.3.3",
description="Retreive values from public API at the Swedish Transport Administration (Trafikverket).",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 69f7596

Please sign in to comment.