cleanup: create common QDateTime -> timestamp conversion function

In analogy to the timestamp -> QDateTime conversion, create a
common function.
1) For symmetry with the opposite conversion.
2) To remove numerous inconsistencies.
3) To remove use of the deprecated QDateTime::toTime_t() function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-05-22 18:53:25 +02:00 committed by Dirk Hohndel
parent e33e420ef3
commit 8f80129bac
9 changed files with 19 additions and 13 deletions

View file

@ -279,7 +279,7 @@ void ShiftImageTimesDialog::dcDateTimeChanged(const QDateTime &newDateTime)
if (!dcImageEpoch)
return;
newtime.setTimeSpec(Qt::UTC);
setOffset(newtime.toTime_t() - dcImageEpoch);
setOffset(dateTimeToTimestamp(newtime) - dcImageEpoch);
}
void ShiftImageTimesDialog::matchAllImagesToggled(bool state)

View file

@ -598,7 +598,7 @@ void MainTab::on_depth_editingFinished()
// all dives are shifted by an offset.
static void shiftTime(QDateTime &dateTime)
{
timestamp_t when = dateTime.toTime_t();
timestamp_t when = dateTimeToTimestamp(dateTime);
if (current_dive && current_dive->when != when) {
timestamp_t offset = when - current_dive->when;
Command::shiftTime(getDiveSelection(), (int)offset);