Skip to content

Commit

Permalink
cli: Signed durations
Browse files Browse the repository at this point in the history
  • Loading branch information
gavv committed May 1, 2024
1 parent 6a34084 commit ef4c545
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tool/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ std::string supported_duration_suffixes()
return "\"ns\", \"us\", \"ms\", \"s\", \"m\", \"h\"";
}

bool parse_duration(const char* name, const std::string& in, uint64_t& result)
bool parse_duration(const char* name, const std::string& in, int64_t& result)
{
uint64_t multiplier = 0;

Expand Down Expand Up @@ -105,20 +105,20 @@ bool parse_duration(const char* name, const std::string& in, uint64_t& result)
return false;
}

result = (uint64_t)number * multiplier;
result = (int64_t)number * multiplier;
return true;
}

bool parse_duration(const char* name,
const std::string& in,
google::protobuf::Duration& out)
{
uint64_t nanoseconds = 0;
int64_t nanoseconds = 0;
if (!parse_duration(name, in, nanoseconds)) {
return false;
}

out = google::protobuf::util::TimeUtil::NanosecondsToDuration((int64_t)nanoseconds);
out = google::protobuf::util::TimeUtil::NanosecondsToDuration(nanoseconds);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion tool/parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bool parse_index(const std::string& in, uint32_t& out);

std::string supported_duration_suffixes();

bool parse_duration(const char* name, const std::string& in, uint64_t& out);
bool parse_duration(const char* name, const std::string& in, int64_t& out);

bool parse_duration(const char* name,
const std::string& in,
Expand Down

0 comments on commit ef4c545

Please sign in to comment.