diff --git a/web_view.py b/web_view.py index ea2d5c8..4fa2d7c 100755 --- a/web_view.py +++ b/web_view.py @@ -887,10 +887,46 @@ def get_destination_timezones(trip: Trip) -> list[StrDict]: if candidate: per_location[key].append(candidate) + # Also collect airport locations from flights, for transit countries + flight_locations: list[tuple[str, Country]] = [] + seen_flight_keys: set[tuple[str, str]] = set() + for item in trip.travel: + if item.get("type") != "flight": + continue + for airport_key in ("from_airport", "to_airport"): + airport = item.get(airport_key) + if not isinstance(airport, dict): + continue + city = airport.get("city") + country_code = airport.get("country") + if not isinstance(city, str) or not isinstance(country_code, str): + continue + if country_code == "gb": + continue + key = (city, country_code.lower()) + lat = airport.get("latitude") + lon = airport.get("longitude") + if isinstance(lat, (int, float)) and isinstance(lon, (int, float)): + location_coords.setdefault(key, (float(lat), float(lon))) + if key not in seen_flight_keys: + seen_flight_keys.add(key) + flight_country = agenda.get_country(country_code) + if flight_country: + flight_locations.append((city, flight_country)) + + existing_location_keys = { + (loc, c.alpha_2.lower()) for loc, c in trip.locations() + } + all_locations = list(trip.locations()) + [ + (city, country) + for city, country in flight_locations + if (city, country.alpha_2.lower()) not in existing_location_keys + ] + destination_times: list[StrDict] = [] trip_end = trip.end or trip.start - for location, country in trip.locations(): + for location, country in all_locations: country_code = country.alpha_2.lower() key = (location, country_code) timezone_name = None