mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 17:55:45 +08:00
Improved details on the readers, regarding timestamp
This commit is contained in:
@@ -59,6 +59,24 @@ namespace BlackCore
|
|||||||
|
|
||||||
if (doc.setContent(xmlData))
|
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);
|
QDomNode atc = doc.elementsByTagName("atcs").at(0);
|
||||||
QDomNodeList bookingNodes = atc.toElement().elementsByTagName("booking");
|
QDomNodeList bookingNodes = atc.toElement().elementsByTagName("booking");
|
||||||
int size = bookingNodes.size();
|
int size = bookingNodes.size();
|
||||||
@@ -93,11 +111,13 @@ namespace BlackCore
|
|||||||
else if (name == "time_end")
|
else if (name == "time_end")
|
||||||
{
|
{
|
||||||
QDateTime t = QDateTime::fromString(value, "yyyy-MM-dd HH:mm:ss");
|
QDateTime t = QDateTime::fromString(value, "yyyy-MM-dd HH:mm:ss");
|
||||||
|
t.setTimeSpec(Qt::UTC);
|
||||||
bookedStation.setBookedUntilUtc(t);
|
bookedStation.setBookedUntilUtc(t);
|
||||||
}
|
}
|
||||||
else if (name == "time_start")
|
else if (name == "time_start")
|
||||||
{
|
{
|
||||||
QDateTime t = QDateTime::fromString(value, "yyyy-MM-dd HH:mm:ss");
|
QDateTime t = QDateTime::fromString(value, "yyyy-MM-dd HH:mm:ss");
|
||||||
|
t.setTimeSpec(Qt::UTC);
|
||||||
bookedStation.setBookedFromUtc(t);
|
bookedStation.setBookedFromUtc(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +128,6 @@ namespace BlackCore
|
|||||||
bookedStation.setController(user);
|
bookedStation.setController(user);
|
||||||
bookedStations.push_back(bookedStation);
|
bookedStations.push_back(bookedStation);
|
||||||
}
|
}
|
||||||
m_updateTimestamp = QDateTime::currentDateTimeUtc();
|
|
||||||
emit this->dataRead(bookedStations);
|
emit this->dataRead(bookedStations);
|
||||||
|
|
||||||
} // node
|
} // node
|
||||||
|
|||||||
@@ -243,7 +243,10 @@ namespace BlackCore
|
|||||||
QString dts = updateParts.at(1).trimmed();
|
QString dts = updateParts.at(1).trimmed();
|
||||||
QDateTime dt = QDateTime::fromString(dts, "yyyyMMddHHmmss");
|
QDateTime dt = QDateTime::fromString(dts, "yyyyMMddHHmmss");
|
||||||
dt.setOffsetFromUtc(0);
|
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;
|
this->m_updateTimestamp = dt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user