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

0001 /*
0002    SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org>
0003    SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 
0006 function parseTicket(pdf, node, triggerNode) {
0007     const text = pdf.pages[triggerNode.location].text;
0008     let res = triggerNode.result[0];
0009     res.reservationFor.trainNumber = text.match(/er ([A-Z]+ \d+)\n/)[1];
0010     res.reservedTicket.ticketNumber = res.reservationNumber;
0011     res.reservationNumber = text.match(/code ([A-Z0-9]{4}-[A-Z0-9]{4})\n/)[1];
0012     const leg = text.match(/(\S.*\S)  +(\d\d:\d\d)  +(\S.*\S)  +(\d\d:\d\d)\n/);
0013     res.reservationFor.departureDay = undefined; // off by one in their ERA FCB data...
0014     res.reservationFor.departureTime = JsonLd.toDateTime(leg[1].replace('.', '') + ' ' + leg[2], 'd MMM yyyy hh:mm', ['en', 'nl']);
0015     res.reservationFor.arrivalTime = JsonLd.toDateTime(leg[3].replace('.', '') + ' ' + leg[4], 'd MMM yyyy hh:mm', ['en', 'nl']);
0016     const seat = text.match(/(?:Carriage|Rijtuig) (.*) (?:Place|Plaats) (.*)\n/);
0017     if (seat) {
0018         res.reservedTicket.ticketedSeat.seatSection = seat[1];
0019         res.reservedTicket.ticketedSeat.seatNumber = seat[2];
0020     }
0021     return res;
0022 }