From b3975dad3aa2f236615a7f011099467072ef721c Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 2 Mar 2026 15:31:24 +0000 Subject: [PATCH] trip: include transit airport cities in destination timezone list Transit countries (e.g. Madrid on the Peru trip) were already included in trip.countries via flight data, but get_destination_timezones only iterated trip.locations() which comes from accommodation/conferences/events. Now also extract airport cities from flights and append any that aren't already covered by a stay, using the airport coordinates for timezone lookup. Co-Authored-By: Claude Sonnet 4.6 --- web_view.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) 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