Hi, based on the airport ICAO and flight number I want to get the ETA for a flight that is in transit (in air)
I’m trying with the FlightInfo method, however, the method does not always return the next flight that will arrive at the airport, so I’m forced to get 5 total flights and analyze each one, by departure / ETA, which one is the next one to arrive at the airport.
This seems extremely overcomplicated… is there a simpler way? I just want to get the ETA.
FlightInfoStruct fi = client.FlightInfo(flight, 5);
foreach (FlightStruct x in fi.flights) {
DateTime filed_departuretime = UnixTimeStampToDateTime(x.filed_departuretime);
if (x.origin == "TJSJ" && filed_departuretime > DatePickupActual) {
TimeSpan timeDifference = filed_departuretime.Subtract(DatePickupActual);
// if the difference is bigger than 4 hours (240 minutes) that
// means it's another day flight, so skip onto the next record
if (timeDifference.TotalMinutes < 240) {
// some code here...
break;
}
}
}