From b3e662a895f6106846b236816ea13a458b95ab4a Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 16 Jul 2014 20:23:15 -0700 Subject: Pick the correct timezoneoffset for the day in question Calculating the timezoneoffset for the current date really makes no sense whatsoever when displaying a time that isn't "now". Fixes #605 Signed-off-by: Dirk Hohndel --- qt-gui.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'qt-gui.cpp') diff --git a/qt-gui.cpp b/qt-gui.cpp index 68f65e76a..0f5342921 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -372,10 +372,14 @@ QString getSubsurfaceDataPath(QString folderToFind) return QString(""); } -int gettimezoneoffset() +int gettimezoneoffset(time_t when) { - QDateTime dt1 = QDateTime::currentDateTime(); - QDateTime dt2 = dt1.toUTC(); + QDateTime dt1, dt2; + if (when == 0) + dt1 = QDateTime::currentDateTime(); + else + dt1 = QDateTime::fromMSecsSinceEpoch(when * 1000); + dt2 = dt1.toUTC(); dt1.setTimeSpec(Qt::UTC); return dt2.secsTo(dt1); } -- cgit v1.2.3-70-g09d2