diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-04-15 18:51:03 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-04-16 07:43:48 -0700 |
commit | 03b2b854bf557ed8ca18b20065ee01cb5e1a424f (patch) | |
tree | bd286410352811682a6307eef7f1b19d876a7e05 /mobile-widgets | |
parent | f2d88619c58b748f0db20fdd2887d276ef79b0c1 (diff) | |
download | subsurface-03b2b854bf557ed8ca18b20065ee01cb5e1a424f.tar.gz |
QML UI: correctly parse manually edited date
We need to set the timeSpec after the QDateTime was parsed,
otherwise it gets converted to localtime again.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets')
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index ea90660c5..d53e5357a 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -589,7 +589,6 @@ bool QMLManager::checkDate(DiveObjectHelper *myDive, struct dive * d, QString da QString oldDate = myDive->date() + " " + myDive->time(); if (date != oldDate) { QDateTime newDate; - newDate.setTimeSpec(Qt::UTC); // what a pain - Qt will not parse dates if the day of the week is incorrect // so if the user changed the date but didn't update the day of the week (most likely behavior, actually), // we need to make sure we don't try to parse that @@ -603,7 +602,9 @@ bool QMLManager::checkDate(DiveObjectHelper *myDive, struct dive * d, QString da format.replace(dateFormatToDrop, ""); date.replace(drop, ""); } + // set date from string and make sure it's treated as UTC (like all our time stamps) newDate = QDateTime::fromString(date, format); + newDate.setTimeSpec(Qt::UTC); if (!newDate.isValid()) { qDebug() << "unable to parse date" << date << "with the given format" << format; QRegularExpression isoDate("\\d+-\\d+-\\d+[^\\d]+\\d+:\\d+"); |