Skip to content

Commit 9f953b0

Browse files
committed
Use ISO-8601 UTC timestamps for better portability of logged data
1 parent ebfa668 commit 9f953b0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/logger.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ bool Logger::beginLog(QString path, bool autoLogging, QString fileName, bool tru
4343
qDebug() << "File open";
4444

4545
if (autoLogging)
46-
openFile(path + "/" + QDateTime::currentDateTime().toString("dd.MM.yyyy_hh.mm.ss.zzz_") + "Log" + fileName.right(fileName.length() - fileName.lastIndexOf('.')), truncateFile);
46+
openFile(path + "/" + QDateTime::currentDateTimeUtc().toString("dd.MM.yyyy_hh.mm.ss.zzzZ_") + "Log" + fileName.right(fileName.length() - fileName.lastIndexOf('.')), truncateFile);
4747
else
4848
openFile(path + "/" + fileName, truncateFile);
4949

@@ -76,7 +76,7 @@ void Logger::writeLogTXTLine(QString lineToAppend, bool simplifyText)
7676
if (simplifyText)
7777
text = text.simplified();
7878

79-
text = QDateTime::currentDateTime().toString("hh:mm:ss:zzz ") + text;
79+
text = QDateTime::currentDateTimeUtc().toString("yyyy-MM-ddTHH:MM:ss.zzzZ ") + text;
8080

8181
if (logFile != nullptr)
8282
{
@@ -98,7 +98,7 @@ void Logger::writeLogTXTParsedData(QStringList labelList, QList<double> dataList
9898

9999
text = text.simplified();
100100

101-
text = QDateTime::currentDateTime().toString("hh:mm:ss:zzz ") + text;
101+
text = QDateTime::currentDateTimeUtc().toString("yyyy-MM-ddTHH:MM:ss.zzzZ ") + text;
102102

103103
if (logFile != nullptr)
104104
{
@@ -169,7 +169,7 @@ void Logger::writeLogCSV(QStringList labelList, QList<double> dataList, bool add
169169
if (index >= 0 && index < dataList.count())
170170
out << QString::number(dataList[index], 'f') + ',';
171171
else if (csvLabelsBuffer[i] == "time")
172-
out << QTime::currentTime().toString("hh:mm:ss:zzz") + ',';
172+
out << QDateTime::currentDateTimeUtc().toString("yyyy-MM-ddTHH:MM:ss.zzzZ") + ',';
173173
}
174174

175175
out << "\n";

0 commit comments

Comments
 (0)