QML UI: only store the new date/time if they are valid

Otherwise we are overwriting valid data with midnight, Jan 1, 1970.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-01-10 22:07:58 -08:00
parent 56b3ecb3f6
commit 0d9892645c

View file

@ -360,7 +360,8 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
date.replace(drop, "");
}
newDate = QDateTime::fromString(date, format);
d->when = newDate.toMSecsSinceEpoch() / 1000 + gettimezoneoffset(newDate.toMSecsSinceEpoch() / 1000);
if (newDate.isValid())
d->dc.when = d->when = newDate.toMSecsSinceEpoch() / 1000 + gettimezoneoffset(newDate.toMSecsSinceEpoch() / 1000);
}
struct dive_site *ds = get_dive_site_by_uuid(d->dive_site_uuid);
char *locationtext = NULL;