Commit 20063b6e authored by Volker Krause's avatar Volker Krause

Fix Czech Railway unit tests

Reviewers: dvratil

Subscribers: #kde_pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D11497
parent 56d7f5c5
[
{
"@type": "TrainReservation",
"reservationFor": {
"@type": "TrainTrip",
"arrivalStation": {
"@type": "TrainStation",
"name": "Praha Masarykovo n."
},
"arrivalTime": "2017-01-01T17:33:00",
"departureStation": {
"@type": "TrainStation",
"name": "Lysá n.Labem"
},
"departureTime": "2017-01-01T16:55:00",
"trainNumber": "Os 9424"
},
"reservationNumber": "VM5MZ3"
}
]
......@@ -53,17 +53,17 @@ function parseSeat(res, text) {
// you can even do that with Czech Railways...
function detectYear(tripDate, purchaseDate)
{
var tripDay = tripDate[1];
var tripMonth = tripDate[2];
var purchaseDay = purchaseDate[1];
var purchaseMonth = purchaseDate[2];
var purchaseYear = purchaseDate[3];
var tripDay = parseInt(tripDate[1]);
var tripMonth = parseInt(tripDate[2]);
var purchaseDay = parseInt(purchaseDate[2]);
var purchaseMonth = parseInt(purchaseDate[3]);
var purchaseYear = parseInt(purchaseDate[4]);
if ((purchaseMonth < tripMonth) ||
(purchaseMonth == tripMonth) && (purchaseDay <= tripDay)) {
return purchaseYear;
} else {
return parseInt(purchaseYear) + 1;
return purchaseYear + 1;
}
}
......@@ -129,11 +129,10 @@ function parseLegs(text, purchaseDate) {
}
function main(text) {
console.log(text);
var reservations = new Array();
var pos = 0;
var purchaseDate = text.match(/[d|D]atum platby|UZP: ([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})/)
var purchaseDate = text.match(/([d|D]atum platby|UZP): ([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})/)
while (true) {
// find itinerary headers
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment