Improved details on the readers, regarding timestamp

This commit is contained in:
Klaus Basan
2014-06-17 20:05:27 +02:00
parent 0547b2847e
commit a867a490e6
2 changed files with 24 additions and 2 deletions

View File

@@ -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

View File

@@ -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;
}
}