diff --git a/ddsrecorder_participants/src/cpp/common/time_utils.cpp b/ddsrecorder_participants/src/cpp/common/time_utils.cpp index 3042a630..6a097027 100644 --- a/ddsrecorder_participants/src/cpp/common/time_utils.cpp +++ b/ddsrecorder_participants/src/cpp/common/time_utils.cpp @@ -52,10 +52,10 @@ 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 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()) @@ -63,7 +63,9 @@ utils::Timestamp to_std_timestamp( 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(time_point_aux); return time_point; }