fix: Wrong length check for logoff time from ATIS

This commit is contained in:
Lars Toenning
2024-01-25 23:03:23 +01:00
parent aa3347ae8b
commit c773f2f915

View File

@@ -737,13 +737,18 @@ namespace BlackCore
Q_ASSERT(CThreadUtils::isInThisThread(this));
if (!this->isConnectedAndNotShuttingDown()) { return; }
if (zuluTime.length() == 4)
if (zuluTime.length() == 5) // for example 2000z
{
// Logic to set logoff time
QStringView zuluTimeView(zuluTime);
// TODO Replace with Qt 6.0 QStringView::slice()
zuluTimeView.chop(1); // Remove z
bool ok;
const int h = zuluTime.leftRef(2).toInt(&ok);
const int h = zuluTimeView.left(2).toInt(&ok);
if (!ok) { return; }
const int m = zuluTime.rightRef(2).toInt(&ok);
const int m = zuluTimeView.right(2).toInt(&ok);
if (!ok) { return; }
QDateTime logoffDateTime = QDateTime::currentDateTimeUtc();
logoffDateTime.setTime(QTime(h, m));