Show local date time in evidence viewer (#37)

main
Joel Smith 2020-08-17 16:16:21 -07:00 committed by GitHub
parent a0d772a27d
commit 6b567d91de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -69,6 +69,9 @@ model::Evidence DatabaseConnection::getEvidenceDetails(qint64 evidenceID) {
rtn.recordedDate = query.value("recorded_date").toDateTime();
rtn.uploadDate = query.value("upload_date").toDateTime();
rtn.recordedDate.setTimeSpec(Qt::UTC);
rtn.uploadDate.setTimeSpec(Qt::UTC);
auto getTagQuery = executeQuery(&db,
"SELECT"
" id, tag_id, name"
@ -153,8 +156,8 @@ void DatabaseConnection::setEvidenceTags(const std::vector<model::Tag> &newTags,
DBQuery DatabaseConnection::buildGetEvidenceWithFiltersQuery(const EvidenceFilters &filters) {
QString query =
"SELECT id, path, operation_slug, content_type, description, error, recorded_date, "
"upload_date"
"SELECT"
" id, path, operation_slug, content_type, description, error, recorded_date, upload_date"
" FROM evidence";
std::vector<QVariant> values;
std::vector<QString> parts;
@ -212,6 +215,9 @@ std::vector<model::Evidence> DatabaseConnection::getEvidenceWithFilters(
evi.recordedDate = resultSet.value("recorded_date").toDateTime();
evi.uploadDate = resultSet.value("upload_date").toDateTime();
evi.recordedDate.setTimeSpec(Qt::UTC);
evi.uploadDate.setTimeSpec(Qt::UTC);
allEvidence.push_back(evi);
}

View File

@ -332,12 +332,12 @@ EvidenceRow EvidenceManager::buildBaseEvidenceRow(qint64 evidenceID) {
}
void EvidenceManager::setRowText(int row, const model::Evidence& model) {
static QString dateFormat = "MMM dd, yyyy hh:mm";
static QString dateFormat = QLocale().dateTimeFormat(QLocale::ShortFormat);
auto setColText = [this, row](int col, QString text) {
evidenceTable->item(row, col)->setText(text);
};
setColText(COL_DATE_CAPTURED, model.recordedDate.toString(dateFormat));
setColText(COL_DATE_CAPTURED, model.recordedDate.toLocalTime().toString(dateFormat));
setColText(COL_DESCRIPTION, model.description);
setColText(COL_OPERATION, model.operationSlug);
setColText(COL_CONTENT_TYPE, model.contentType);
@ -346,7 +346,7 @@ void EvidenceManager::setRowText(int row, const model::Evidence& model) {
setColText(COL_PATH, model.path);
setColText(COL_ERROR_MSG, model.errorText);
auto uploadDateText = model.uploadDate.isNull() ? "Never" : model.uploadDate.toString(dateFormat);
auto uploadDateText = model.uploadDate.isNull() ? "Never" : model.uploadDate.toLocalTime().toString(dateFormat);
setColText(COL_DATE_SUBMITTED, uploadDateText);
}