mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Ref T308, if QDateTime is invalid (normal state) setting a offset turns it into a valid timestamp of 1970 (which is wrong)
This commit is contained in:
@@ -261,15 +261,19 @@ namespace BlackMisc
|
||||
|
||||
QDateTime fromStringUtc(const QString &dateTimeString, const QString &format)
|
||||
{
|
||||
if (dateTimeString.isEmpty() || format.isEmpty()) { return QDateTime(); }
|
||||
QDateTime dt = QDateTime::fromString(dateTimeString, format);
|
||||
dt.setUtcOffset(0);
|
||||
if (!dt.isValid()) { return dt; }
|
||||
dt.setUtcOffset(0); // must only be applied to valid timestamps
|
||||
return dt;
|
||||
}
|
||||
|
||||
QDateTime fromStringUtc(const QString &dateTimeString, Qt::DateFormat format)
|
||||
{
|
||||
if (dateTimeString.isEmpty()) { return QDateTime(); }
|
||||
QDateTime dt = QDateTime::fromString(dateTimeString, format);
|
||||
dt.setUtcOffset(0);
|
||||
if (!dt.isValid()) { return dt; }
|
||||
dt.setUtcOffset(0); // must only be applied to valid timestamps
|
||||
return dt;
|
||||
}
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace BlackMiscTest
|
||||
{
|
||||
CSimulatedAircraftList aircraft({ CSimulatedAircraft("BAW001", {}, {}) });
|
||||
CAtcStationList atcStations({ CAtcStation("EGLL_TWR") });
|
||||
CVariantMap testData
|
||||
const CVariantMap testData
|
||||
{
|
||||
{ "namespace1/value1", CVariant::from(1) },
|
||||
{ "namespace1/value2", CVariant::from(2) },
|
||||
@@ -260,7 +260,8 @@ namespace BlackMiscTest
|
||||
CValueCache cache2(1);
|
||||
status = cache2.loadFromFiles(dir.absolutePath());
|
||||
QVERIFY(status.isSuccess());
|
||||
QCOMPARE(cache2.getAllValues(), testData);
|
||||
const CVariantMap test2Values = cache2.getAllValues();
|
||||
QCOMPARE(test2Values, testData);
|
||||
}
|
||||
|
||||
//! Is value between 0 - 100?
|
||||
|
||||
Reference in New Issue
Block a user