cmTimestamp.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2012 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmTimestamp_h
  11. #define cmTimestamp_h
  12. #include <string>
  13. #include <time.h>
  14. /** \class cmTimestamp
  15. * \brief Utility class to generate string representation of a timestamp
  16. *
  17. */
  18. class cmTimestamp
  19. {
  20. public:
  21. cmTimestamp() {}
  22. std::string CurrentTime(const std::string& formatString, bool utcFlag);
  23. std::string FileModificationTime(const char* path,
  24. const std::string& formatString, bool utcFlag);
  25. private:
  26. time_t CreateUtcTimeTFromTm(struct tm& timeStruct) const;
  27. std::string CreateTimestampFromTimeT(
  28. time_t timeT, std::string formatString, bool utcFlag) const;
  29. std::string AddTimestampComponent(
  30. char flag, struct tm& timeStruct, time_t timeT) const;
  31. };
  32. #endif