refs #921, support both timestamp formats

* DB
* JSON object (backend side)
This commit is contained in:
Klaus Basan
2017-03-30 03:23:00 +02:00
committed by Mathew Sutcliffe
parent f85501c7bf
commit a4a3dd1504

View File

@@ -75,9 +75,12 @@ namespace BlackMisc
void IDatastoreObjectWithIntegerKey::setKeyAndTimestampFromDatabaseJson(const QJsonObject &json, const QString &prefix)
{
const int dbKey = json.value(prefix + "id").toInt(-1);
const QString timestampString(json.value(prefix + "lastupdated").toString());
const QDateTime ts(CDatastoreUtility::parseTimestamp(timestampString));
this->setDbKey(dbKey);
// we check 2 formats, the DB format and the backend object format
QString timestampString(json.value(prefix + "lastupdated").toString());
if (timestampString.isEmpty()) { timestampString = json.value(prefix + "tsLastUpdated").toString(); }
const QDateTime ts(CDatastoreUtility::parseTimestamp(timestampString));
this->setUtcTimestamp(ts);
}