cmTimestamp.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmTimestamp_h
  4. #define cmTimestamp_h
  5. #include <cmConfigure.h>
  6. #include "cmStandardIncludes.h"
  7. #include <string>
  8. #include <time.h>
  9. /** \class cmTimestamp
  10. * \brief Utility class to generate string representation of a timestamp
  11. *
  12. */
  13. class cmTimestamp
  14. {
  15. public:
  16. cmTimestamp() {}
  17. std::string CurrentTime(const std::string& formatString, bool utcFlag);
  18. std::string FileModificationTime(const char* path,
  19. const std::string& formatString,
  20. bool utcFlag);
  21. private:
  22. time_t CreateUtcTimeTFromTm(struct tm& timeStruct) const;
  23. std::string CreateTimestampFromTimeT(time_t timeT, std::string formatString,
  24. bool utcFlag) const;
  25. std::string AddTimestampComponent(char flag, struct tm& timeStruct,
  26. time_t timeT) const;
  27. };
  28. #endif