From 2d709470440b2ca1911a6a4cee5016664937638e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 23 Apr 2025 21:00:07 -0400 Subject: [PATCH] two more workarounds for compilation with -DFMT_STATIC_THOUSANDS_SEPARATOR --- src/info.cpp | 10 ++++++++++ src/timer.cpp | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/src/info.cpp b/src/info.cpp index 160879577f..39ad7b2788 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -44,7 +44,9 @@ #include "region.h" #include "update.h" #include "variable.h" +#ifndef FMT_STATIC_THOUSANDS_SEPARATOR #include "fmt/chrono.h" +#endif #include #include @@ -270,8 +272,16 @@ void Info::command(int narg, char **arg) if (out == nullptr) return; fputs("\nInfo-Info-Info-Info-Info-Info-Info-Info-Info-Info-Info\n",out); +#if defined(FMT_STATIC_THOUSANDS_SEPARATOR) + { + time_t tv = time(nullptr); + struct tm *now = localtime(&tv); + utils::print(out, "Printed on {}", asctime(now)); + } +#else std::tm now = fmt::localtime(std::time(nullptr)); utils::print(out,"Printed on {}", std::asctime(&now)); +#endif if (flags & CONFIG) { utils::print(out,"\nLAMMPS version: {} / {}\n", lmp->version, lmp->num_ver); diff --git a/src/timer.cpp b/src/timer.cpp index dea008a3c9..219cad20b4 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -15,7 +15,9 @@ #include "comm.h" #include "error.h" +#ifndef FMT_STATIC_THOUSANDS_SEPARATOR #include "fmt/chrono.h" +#endif #include "tokenizer.h" #include @@ -264,8 +266,15 @@ void Timer::modify_params(int narg, char **arg) // format timeout setting std::string timeout = "off"; if (_timeout >= 0.0) { +#if defined(FMT_STATIC_THOUSANDS_SEPARATOR) + char outstr[200]; + struct tm *tv = gmtime(&((time_t) _timeout)); + strftime(outstr, 200, "%02d:%M:%S", tv) + timeout = outstr; +#else std::tm tv = fmt::gmtime((std::time_t) _timeout); timeout = fmt::format("{:02d}:{:%M:%S}", tv.tm_yday * 24 + tv.tm_hour, tv); +#endif } utils::logmesg(lmp, "New timer settings: style={} mode={} timeout={}\n", timer_style[_level],