DateUtils.cpp 453 B

123456789101112131415161718192021222324
  1. #include "StdInc.h"
  2. #include <vstd/DateUtils.h>
  3. VCMI_LIB_NAMESPACE_BEGIN
  4. namespace vstd
  5. {
  6. DLL_LINKAGE std::string getFormattedDateTime(std::time_t dt, std::string format)
  7. {
  8. std::tm tm = *std::localtime(&dt);
  9. std::stringstream s;
  10. s << std::put_time(&tm, format.c_str());
  11. return s.str();
  12. }
  13. DLL_LINKAGE std::string getDateTimeISO8601Basic(std::time_t dt)
  14. {
  15. return getFormattedDateTime(dt, "%Y%m%dT%H%M%S");
  16. }
  17. }
  18. VCMI_LIB_NAMESPACE_END