You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Support the case where the timestamp is in nanoseconds / microseconds
int64_t ts = str.toLong(&is_number);
const int64_t first_ts = 1400000000; // July 14, 2017
const int64_t last_ts = 2000000000; // May 18, 2033
if (is_number)
{
// check if it is an absolute time in nanoseconds.
// convert to seconds if it is
if (ts > first_ts * 1e9 && ts < last_ts * 1e9)
{
val = double(ts) * 1e-9;
}
else if (ts > first_ts * 1e6 && ts < last_ts * 1e6)
{
// check if it is an absolute time in microseconds.
// convert to seconds if it is
val = double(ts) * 1e-6;
}
else
{
val = double(ts);
}
}
else
{
// Try a double value (seconds)
val = str.toDouble(&is_number);
}
// handle numbers with comma instead of point as decimal separator
if (!is_number)
{
static QLocale locale_with_comma(QLocale::German);
val = locale_with_comma.toDouble(str, &is_number);
}
if (!is_number)
{
QDateTime ts = QDateTime::fromString(str, Qt::ISODateWithMs);
if (ts.isValid())
{
return double(ts.toMSecsSinceEpoch()) / 1000.0;
}
else
{
return std::nullopt;
}
}
return is_number ? std::optional(val) : std::nullopt;
};
I have tried out various timestamp formats and using the parser aswell but the only thing that seems to worked for me to get the data with timestamp on the x axis is using an epoch rather than a timestamp
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Error reading file | Couldn't parse timestamp
Parsing format: [None]
Time at line 1 : [2025-04-17T17:00:08]
I found that I am getting this error on the auto timestamp parsing.
#include
#include
#include
#include
#include
#include
std::optional AutoParseTimestamp(const QString& str)
{
bool is_number = false;
QString str_trimmed = str.trimmed();
double val = 0.0;
// Support the case where the timestamp is in nanoseconds / microseconds
int64_t ts = str.toLong(&is_number);
const int64_t first_ts = 1400000000; // July 14, 2017
const int64_t last_ts = 2000000000; // May 18, 2033
if (is_number)
{
// check if it is an absolute time in nanoseconds.
// convert to seconds if it is
if (ts > first_ts * 1e9 && ts < last_ts * 1e9)
{
val = double(ts) * 1e-9;
}
else if (ts > first_ts * 1e6 && ts < last_ts * 1e6)
{
// check if it is an absolute time in microseconds.
// convert to seconds if it is
val = double(ts) * 1e-6;
}
else
{
val = double(ts);
}
}
else
{
// Try a double value (seconds)
val = str.toDouble(&is_number);
}
// handle numbers with comma instead of point as decimal separator
if (!is_number)
{
static QLocale locale_with_comma(QLocale::German);
val = locale_with_comma.toDouble(str, &is_number);
}
if (!is_number)
{
QDateTime ts = QDateTime::fromString(str, Qt::ISODateWithMs);
if (ts.isValid())
{
return double(ts.toMSecsSinceEpoch()) / 1000.0;
}
else
{
return std::nullopt;
}
}
return is_number ? std::optional(val) : std::nullopt;
};
int main(int argc, char *argv[])
{
QStringList testStrings = {
"2025-04-17T17:00:08"
};
}
I created this file to test the function that PlotJuggler uses itself and it works properly.
g++ tzparse.cpp -o timestamp_parser -lQt6Core -I/usr/include/x86_64-linux-gnu/qt6 -I/usr/include/x86_64-linux-gnu/qt6/QtCore -fPIC && ./timestamp_parser
Input: [2025-04-19T22:07:29.568] -> Parsed (seconds): 1745125649.568000078
I have tried out various timestamp formats and using the parser aswell but the only thing that seems to worked for me to get the data with timestamp on the x axis is using an epoch rather than a timestamp
The text was updated successfully, but these errors were encountered: