aboutsummaryrefslogtreecommitdiffstats
path: root/core/metadata.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-05-22 18:53:25 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-05-22 12:31:06 -0700
commit8f80129bac29227a03c35940af9d197ef0fa6398 (patch)
tree40cd682efb11880af5410aab700dcd9d8bacbe72 /core/metadata.cpp
parente33e420ef3e5139015504ef49215721e99850f2b (diff)
downloadsubsurface-8f80129bac29227a03c35940af9d197ef0fa6398.tar.gz
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>
Diffstat (limited to 'core/metadata.cpp')
-rw-r--r--core/metadata.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/core/metadata.cpp b/core/metadata.cpp
index 8692ea30f..e7cc0a08b 100644
--- a/core/metadata.cpp
+++ b/core/metadata.cpp
@@ -271,7 +271,7 @@ static bool parseDate(const QString &s_in, timestamp_t &timestamp)
if (datetime.isValid()) {
// Not knowing any better, we suppose that time is give in UTC
datetime.setTimeSpec(Qt::UTC);
- timestamp = datetime.toMSecsSinceEpoch() / 1000;
+ timestamp = dateTimeToTimestamp(datetime);
return true;
}
@@ -312,7 +312,7 @@ static bool parseDate(const QString &s_in, timestamp_t &timestamp)
// Not knowing any better, we suppose that time is give in UTC
datetime = QDateTime(date, time, Qt::UTC);
if (datetime.isValid()) {
- timestamp = datetime.toMSecsSinceEpoch() / 1000;
+ timestamp = dateTimeToTimestamp(datetime);
return true;
}
@@ -542,9 +542,9 @@ extern "C" mediatype_t get_metadata(const char *filename_in, metadata *data)
// have a standard way of storing this datum), use the file creation date of the file.
if (data->timestamp == 0)
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
- data->timestamp = QFileInfo(filename).birthTime().toMSecsSinceEpoch() / 1000;
+ data->timestamp = dateTimeToTimestamp(QFileInfo(filename).birthTime());
#else
- data->timestamp = QFileInfo(filename).created().toMSecsSinceEpoch() / 1000;
+ data->timestamp = dateTimeToTimestamp(QFileInfo(filename).created());
#endif
return res;
}