From 7b1efe3b7be5e9faaa8e88672dfe0ffc50b05ad4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 14 Mar 2026 13:06:59 +0000 Subject: [PATCH 1/2] Initial plan From c6339d7ad931ba937e260a5a141f37a8f5ce234a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 14 Mar 2026 13:20:01 +0000 Subject: [PATCH 2/2] Fix macOS build: replace zoned_time with portable localtime_r/strftime Co-authored-by: gfauredev <19304085+gfauredev@users.noreply.github.com> --- include/Logger.hpp | 23 ++++++++++++++++------- test/LoggerTest.cpp | 10 +++++++--- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/Logger.hpp b/include/Logger.hpp index 4a7ed5d..10f0cca 100644 --- a/include/Logger.hpp +++ b/include/Logger.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -20,12 +21,16 @@ class Logger { private: /** * @brief Retourne heure formatée - * @return Horodatage "HH:MM:SS.mmm" + * @return Horodatage "HH:MM:SS" */ static std::string time() { - return std::format( - "{:%T}", std::chrono::zoned_time{std::chrono::current_zone(), - std::chrono::system_clock::now()}); + auto now = std::chrono::system_clock::now(); + std::time_t t = std::chrono::system_clock::to_time_t(now); + std::tm local_tm{}; + localtime_r(&t, &local_tm); + char buf[9]; + std::strftime(buf, sizeof(buf), "%T", &local_tm); + return std::string(buf); } /** @@ -33,9 +38,13 @@ class Logger { * @return Horodatage "YYYY-MM-DD" */ static std::string date() { - return std::format( - "{:%F}", std::chrono::zoned_time{std::chrono::current_zone(), - std::chrono::system_clock::now()}); + auto now = std::chrono::system_clock::now(); + std::time_t t = std::chrono::system_clock::to_time_t(now); + std::tm local_tm{}; + localtime_r(&t, &local_tm); + char buf[11]; + std::strftime(buf, sizeof(buf), "%F", &local_tm); + return std::string(buf); } /** diff --git a/test/LoggerTest.cpp b/test/LoggerTest.cpp index 6773e45..decadca 100644 --- a/test/LoggerTest.cpp +++ b/test/LoggerTest.cpp @@ -89,9 +89,13 @@ TEST_CASE("Logger functionality") { // Vérifier si fichier a été archivé avec date // La logique de rotation: rename(filePath, date() + filePath) // Il faut obtenir la chaîne de date - auto now = std::chrono::zoned_time{std::chrono::current_zone(), - std::chrono::system_clock::now()}; - std::string dateStr = std::format("{:%F}", now); + auto now = std::chrono::system_clock::now(); + std::time_t t = std::chrono::system_clock::to_time_t(now); + std::tm local_tm{}; + localtime_r(&t, &local_tm); + char dateBuf[11]; + std::strftime(dateBuf, sizeof(dateBuf), "%F", &local_tm); + std::string dateStr = dateBuf; std::string rotatedFile = dateStr + basicLog; CHECK(std::filesystem::exists(rotatedFile));