File indexing completed on 2024-12-29 04:51:05

0001 /*
0002    SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
0003    SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 
0006 function parseReservation(content) {
0007     const ref = content.match(/Booking Reference\n(\S{6})/)[1];
0008 
0009     // TODO multiple legs?
0010     const leg = content.match(/(\S{2}\d{1,4})】[\s\S]*?├ (.*) (.*)\n├ (\d{4}\/\d{2}\/\d{2}).*(\d{2}:\d{2})\n| ↓\n├ (.*) (.*)\n└ (\d{4}\/\d{2}\/\d{2}).*(\d{2}:\d{2})/);
0011 
0012     var res = JsonLd.newFlightReservation();
0013     res.reservationNumber = ref;
0014     res.reservationFor.flightNumber = leg[1];
0015     res.reservationFor.departureAirport.name = leg[2];
0016     res.reservationFor.departureTerminal = leg[3];
0017     res.reservationFor.departureTime = JsonLd.toDateTime(leg[4] + ' ' + leg[5], 'yyyy/MM/dd hh:mm', 'jp');
0018     res.reservationFor.arrivalAirport.name = leg[6];
0019     res.reservationFor.arrivalTerminal = leg[7];
0020     res.reservationFor.arrivalTime = JsonLd.toDateTime(leg[8] + ' ' + leg[9], 'yyyy/MM/dd hh:mm', 'jp');
0021 
0022     // TODO multiple passengers?
0023     const pas = content.match(/Name: (.*)\nTitle: .*\n\S{2}\d{1,4}\nAdvance Seat selection: (.*)\n/);
0024     res.underName.name = pas[1];
0025     res.airplaneSeat = pas[2];
0026 
0027     return res;
0028 }