Add simple detection of timestamp resolution

Set access time equal to modification time
This commit is contained in:
evgfilim1 2021-12-03 20:53:42 +05:00 committed by Jonathan White
parent d8c62f8eba
commit b3896f2600

View File

@ -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()) {