mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-06-04 11:13:58 +08:00
Test helper for file_time_type got additional error checking
This commit is contained in:
parent
43e75c3869
commit
547ecfb28f
@ -117,9 +117,15 @@ struct StringMaker<fs::file_time_type>
|
|||||||
static std::string convert(fs::file_time_type const& value)
|
static std::string convert(fs::file_time_type const& value)
|
||||||
{
|
{
|
||||||
std::time_t t = to_time_t(value);
|
std::time_t t = to_time_t(value);
|
||||||
std::tm ttm = *std::localtime(&t);
|
std::tm* ptm = std::localtime(&t);
|
||||||
|
if (ptm) {
|
||||||
|
std::tm ttm = *ptm;
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << std::put_time(&ttm, "%Y-%m-%d %H:%M:%S");
|
os << std::put_time(&ttm, "%Y-%m-%d %H:%M:%S");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
os << "(invalid-time)";
|
||||||
|
}
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user