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 parseBooking(content) {
0007     var baseRes = JsonLd.newFlightReservation();
0008     const flight = content.match(/(\d{1,2}\w{3}\d{4}) Flight No.([A-Z0-9 ]+) \[.*:([^\]]+)\]\n.*from (.*) at (\d{2}:\d{2}) -> .* at (.*) at (\d{2}:\d{2})/);
0009     baseRes.reservationNumber = flight[3];
0010     baseRes.reservationFor.flightNumber = flight[2];
0011     baseRes.reservationFor.departureAirport.name = flight[4];
0012     baseRes.reservationFor.departureTime = JsonLd.toDateTime(flight[1] + flight[5], "ddMMMyyyyhh:mm", "en");
0013     baseRes.reservationFor.arrivalAirport.name = flight[6];
0014     baseRes.reservationFor.arrivalTime = JsonLd.toDateTime(flight[1] + flight[7], "ddMMMyyyyhh:mm", "en");
0015 
0016     var reservations = new Array();
0017     const passengers = content.match(/-Passengers\n([\s\S]*?)\n-/)[1].split(/\n/);
0018     for (const passenger of passengers) {
0019         const name = passenger.match(/M[a-z]+\.(.*)\(/);
0020         if (!name) {
0021             break;
0022         }
0023         var res = JsonLd.clone(baseRes);
0024         res.underName.name = name[1];
0025         reservations.push(res);
0026     }
0027 
0028     return reservations;
0029 }