From 5dd8141de57f949013f729273c55d4e2b56fd3c6 Mon Sep 17 00:00:00 2001 From: aiekick Date: Mon, 10 Jun 2024 00:22:06 +0200 Subject: [PATCH] [FIX] : fix the dates functions --- src/cTools.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cTools.cpp b/src/cTools.cpp index d5d49bd..a143ff2 100644 --- a/src/cTools.cpp +++ b/src/cTools.cpp @@ -52,9 +52,9 @@ SOFTWARE. bool ct::iso8601ToEpoch(const std::string& vIsoDateTime, const std::string& vTimeFormat, std::time_t& vOutTime) { if (!vIsoDateTime.empty() && !vTimeFormat.empty()) { struct std::tm time = {}; - std::istringstream ss(vIsoDateTime); - ss >> std::get_time(&time, vTimeFormat.c_str()); - if (ss.good()) { + std::istringstream iss(vIsoDateTime); + iss >> std::get_time(&time, vTimeFormat.c_str()); + if (!iss.fail()) { time.tm_hour = 0; time.tm_min = 0; time.tm_sec = 0; @@ -75,7 +75,7 @@ bool ct::epochToISO8601(const std::time_t& vEpochTime, std::string& vOutTime) { auto* timeinfo = std::localtime(&tt); std::ostringstream oss; oss << std::put_time(timeinfo, "%Y-%m-%d"); - if (oss.good()) { + if (!oss.fail()) { vOutTime = oss.str(); return true; }