mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 02:35:33 +08:00
Improved details on the readers, regarding timestamp
This commit is contained in:
@@ -59,6 +59,24 @@ namespace BlackCore
|
||||
|
||||
if (doc.setContent(xmlData))
|
||||
{
|
||||
QDomNode timestamp = doc.elementsByTagName("timestamp").at(0);
|
||||
QString ts = timestamp.toElement().text().trimmed();
|
||||
Q_ASSERT(!ts.isEmpty());
|
||||
if (ts.isEmpty())
|
||||
{
|
||||
// fallback
|
||||
m_updateTimestamp = QDateTime::currentDateTimeUtc();
|
||||
}
|
||||
else
|
||||
{
|
||||
// normally the timestamp is always updated from backend
|
||||
// if this changes in the future we're prepared
|
||||
QDateTime fileTimestamp = QDateTime::fromString(ts, "yyyy-MM-dd HH:mm:ss");
|
||||
fileTimestamp.setTimeSpec(Qt::UTC);
|
||||
if (this->m_updateTimestamp == fileTimestamp) return; // nothing to do
|
||||
this->m_updateTimestamp = fileTimestamp;
|
||||
}
|
||||
|
||||
QDomNode atc = doc.elementsByTagName("atcs").at(0);
|
||||
QDomNodeList bookingNodes = atc.toElement().elementsByTagName("booking");
|
||||
int size = bookingNodes.size();
|
||||
@@ -93,11 +111,13 @@ namespace BlackCore
|
||||
else if (name == "time_end")
|
||||
{
|
||||
QDateTime t = QDateTime::fromString(value, "yyyy-MM-dd HH:mm:ss");
|
||||
t.setTimeSpec(Qt::UTC);
|
||||
bookedStation.setBookedUntilUtc(t);
|
||||
}
|
||||
else if (name == "time_start")
|
||||
{
|
||||
QDateTime t = QDateTime::fromString(value, "yyyy-MM-dd HH:mm:ss");
|
||||
t.setTimeSpec(Qt::UTC);
|
||||
bookedStation.setBookedFromUtc(t);
|
||||
}
|
||||
}
|
||||
@@ -108,7 +128,6 @@ namespace BlackCore
|
||||
bookedStation.setController(user);
|
||||
bookedStations.push_back(bookedStation);
|
||||
}
|
||||
m_updateTimestamp = QDateTime::currentDateTimeUtc();
|
||||
emit this->dataRead(bookedStations);
|
||||
|
||||
} // node
|
||||
|
||||
@@ -243,7 +243,10 @@ namespace BlackCore
|
||||
QString dts = updateParts.at(1).trimmed();
|
||||
QDateTime dt = QDateTime::fromString(dts, "yyyyMMddHHmmss");
|
||||
dt.setOffsetFromUtc(0);
|
||||
if (dt == this->m_updateTimestamp) return; // still same data, terminate
|
||||
if (dt == this->m_updateTimestamp)
|
||||
{
|
||||
return; // still same data, terminate
|
||||
}
|
||||
this->m_updateTimestamp = dt;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user