mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 23:53:23 +00:00
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 <dirk@hohndel.org>
This commit is contained in:
parent
bebcbfe92a
commit
b3e662a895
3 changed files with 9 additions and 5 deletions
|
@ -27,7 +27,7 @@ void set_default_dive_computer(const char *vendor, const char *product);
|
||||||
void set_default_dive_computer_device(const char *name);
|
void set_default_dive_computer_device(const char *name);
|
||||||
QString getSubsurfaceDataPath(QString folderToFind);
|
QString getSubsurfaceDataPath(QString folderToFind);
|
||||||
extern const QString get_dc_nickname(const char *model, uint32_t deviceid);
|
extern const QString get_dc_nickname(const char *model, uint32_t deviceid);
|
||||||
int gettimezoneoffset();
|
int gettimezoneoffset(time_t when = 0);
|
||||||
int parseTemperatureToMkelvin(const QString &text);
|
int parseTemperatureToMkelvin(const QString &text);
|
||||||
QString get_dive_date_string(timestamp_t when);
|
QString get_dive_date_string(timestamp_t when);
|
||||||
QString get_short_dive_date_string(timestamp_t when);
|
QString get_short_dive_date_string(timestamp_t when);
|
||||||
|
|
10
qt-gui.cpp
10
qt-gui.cpp
|
@ -372,10 +372,14 @@ QString getSubsurfaceDataPath(QString folderToFind)
|
||||||
return QString("");
|
return QString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
int gettimezoneoffset()
|
int gettimezoneoffset(time_t when)
|
||||||
{
|
{
|
||||||
QDateTime dt1 = QDateTime::currentDateTime();
|
QDateTime dt1, dt2;
|
||||||
QDateTime dt2 = dt1.toUTC();
|
if (when == 0)
|
||||||
|
dt1 = QDateTime::currentDateTime();
|
||||||
|
else
|
||||||
|
dt1 = QDateTime::fromMSecsSinceEpoch(when * 1000);
|
||||||
|
dt2 = dt1.toUTC();
|
||||||
dt1.setTimeSpec(Qt::UTC);
|
dt1.setTimeSpec(Qt::UTC);
|
||||||
return dt2.secsTo(dt1);
|
return dt2.secsTo(dt1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -380,7 +380,7 @@ void MainTab::updateDiveInfo(bool clear)
|
||||||
|
|
||||||
if (!clear) {
|
if (!clear) {
|
||||||
updateGpsCoordinates(&displayed_dive);
|
updateGpsCoordinates(&displayed_dive);
|
||||||
QDateTime localTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset());
|
QDateTime localTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when));
|
||||||
ui.dateEdit->setDate(localTime.date());
|
ui.dateEdit->setDate(localTime.date());
|
||||||
ui.timeEdit->setTime(localTime.time());
|
ui.timeEdit->setTime(localTime.time());
|
||||||
if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() == 1) {
|
if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() == 1) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue