1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00
vcmi/lib/vstd/DateUtils.cpp

34 lines
680 B
C++
Raw Normal View History

2024-03-29 07:48:52 +02:00
/*
* 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
*
*/
2023-08-12 01:13:03 +02:00
#include "StdInc.h"
#include <vstd/DateUtils.h>
VCMI_LIB_NAMESPACE_BEGIN
namespace vstd
{
2023-12-16 15:27:18 +02:00
DLL_LINKAGE std::string getFormattedDateTime(std::time_t dt, std::string format)
2023-08-12 01:13:03 +02:00
{
std::tm tm = *std::localtime(&dt);
std::stringstream s;
2023-12-16 22:10:27 +02:00
s << std::put_time(&tm, format.c_str());
2023-08-12 01:13:03 +02:00
return s.str();
}
2023-08-23 01:47:55 +02:00
DLL_LINKAGE std::string getDateTimeISO8601Basic(std::time_t dt)
{
2023-12-16 22:10:27 +02:00
return getFormattedDateTime(dt, "%Y%m%dT%H%M%S");
2023-08-23 01:47:55 +02:00
}
2023-08-12 01:13:03 +02:00
}
VCMI_LIB_NAMESPACE_END