Skip to content

Commit 8029caa

Browse files
committed
Update version.h
1 parent 50bb76e commit 8029caa

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

common/include/common/version/version.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ inline const std::string& get_build_date() {
8181

8282
inline const std::string& get_build_time() {
8383
static std::string res = std::invoke([] {
84-
int hh = 0, mm = 0, ss = 0;
85-
std::sscanf(__TIME__, "%d:%d:%d", &hh, &mm, &ss);
84+
const std::string_view time = __TIME__;
85+
const int hh = 10 * (time[0] - '0') + (time[1] - '0');
86+
const int mm = 10 * (time[3] - '0') + (time[4] - '0');
8687
const std::string_view suffix = (hh < 12) ? "AM" : "PM";
8788
// Use a zero-indexed 12-hour clock for elegance.
8889
return std::format("{}:{:02} {}", hh % 12, mm, suffix);

0 commit comments

Comments
 (0)