I got a reply from transport api- seems this issue is not just limited to my station:
"
Since last week we have been investigating an issue with live data for many Scottish trains stations being off by one hour. This is not effecting all stations in Scotland. In fact we had thought the issue was concentrated around Glasgow, so it’s useful to have this report of this example.
In any case it seems likely to be an issue with the underlying data feed in these areas. We are working to pin down exactly what is going wrong, so that we can report it to the data suppliers. We shall let you know what we find."
So in that event I’ve pressed on with modifying the module to avoid this data.
I’ve moved my time check code to the processtrains function… It mostly works, except whenever I try to increment the counter once Ive skipped a row (so that the total values displayed should match the ‘max results’ parameter it stops working. Any ideas where I could be going wrong?
for (var i = 0; i < counter; i++) {
var thisTrain = data.departures.all[i];
//Check current time vs. departure & don't show it if it's past departure
var nowtime = new Date();
nowtime = ("0" + nowtime.getHours()).slice(-2) + ":" +
("0" + nowtime.getMinutes()).slice(-2) + ":" +
("0" + nowtime.getSeconds()).slice(-2);
if (thisTrain.expected_departure_time < nowtime)
{
//Train already departed so we need to increment counter
counter++;
} else {
//additional check to see if counter now exceeds length of data
if (counter > data.departures.all.length){
window.alert("counter exceeds data length");
}
else{
//push data
this.trains.data.push({
plannedDeparture: thisTrain.aimed_departure_time,
actualDeparture: thisTrain.expected_departure_time,
status: thisTrain.status,
origin: thisTrain.origin_name,
destination: thisTrain.destination_name,
leavesIn: thisTrain.best_arrival_estimate_mins,
platform: thisTrain.platform
});
}
}
}
I threw in the alert to see when the if was proving as true, but if my counter value is over the limit it just throws the pop up straight away rather than sending through the data. Am I wrong in thinking it should at least be pushing the lines through up until the condition is met?