From 547ecfb28f20958ea76bcd5ce12652b000852933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Sch=C3=BCmann?= Date: Sat, 4 May 2019 08:08:04 +0200 Subject: [PATCH] Test helper for file_time_type got additional error checking --- test/filesystem_test.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/filesystem_test.cpp b/test/filesystem_test.cpp index faaa905..a1b3f8b 100644 --- a/test/filesystem_test.cpp +++ b/test/filesystem_test.cpp @@ -117,9 +117,15 @@ struct StringMaker static std::string convert(fs::file_time_type const& value) { std::time_t t = to_time_t(value); - std::tm ttm = *std::localtime(&t); - std::ostringstream os; - os << std::put_time(&ttm, "%Y-%m-%d %H:%M:%S"); + std::tm* ptm = std::localtime(&t); + if (ptm) { + std::tm ttm = *ptm; + std::ostringstream os; + os << std::put_time(&ttm, "%Y-%m-%d %H:%M:%S"); + } + else { + os << "(invalid-time)"; + } return os.str(); } };