Skip to content

Commit

Permalink
Fixed bug where early trains would cause a crash
Browse files Browse the repository at this point in the history
  • Loading branch information
w-henderson committed Nov 29, 2020
1 parent 9dd18ab commit 5098dac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist/
dist/
*.exe
2 changes: 1 addition & 1 deletion NimTrains.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.1.0"
version = "0.1.1"
author = "William Henderson"
description = "A simple command-line utility and Nim package to get realtime UK train information."
license = "GPL-3.0"
Expand Down
6 changes: 5 additions & 1 deletion src/api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,18 @@ proc loadDepartures(crs: string): Station =
except:
discard "Ignore exception"

var delay = 0
if serviceXML.findAll("Delay")[0].attr("Minutes") != "":
delay = parseInt(serviceXML.findAll("Delay")[0].attr("Minutes"))

# Put everything together into a Service object
services[actualIterValue] = Service(
destination: serviceXML.findAll("Destination1")[0].attr("name"),
destinationCRS: serviceXML.findAll("Destination1")[0].attr("crs"),
origin: serviceXML.findAll("Origin1")[0].attr("name"),
scheduledDeparture: parseTime(serviceXML.findAll("DepartTime")[0].attr("time")),
expectedDeparture: expectedDeparture,
delay: parseInt("0" & serviceXML.findAll("Delay")[0].attr("Minutes")),
delay: delay,
delayCause: noneIfNotFound(serviceXML, "DelayCause"),
platform: platform,
platformComment: noneIfNotFound(serviceXML, "PlatformComment1") & " " & noneIfNotFound(serviceXML, "PlatformComment2"),
Expand Down

0 comments on commit 5098dac

Please sign in to comment.