From b3896f260048551d1d08245f85038182cb5e303b Mon Sep 17 00:00:00 2001 From: evgfilim1 Date: Fri, 3 Dec 2021 20:53:42 +0500 Subject: [PATCH] Add simple detection of timestamp resolution Set access time equal to modification time --- src/gui/csvImport/CsvImportWidget.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/gui/csvImport/CsvImportWidget.cpp b/src/gui/csvImport/CsvImportWidget.cpp index 61319eea1..a3a30e4c3 100644 --- a/src/gui/csvImport/CsvImportWidget.cpp +++ b/src/gui/csvImport/CsvImportWidget.cpp @@ -225,18 +225,29 @@ void CsvImportWidget::writeDatabase() if (m_parserModel->data(m_parserModel->index(r, 8)).isValid()) { auto datetime = m_parserModel->data(m_parserModel->index(r, 8)).toString(); if (datetime.contains(QRegularExpression("^\\d+$"))) { - timeInfo.setLastModificationTime(Clock::datetimeUtc(datetime.toLongLong() * 1000)); + auto t = datetime.toLongLong(); + if (t <= INT32_MAX) { + t *= 1000; + } + auto lastModified = Clock::datetimeUtc(t); + timeInfo.setLastModificationTime(lastModified); + timeInfo.setLastAccessTime(lastModified); } else { auto lastModified = QDateTime::fromString(datetime, Qt::ISODate); if (lastModified.isValid()) { timeInfo.setLastModificationTime(lastModified); + timeInfo.setLastAccessTime(lastModified); } } } if (m_parserModel->data(m_parserModel->index(r, 9)).isValid()) { auto datetime = m_parserModel->data(m_parserModel->index(r, 9)).toString(); if (datetime.contains(QRegularExpression("^\\d+$"))) { - timeInfo.setCreationTime(Clock::datetimeUtc(datetime.toLongLong() * 1000)); + auto t = datetime.toLongLong(); + if (t <= INT32_MAX) { + t *= 1000; + } + timeInfo.setCreationTime(Clock::datetimeUtc(t)); } else { auto created = QDateTime::fromString(datetime, Qt::ISODate); if (created.isValid()) {