cmTimestamp.h 1023 B

123456789101112131415161718192021222324252627282930313233343536
  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" // IWYU pragma: keep
  6. #include <string>
  7. #include <time.h>
  8. /** \class cmTimestamp
  9. * \brief Utility class to generate string representation of a timestamp
  10. *
  11. */
  12. class cmTimestamp
  13. {
  14. public:
  15. cmTimestamp() {}
  16. std::string CurrentTime(const std::string& formatString, bool utcFlag);
  17. std::string FileModificationTime(const char* path,
  18. const std::string& formatString,
  19. bool utcFlag);
  20. private:
  21. time_t CreateUtcTimeTFromTm(struct tm& timeStruct) const;
  22. std::string CreateTimestampFromTimeT(time_t timeT, std::string formatString,
  23. bool utcFlag) const;
  24. std::string AddTimestampComponent(char flag, struct tm& timeStruct,
  25. time_t timeT) const;
  26. };
  27. #endif