cmTimestamp.h 1023 Bytes
Newer Older
1 2
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
3 4 5
#ifndef cmTimestamp_h
#define cmTimestamp_h

6
#include "cmConfigure.h" // IWYU pragma: keep
Brad King's avatar
Brad King committed
7

8 9 10 11
#include <string>
#include <time.h>

/** \class cmTimestamp
12
 * \brief Utility class to generate string representation of a timestamp
13 14 15 16 17 18 19 20 21 22
 *
 */
class cmTimestamp
{
public:
  cmTimestamp() {}

  std::string CurrentTime(const std::string& formatString, bool utcFlag);

  std::string FileModificationTime(const char* path,
23 24
                                   const std::string& formatString,
                                   bool utcFlag);
25

26 27
  std::string CreateTimestampFromTimeT(time_t timeT, std::string formatString,
                                       bool utcFlag) const;
28

29 30 31
private:
  time_t CreateUtcTimeTFromTm(struct tm& timeStruct) const;

32 33
  std::string AddTimestampComponent(char flag, struct tm& timeStruct,
                                    time_t timeT) const;
34 35 36
};

#endif