Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions plotjuggler_plugins/DataLoadCSV/timestamp_parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,14 @@ ColumnTypeInfo DetectColumnType(const std::string& str)
return info;
}

// Check for hexadecimal with 0x prefix (case insensitive)
if (trimmed.size() > 2 &&
(trimmed[0] == '0' && (trimmed[1] == 'x' || trimmed[1] == 'X')))
{
info.type = ColumnType::HEX;
return info;
}

auto num_info = CheckNumeric(trimmed);
if (num_info.is_number)
{
Expand Down Expand Up @@ -431,6 +439,11 @@ std::optional<double> ParseWithType(const std::string& str, const ColumnTypeInfo
return std::stod(normalized);
}

case ColumnType::HEX: {
// Parse hex value with 0x prefix
return static_cast<double>(std::stoll(trimmed, nullptr, 16));
}

case ColumnType::EPOCH_SECONDS:
case ColumnType::EPOCH_MILLIS:
case ColumnType::EPOCH_MICROS:
Expand Down
1 change: 1 addition & 0 deletions plotjuggler_plugins/DataLoadCSV/timestamp_parsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ std::optional<double> FormatParseTimestamp(const std::string& str, const std::st
enum class ColumnType
{
NUMBER, // Plain numeric value
HEX, // Hexadecimal number with 0x prefix
EPOCH_SECONDS, // Numeric epoch timestamp in seconds
EPOCH_MILLIS, // Numeric epoch timestamp in milliseconds
EPOCH_MICROS, // Numeric epoch timestamp in microseconds
Expand Down
Loading