From 03b2b854bf557ed8ca18b20065ee01cb5e1a424f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 15 Apr 2017 18:51:03 -0700 Subject: [PATCH] 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 --- mobile-widgets/qmlmanager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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+");