DateUtils.cpp 552 B

1234567891011121314151617181920212223242526272829
  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.imbue(std::locale(""));
  19. s << std::put_time(&tm, "%Y%m%dT%H%M%S");
  20. return s.str();
  21. }
  22. }
  23. VCMI_LIB_NAMESPACE_END