DateUtils.cpp 524 B

12345678910111213141516171819202122232425262728
  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)
  7. {
  8. std::tm tm = *std::localtime(&dt);
  9. std::stringstream s;
  10. s.imbue(std::locale(""));
  11. s << std::put_time(&tm, "%x %X");
  12. return s.str();
  13. }
  14. DLL_LINKAGE std::string getDateTimeISO8601Basic(std::time_t dt)
  15. {
  16. std::tm tm = *std::localtime(&dt);
  17. std::stringstream s;
  18. s << std::put_time(&tm, "%Y%m%dT%H%M%S");
  19. return s.str();
  20. }
  21. }
  22. VCMI_LIB_NAMESPACE_END