Skip to content

Commit

Permalink
Fix windows no right-hand operand
Browse files Browse the repository at this point in the history
Signed-off-by: Eugenio Collado <[email protected]>
  • Loading branch information
EugenioCollado committed Dec 31, 2024
1 parent 85807da commit c1ec0ab
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ddsrecorder_participants/src/cpp/common/time_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,20 @@ utils::Timestamp to_std_timestamp(
throw std::runtime_error("No dot found in the timestamp");
}

auto time_point = utils::string_to_timestamp(time.substr(0, dot_pos), SQL_TIMESTAMP_FORMAT);
std::chrono::time_point<std::chrono::system_clock> time_point = utils::string_to_timestamp(time.substr(0, dot_pos), SQL_TIMESTAMP_FORMAT);

const auto decimals = time.substr(dot_pos + 1);
std::uint32_t nanoseconds;
std::uint64_t nanoseconds;
std::istringstream(decimals) >> nanoseconds;

if (decimals.empty() || std::istringstream(decimals).fail())
{
throw std::runtime_error("Failed to parse fractional part as an integer");
}

time_point += std::chrono::nanoseconds(nanoseconds);
// Add the nanoseconds to the time_point
auto time_point_aux = time_point + std::chrono::nanoseconds(nanoseconds);
time_point = static_cast<utils::Timestamp>(time_point_aux);

return time_point;
}
Expand Down

0 comments on commit c1ec0ab

Please sign in to comment.