From 985fe9cd318fd2a2cdc9df14c9bfe521f427a930 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Mon, 10 May 2021 19:09:44 -0400 Subject: [PATCH] Use fmt::gmtime in timer.cpp --- src/timer.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/timer.cpp b/src/timer.cpp index 79fb63e7b5..0258f4d044 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -15,6 +15,7 @@ #include "comm.h" #include "error.h" +#include "fmt/chrono.h" #include @@ -26,8 +27,6 @@ #include #endif -#include - using namespace LAMMPS_NS; @@ -286,15 +285,13 @@ void Timer::modify_params(int narg, char **arg) if (comm->me == 0) { // format timeout setting - char timebuf[32]; - if (_timeout < 0) strcpy(timebuf,"off"); - else { - time_t tv = _timeout; - struct tm *tm = gmtime(&tv); - strftime(timebuf,32,"%H:%M:%S",tm); + std::string timeout = "off"; + if (_timeout >= 0) { + std::time_t tv = _timeout; + timeout = fmt::format("{:%H:%M:%S}", fmt::gmtime(tv)); } utils::logmesg(lmp,"New timer settings: style={} mode={} timeout={}\n", - timer_style[_level],timer_mode[_sync],timebuf); + timer_style[_level],timer_mode[_sync],timeout); } }