mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
d668f5dc8e
commit
648f02c669
1 changed files with 5 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue