1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-02 09:02:03 +02:00
vcmi/lib/vstd/DateUtils.cpp
2023-08-23 22:46:28 +03:00

28 lines
445 B
C++

#include "StdInc.h"
#include <vstd/DateUtils.h>
VCMI_LIB_NAMESPACE_BEGIN
namespace vstd
{
DLL_LINKAGE std::string getFormattedDateTime(std::time_t dt)
{
std::tm tm = *std::localtime(&dt);
std::stringstream s;
try
{
s.imbue(std::locale(""));
}
catch(const std::runtime_error & e)
{
// locale not be available - keep default / global
}
s << std::put_time(&tm, "%x %X");
return s.str();
}
}
VCMI_LIB_NAMESPACE_END