1
0
Fork 0

Move currentDateTime suffix to isoDateTime in StringUtil.h

development
Duncan Ogilvie 2023-08-01 13:47:23 +02:00
parent dd76320156
commit ea631d4539
4 changed files with 18 additions and 10 deletions

View File

@ -479,7 +479,7 @@ void LogView::saveToFileSlot(QString fileName)
void LogView::saveSlot()
{
QString fileName;
fileName = QString("log-%1.txt").arg(QDateTime::currentDateTime().toString().replace(QChar(':'), QChar('-')));
fileName = QString("log-%1.txt").arg(isoDateTime());
saveToFileSlot(fileName);
}

View File

@ -374,15 +374,7 @@ QString getDbPath(const QString & filename, bool addDateTimeSuffix)
{
extensionIdx = path.length();
}
auto now = QDateTime::currentDateTime();
auto suffix = QString().sprintf("-%04d%02d%02d-%02d%02d%02d",
now.date().year(),
now.date().month(),
now.date().day(),
now.time().hour(),
now.time().minute(),
now.time().second()
);
auto suffix = "-" + isoDateTime();
path.insert(extensionIdx, suffix);
}
}

View File

@ -219,6 +219,19 @@ QString GetDataTypeString(const void* buffer, duint size, ENCODETYPE type)
}
}
QString isoDateTime()
{
auto now = QDateTime::currentDateTime();
return QString().sprintf("%04d%02d%02d-%02d%02d%02d",
now.date().year(),
now.date().month(),
now.date().day(),
now.time().hour(),
now.time().minute(),
now.time().second()
);
}
QString ToDateString(const QDate & date)
{
static const char* months[] =

View File

@ -104,6 +104,9 @@ inline QString ToDoubleString(const void* buffer, int precision = std::numeric_l
QString ToLongDoubleString(const void* buffer);
// yyyyMMdd-HHmmss (useful for file suffix)
QString isoDateTime();
QString ToDateString(const QDate & date);
QString fillValue(const char* value, int valsize = 2, bool bFpuRegistersLittleEndian = false);