summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/gpslocation.cpp17
-rw-r--r--desktop-widgets/simplewidgets.cpp8
-rw-r--r--mobile-widgets/qmlmanager.cpp3
-rw-r--r--qt-models/diveplannermodel.cpp3
4 files changed, 16 insertions, 15 deletions
diff --git a/core/gpslocation.cpp b/core/gpslocation.cpp
index 2a097588a..d3f91ebaf 100644
--- a/core/gpslocation.cpp
+++ b/core/gpslocation.cpp
@@ -475,9 +475,8 @@ void GpsLocation::deleteFixesFromServer()
QList<qint64> keys = m_trackers.keys();
while (!m_deletedTrackers.isEmpty()) {
gpsTracker gt = m_deletedTrackers.takeFirst();
- QDateTime dt;
+ QDateTime dt = QDateTime::fromTime_t(gt.when, Qt::UTC);
QUrlQuery data;
- dt.setTime_t(gt.when - gettimezoneoffset(gt.when));
data.addQueryItem("login", prefs.userid);
data.addQueryItem("dive_date", dt.toString("yyyy-MM-dd"));
data.addQueryItem("dive_time", dt.toString("hh:mm"));
@@ -521,9 +520,8 @@ void GpsLocation::uploadToServer()
QUrl url(GPS_FIX_ADD_URL);
Q_FOREACH(qint64 key, m_trackers.keys()) {
struct gpsTracker gt = m_trackers.value(key);
- QDateTime dt;
+ QDateTime dt = QDateTime::fromTime_t(gt.when, Qt::UTC);
QUrlQuery data;
- dt.setTime_t(gt.when - gettimezoneoffset(gt.when));
data.addQueryItem("login", prefs.userid);
data.addQueryItem("dive_date", dt.toString("yyyy-MM-dd"));
data.addQueryItem("dive_time", dt.toString("hh:mm"));
@@ -602,15 +600,18 @@ void GpsLocation::downloadFromServer()
qDebug() << downloadedFixes.count() << "GPS fixes downloaded";
for (int i = 0; i < downloadedFixes.count(); i++) {
QJsonObject fix = downloadedFixes[i].toObject();
- QString date = fix.value("date").toString();
- QString time = fix.value("time").toString();
+ QDate date = QDate::fromString(fix.value("date").toString(), "yyy-M-d");
+ QTime time = QTime::fromString(fix.value("time").toString(), "hh:m:s");
QString name = fix.value("name").toString();
QString latitude = fix.value("latitude").toString();
QString longitude = fix.value("longitude").toString();
- QDateTime timestamp = QDateTime::fromString(date + " " + time, "yyyy-M-d hh:m:s");
+ QDateTime timestamp;
+ timestamp.setTimeSpec(Qt::UTC);
+ timestamp.setDate(date);
+ timestamp.setTime(time);
struct gpsTracker gt;
- gt.when = timestamp.toMSecsSinceEpoch() / 1000 + gettimezoneoffset(timestamp.toMSecsSinceEpoch() / 1000);
+ gt.when = timestamp.toMSecsSinceEpoch() / 1000;
gt.latitude.udeg = latitude.toDouble() * 1000000;
gt.longitude.udeg = longitude.toDouble() * 1000000;
gt.name = name;
diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp
index cbf31cb98..add4c80de 100644
--- a/desktop-widgets/simplewidgets.cpp
+++ b/desktop-widgets/simplewidgets.cpp
@@ -292,7 +292,6 @@ void ShiftImageTimesDialog::buttonClicked(QAbstractButton *button)
void ShiftImageTimesDialog::syncCameraClicked()
{
QPixmap picture;
- QDateTime dcDateTime = QDateTime();
QStringList fileNames = QFileDialog::getOpenFileNames(this,
tr("Open image file"),
DiveListView::lastUsedImageDir(),
@@ -308,7 +307,7 @@ void ShiftImageTimesDialog::syncCameraClicked()
ui.DCImage->setScene(scene);
dcImageEpoch = picture_get_timestamp(fileNames.at(0).toUtf8().data());
- dcDateTime.setTime_t(dcImageEpoch - gettimezoneoffset(displayed_dive.when));
+ QDateTime dcDateTime = QDateTime::fromTime_t(dcImageEpoch, Qt::UTC);
ui.dcTime->setDateTime(dcDateTime);
connect(ui.dcTime, SIGNAL(dateTimeChanged(const QDateTime &)), this, SLOT(dcDateTimeChanged(const QDateTime &)));
}
@@ -365,11 +364,10 @@ void ShiftImageTimesDialog::setOffset(time_t offset)
void ShiftImageTimesDialog::updateInvalid()
{
timestamp_t timestamp;
- QDateTime time;
bool allValid = true;
ui.warningLabel->hide();
ui.invalidLabel->hide();
- time.setTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when));
+ QDateTime time = QDateTime::fromTime_t(displayed_dive.when, Qt::UTC);
ui.invalidLabel->setText("Dive:" + time.toString() + "\n");
Q_FOREACH (const QString &fileName, fileNames) {
@@ -378,7 +376,7 @@ void ShiftImageTimesDialog::updateInvalid()
// We've found invalid image
timestamp = picture_get_timestamp(fileName.toUtf8().data());
- time.setTime_t(timestamp + m_amount - gettimezoneoffset(displayed_dive.when));
+ time.setTime_t(timestamp + m_amount);
ui.invalidLabel->setText(ui.invalidLabel->text() + fileName + " " + time.toString() + "\n");
allValid = false;
}
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index eae4a4e8f..a8dd24948 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -578,6 +578,7 @@ bool QMLManager::checkDate(DiveObjectHelper *myDive, struct dive * d, QString da
QString oldDate = myDive->date() + " " + myDive->time();
if (date != oldDate) {
QDateTime newDate;
+ newDate.setTimeSpec(Qt::UTC);
// what a pain - Qt will not parse dates if the day of the week is incorrect
// so if the user changed the date but didn't update the day of the week (most likely behavior, actually),
// we need to make sure we don't try to parse that
@@ -668,7 +669,7 @@ parsed:
// add a hundred years.
if (newDate.addYears(100) < QDateTime::currentDateTime().addYears(1))
newDate = newDate.addYears(100);
- d->dc.when = d->when = newDate.toMSecsSinceEpoch() / 1000 + gettimezoneoffset(newDate.toMSecsSinceEpoch() / 1000);
+ d->dc.when = d->when = newDate.toMSecsSinceEpoch() / 1000;
return true;
}
qDebug() << "none of our parsing attempts worked for the date string";
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index 03cc90e06..425d8bc1a 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -353,6 +353,7 @@ DivePlannerPointsModel::DivePlannerPointsModel(QObject *parent) : QAbstractTable
tempGFLow(100)
{
memset(&diveplan, 0, sizeof(diveplan));
+ startTime.setTimeSpec(Qt::UTC);
}
DivePlannerPointsModel *DivePlannerPointsModel::instance()
@@ -540,7 +541,7 @@ void DivePlannerPointsModel::setStartDate(const QDate &date)
void DivePlannerPointsModel::setStartTime(const QTime &t)
{
startTime.setTime(t);
- diveplan.when = startTime.toTime_t();
+ diveplan.when = startTime.toTime_t();
displayed_dive.when = diveplan.when;
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}