two more workarounds for compilation with -DFMT_STATIC_THOUSANDS_SEPARATOR

This commit is contained in:
Axel Kohlmeyer
2025-04-23 21:00:07 -04:00
parent 4126c9ed75
commit 2d70947044
2 changed files with 19 additions and 0 deletions

View File

@ -44,7 +44,9 @@
#include "region.h"
#include "update.h"
#include "variable.h"
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
#include "fmt/chrono.h"
#endif
#include <cctype>
#include <cmath>
@ -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);

View File

@ -15,7 +15,9 @@
#include "comm.h"
#include "error.h"
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
#include "fmt/chrono.h"
#endif
#include "tokenizer.h"
#include <cstring>
@ -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],