mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-22 22:13:35 +02:00
34 lines
680 B
C++
34 lines
680 B
C++
/*
|
|
* DateUtils.cpp, part of VCMI engine
|
|
*
|
|
* Authors: listed in file AUTHORS in main folder
|
|
*
|
|
* License: GNU General Public License v2.0 or later
|
|
* Full text of license available in license.txt file, in main folder
|
|
*
|
|
*/
|
|
#include "StdInc.h"
|
|
#include <vstd/DateUtils.h>
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
namespace vstd
|
|
{
|
|
|
|
DLL_LINKAGE std::string getFormattedDateTime(std::time_t dt, std::string format)
|
|
{
|
|
std::tm tm = *std::localtime(&dt);
|
|
std::stringstream s;
|
|
s << std::put_time(&tm, format.c_str());
|
|
return s.str();
|
|
}
|
|
|
|
DLL_LINKAGE std::string getDateTimeISO8601Basic(std::time_t dt)
|
|
{
|
|
return getFormattedDateTime(dt, "%Y%m%dT%H%M%S");
|
|
}
|
|
|
|
}
|
|
|
|
VCMI_LIB_NAMESPACE_END
|