Commit a94b7dc3 authored by Volker Krause's avatar Volker Krause
Browse files

Switch context date arguments in ERA SSB to QDateTime as well

Not that we need that level of detail, but we cannot pass a QDate safely
through JS.
parent 8ecaf8e5
......@@ -44,16 +44,16 @@ bool SSBv1Ticket::maybeSSB(const QByteArray& data)
return (data.at(0) >> 4) == SSB_VERSION;
}
QDate SSBv1Ticket::firstDayOfValidity(const QDate &contextDate) const
QDate SSBv1Ticket::firstDayOfValidity(const QDateTime &contextDate) const
{
if (!isValid() || firstDayOfValidityDay() == 0 || firstDayOfValidityDay() > 366) {
return {};
}
QDate d(contextDate.year(), 1, 1);
QDate d(contextDate.date().year(), 1, 1);
return d.addDays(firstDayOfValidityDay() - 1);
}
QDateTime SSBv1Ticket::departureTime(const QDate &contextDate) const
QDateTime SSBv1Ticket::departureTime(const QDateTime &contextDate) const
{
if (!isValid() || departureTimeSlot() == 0 || departureTimeSlot() > 48) {
return {};
......
......@@ -65,9 +65,9 @@ public:
bool isValid() const;
/** First day of validity. */
Q_INVOKABLE QDate firstDayOfValidity(const QDate &contextDate = QDate::currentDate()) const;
Q_INVOKABLE QDate firstDayOfValidity(const QDateTime &contextDate = QDateTime::currentDateTime()) const;
/** Decoded departure time slot. */
Q_INVOKABLE QDateTime departureTime(const QDate &contextDate = QDate::currentDate()) const;
Q_INVOKABLE QDateTime departureTime(const QDateTime &contextDate = QDateTime::currentDateTime()) const;
/** Raw barcode data. */
QByteArray rawData() const;
......
......@@ -54,13 +54,13 @@ bool SSBv3Ticket::maybeSSB(const QByteArray& data)
return (data.at(0) >> 4) == SSB_VERSION;
}
QDate SSBv3Ticket::issueDate(const QDate &contextDate)
QDate SSBv3Ticket::issueDate(const QDateTime &contextDate)
{
if (m_data.isEmpty() || ticketTypeCode() > SSBv3Ticket::RPT) {
return {};
}
int year = contextDate.year();
int year = contextDate.date().year();
if (year % 10 != yearOfIssue()) {
year += (10 + yearOfIssue() - year % 10) % 10;
}
......@@ -69,7 +69,7 @@ QDate SSBv3Ticket::issueDate(const QDate &contextDate)
return d;
}
QDate SSBv3Ticket::type1DepartureDay(const QDate& contextDate)
QDate SSBv3Ticket::type1DepartureDay(const QDateTime& contextDate)
{
if (ticketTypeCode() != SSBv3Ticket::IRT_RES_BOA) {
return {};
......
......@@ -112,9 +112,9 @@ public:
bool isValid() const;
/** Date of issue. */
Q_INVOKABLE QDate issueDate(const QDate &contextDate = QDate::currentDate());
Q_INVOKABLE QDate issueDate(const QDateTime &contextDate = QDateTime::currentDateTime());
/** Departure day for type 1 (IRT/RES/BOA) tickets. */
Q_INVOKABLE QDate type1DepartureDay(const QDate &contextDate = QDate::currentDate());
Q_INVOKABLE QDate type1DepartureDay(const QDateTime &contextDate = QDateTime::currentDateTime());
/** Raw barcode data. */
QByteArray rawData() const;
......
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