Commit 79308a08 authored by Volker Krause's avatar Volker Krause
Browse files

Decode and use the issuing time from ERA FCB tickets

parent 8685e376
Pipeline #254733 passed with stage
in 8 minutes and 3 seconds
......@@ -122,6 +122,16 @@ void Fcb::IssuingData::decode(UPERDecoder &decoder)
FCB_READ_CUSTOM(pointOfSale);
}
QDateTime Fcb::IssuingData::issueingDateTime() const
{
QDate date(issuingYear, 1, 1);
date = date.addDays(issuingDay - 1);
if (issuingTimeIsSet()) {
return QDateTime(date, QTime(0,0).addSecs(issuingTime * 60), Qt::UTC);
}
return QDateTime(date, {});
}
void Fcb::CustomerStatusType::decode(UPERDecoder &decoder)
{
decodeSequence(decoder);
......
......@@ -10,6 +10,7 @@
#include "asn1/uperelement.h"
#include <QDateTime>
#include <QList>
#include <QVariant>
......@@ -101,6 +102,10 @@ class IssuingData {
UPER_ELEMENT_OPTIONAL(int, issuedOnLine)
UPER_ELEMENT_OPTIONAL(KItinerary::Fcb::GeoCoordinateType, pointOfSale)
UPER_GADGET_FINALIZE
Q_PROPERTY(QDateTime issueingDateTime READ issueingDateTime)
public:
QDateTime issueingDateTime() const;
};
enum GenderType {
......
......@@ -10,6 +10,7 @@
#include <KItinerary/JsonLdDocument>
#include <KItinerary/Uic9183Parser>
#include <KItinerary/Rct2Ticket>
#include <era/fcbticket.h>
#include <uic9183/uic9183head.h>
#include <uic9183/vendor0080block.h>
......@@ -50,8 +51,11 @@ void Uic9183DocumentProcessor::expandNode(ExtractorDocumentNode &node, [[maybe_u
// while that is usually correct it cannot contain a time zone, unlike the (often) enclosing PDF document´
if (!node.contextDateTime().isValid()) {
const auto p = node.content<Uic9183Parser>();
const auto u_head = p.findBlock<Uic9183Head>();
node.setContextDateTime(u_head.issuingDateTime());
if (const auto u_flex = p.findBlock<Fcb::UicRailTicketData>(); u_flex.isValid()) {
node.setContextDateTime(u_flex.issuingDetail.issueingDateTime());
} else if (const auto u_head = p.findBlock<Uic9183Head>(); u_head.isValid()) {
node.setContextDateTime(u_head.issuingDateTime());
}
}
}
......
Supports Markdown
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