Skip to content

Commit

Permalink
solve clang-tidy issues in converter
Browse files Browse the repository at this point in the history
Signed-off-by: Timm Ruppert <[email protected]>
  • Loading branch information
TimmRuppert committed Nov 15, 2024
1 parent 608187a commit ea07e49
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions examples/convert_osi2mcap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ std::string ExtractTimestampFromFileName(const std::filesystem::path& file_path)
auto possible_timestamp = file_path.filename().string().substr(0, 16);

// Parse the timestamp using std::get_time
tm tm = {};
std::istringstream ss(possible_timestamp);
ss >> std::get_time(&tm, "%Y%m%dT%H%M%SZ");
tm tm_struct = {};
std::istringstream string_stream(possible_timestamp);
string_stream >> std::get_time(&tm_struct, "%Y%m%dT%H%M%SZ");
// Check if parsing was successful
if (ss.fail()) {
throw std::runtime_error(
"ERROR: Failed to parse timestamp.\n Only files following the recommended OSI .osi naming convention can be converted. Expected format: YYYYMMDDTHHMMSSZ");
if (string_stream.fail()) {
std::cerr << "ERROR: Failed to parse timestamp.\n Only files following the recommended OSI .osi naming convention can be converted. Expected format: YYYYMMDDTHHMMSSZ";
exit(1);
}

std::cout << "Assuming timestamp for required MCAP metadata 'zero_time' and 'timestamp' to be : " << possible_timestamp << std::endl;
Expand Down

0 comments on commit ea07e49

Please sign in to comment.