From f66d2ab8edb94e371f5f129df99cc8eefc84f13d Mon Sep 17 00:00:00 2001 From: Alan Coleman <alanco@umich.edu> Date: Tue, 10 Sep 2024 22:28:57 +0000 Subject: [PATCH] Resolve "Summary file doesn't account for day roll over" --- corsika/detail/output/OutputManager.inl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/corsika/detail/output/OutputManager.inl b/corsika/detail/output/OutputManager.inl index cb4463351..28edfece0 100644 --- a/corsika/detail/output/OutputManager.inl +++ b/corsika/detail/output/OutputManager.inl @@ -133,13 +133,16 @@ namespace corsika { auto end_time{std::chrono::system_clock::now()}; - // now let's construct an estimate of the runtime - auto runtime{end_time - start_time}; + // calculate the number of days + auto const start_t = std::chrono::system_clock::to_time_t(start_time); + auto const end_t = std::chrono::system_clock::to_time_t(end_time); + int const durationDays = std::difftime(end_t, start_t) / (60 * 60 * 24); // add the time and duration info summary["start time"] = timeToString(start_time); summary["end time"] = timeToString(end_time); - summary["runtime"] = fmt::format("{:%H:%M:%S}", runtime); + summary["runtime"] = (durationDays ? fmt::format("+{}d ", durationDays) : "") + + fmt::format("{:%H:%M:%S}", end_time - start_time); return summary; } -- GitLab