From 648f02c669f5d69910f65518904a8967760a2003 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sat, 30 Nov 2013 03:35:15 -0400 Subject: Avoid using manual timezone offsets. Since some early bird thought it was a good idea to force the rest of us to get up early by changing our clocks during summer, we can not use the currentDateTime() to determine the timezone offset for all dives. Instead, we just pretend that everything is in UTC and avoid doing the offset calculations. If only that early bird knew that if clocks stayed consistent throughout the year then I could be asleep instead of fixing this in the middle of the night.. Signed-off-by: Michael Andreen Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index ca0aba926..15641cb9f 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -213,7 +213,7 @@ void MainTab::enableEdition(EditMode newEditMode) notesBackup[mydive].coordinates = ui.coordinates->text(); notesBackup[mydive].airtemp = get_temperature_string(mydive->airtemp, true); notesBackup[mydive].watertemp = get_temperature_string(mydive->watertemp, true); - notesBackup[mydive].datetime = QDateTime::fromTime_t(mydive->when - gettimezoneoffset()).toString(); + notesBackup[mydive].datetime = QDateTime::fromTime_t(mydive->when).toUTC().toString(); char buf[1024]; taglist_get_tagstring(mydive->tag_list, buf, 1024); notesBackup[mydive].tags = QString(buf); @@ -334,7 +334,7 @@ void MainTab::updateDiveInfo(int dive) UPDATE_TEMP(d, watertemp); if (d) { updateGpsCoordinates(d); - ui.dateTimeEdit->setDateTime(QDateTime::fromTime_t(d->when - gettimezoneoffset())); + ui.dateTimeEdit->setDateTime(QDateTime::fromTime_t(d->when).toUTC()); if (mainWindow() && mainWindow()->dive_list()->selectedTrips().count() == 1) { setTabText(0, tr("Trip Notes")); // only use trip relevant fields @@ -772,7 +772,9 @@ void MainTab::on_watertemp_textChanged(const QString& text) void MainTab::on_dateTimeEdit_dateTimeChanged(const QDateTime& datetime) { - EDIT_SELECTED_DIVES( mydive->when = datetime.toTime_t() + gettimezoneoffset() ); + QDateTime dateTimeUtc(datetime); + dateTimeUtc.setTimeSpec(Qt::UTC); + EDIT_SELECTED_DIVES( mydive->when = dateTimeUtc.toTime_t() ); markChangedWidget(ui.dateTimeEdit); } -- cgit v1.2.3-70-g09d2