summaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Michael Andreen <harv@ruin.nu>2013-11-30 03:35:15 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-29 20:31:51 -0800
commit648f02c669f5d69910f65518904a8967760a2003 (patch)
tree5a7a1e183968d51bce74708d6ba11672c4784545 /qt-ui/maintab.cpp
parentd668f5dc8e0121d4000c7b2c340d7a0cd86efc49 (diff)
downloadsubsurface-648f02c669f5d69910f65518904a8967760a2003.tar.gz
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 <harv@ruin.nu> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r--qt-ui/maintab.cpp8
1 files 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);
}