Print: dates in QLocale::ShortFormat

Note: this needs test!
Expected behaviour is that date format switches with language switch!
This my be no problem in most cases however, e.g. in some cases there
would be a different date format on the tickets.
This commit is contained in:
Siegfried Siegert 2023-11-30 16:33:47 +01:00
parent 8c1aa26145
commit e95de7f9e4
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03

View File

@ -506,6 +506,10 @@ void ATBDeviceControllerPlugin::requestPrintTicket(nsDeviceControllerInterface::
QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate); QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate);
QDateTime currentDateTime = QDateTime::fromString(printingData["currentDateTime"].toString(), Qt::ISODate); QDateTime currentDateTime = QDateTime::fromString(printingData["currentDateTime"].toString(), Qt::ISODate);
QString parkingEndDateString = QLocale().toString(parkingEndDateTime.date(), QLocale::ShortFormat);
QString currentDateString = QLocale().toString(currentDateTime.date(), QLocale::ShortFormat);
// set dynamic printer data: // set dynamic printer data:
QByteArray ba_licenseplate = codec->fromUnicode(printingData["licenseplate"].toString()); QByteArray ba_licenseplate = codec->fromUnicode(printingData["licenseplate"].toString());
memcpy((char*)dynTicketData->licensePlate, ba_licenseplate.data(), std::min(ba_licenseplate.size(),8)); memcpy((char*)dynTicketData->licensePlate, ba_licenseplate.data(), std::min(ba_licenseplate.size(),8));
@ -517,11 +521,11 @@ void ATBDeviceControllerPlugin::requestPrintTicket(nsDeviceControllerInterface::
QByteArray ba_parkingEndTime = codec->fromUnicode(parkingEndDateTime.toString("hh:mm")); QByteArray ba_parkingEndTime = codec->fromUnicode(parkingEndDateTime.toString("hh:mm"));
memcpy((char*)dynTicketData->parkingEnd, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8)); memcpy((char*)dynTicketData->parkingEnd, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8));
QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateTime.toString("yy.MM.dd")); QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateString);
memcpy((char*)dynTicketData->currentTime, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8)); memcpy((char*)dynTicketData->currentTime, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8));
// ! and yes... 'ParkingEndDate' is 'currentTime' // ! and yes... 'ParkingEndDate' is 'currentTime'
QByteArray ba_currentDate = codec->fromUnicode(currentDateTime.toString("yy.MM.dd")); QByteArray ba_currentDate = codec->fromUnicode(currentDateString);
memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8)); memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8));
// STAN for Szeged Start/Stop: must be 9 digits // STAN for Szeged Start/Stop: must be 9 digits
@ -673,6 +677,9 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate); QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate);
QDateTime currentDateTime = QDateTime::fromString(printingData["currentDateTime"].toString(), Qt::ISODate); QDateTime currentDateTime = QDateTime::fromString(printingData["currentDateTime"].toString(), Qt::ISODate);
QString parkingEndDateString = QLocale().toString(parkingEndDateTime.date(), QLocale::ShortFormat);
QString currentDateString = QLocale().toString(currentDateTime.date(), QLocale::ShortFormat);
/* ----------------------------------------------------------------------------------------- /* -----------------------------------------------------------------------------------------
* note: the following highly depends on printer template files! * note: the following highly depends on printer template files!
* ----------------------------------------------------------------------------------------- * -----------------------------------------------------------------------------------------
@ -690,11 +697,11 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
QByteArray ba_parkingEndTime = codec->fromUnicode(parkingEndDateTime.toString("hh:mm")); QByteArray ba_parkingEndTime = codec->fromUnicode(parkingEndDateTime.toString("hh:mm"));
memcpy((char*)dynTicketData->parkingEnd, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8)); memcpy((char*)dynTicketData->parkingEnd, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8));
QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateTime.toString("yy.MM.dd")); QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateString);
memcpy((char*)dynTicketData->currentTime, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8)); memcpy((char*)dynTicketData->currentTime, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8));
// ! and yes... 'ParkingEndDate' is 'currentTime' // ! and yes... 'ParkingEndDate' is 'currentTime'
QByteArray ba_currentDate = codec->fromUnicode(currentDateTime.toString("yy.MM.dd")); QByteArray ba_currentDate = codec->fromUnicode(currentDateString);
memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8)); memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8));