Ref T308, using an optimized (faster) function for YYYYmmdd string parsing

Ref T309, found that QDateTime::fromString returns a QDateTime object with local timestamp. Using a optimized version returns UTC objects now.

- The bug was found writing a unit test for Ref T308
- Slack: https://swift-project.slack.com/archives/G7GD2UP9C/p1534848725000100
This commit is contained in:
Klaus Basan
2018-08-21 15:19:16 +02:00
parent d3c3fe2566
commit 183280fa75
13 changed files with 167 additions and 61 deletions

View File

@@ -112,8 +112,7 @@ namespace BlackCore
{
// normally the timestamp is always updated from backend
// if this changes in the future we're prepared
updateTimestamp = QDateTime::fromString(ts, timestampFormat);
updateTimestamp.setTimeSpec(Qt::UTC);
updateTimestamp = fromStringUtc(ts, timestampFormat);
if (this->getUpdateTimestamp() == updateTimestamp) return; // nothing to do
// save parsing and all follow up actions if nothing changed
@@ -166,14 +165,12 @@ namespace BlackCore
}
else if (name == "time_end")
{
QDateTime t = QDateTime::fromString(value, timestampFormat);
t.setTimeSpec(Qt::UTC);
QDateTime t = fromStringUtc(value, timestampFormat);
bookedStation.setBookedUntilUtc(t);
}
else if (name == "time_start")
{
QDateTime t = QDateTime::fromString(value, timestampFormat);
t.setTimeSpec(Qt::UTC);
QDateTime t = fromStringUtc(value, timestampFormat);
bookedStation.setBookedFromUtc(t);
}
}