cmake/Source/cmTimestamp.h

38 lines
1.2 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2021-09-14 00:13:48 +02:00
#pragma once
2013-03-16 19:13:01 +02:00
2017-07-20 19:35:53 +02:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-07-09 11:21:54 +02:00
2022-03-29 21:10:50 +02:00
#include <cstdint>
2020-02-01 23:06:01 +01:00
#include <ctime>
2013-03-16 19:13:01 +02:00
#include <string>
/** \class cmTimestamp
2016-07-09 11:21:54 +02:00
* \brief Utility class to generate string representation of a timestamp
2013-03-16 19:13:01 +02:00
*
*/
class cmTimestamp
{
public:
2021-09-14 00:13:48 +02:00
std::string CurrentTime(const std::string& formatString, bool utcFlag) const;
2013-03-16 19:13:01 +02:00
std::string FileModificationTime(const char* path,
2016-07-09 11:21:54 +02:00
const std::string& formatString,
2021-09-14 00:13:48 +02:00
bool utcFlag) const;
2013-03-16 19:13:01 +02:00
2016-07-09 11:21:54 +02:00
std::string CreateTimestampFromTimeT(time_t timeT, std::string formatString,
bool utcFlag) const;
2013-03-16 19:13:01 +02:00
2022-03-29 21:10:50 +02:00
std::string CreateTimestampFromTimeT(time_t timeT, uint32_t microseconds,
std::string formatString,
bool utcFlag) const;
2019-11-11 23:01:05 +01:00
private:
time_t CreateUtcTimeTFromTm(struct tm& timeStruct) const;
2016-07-09 11:21:54 +02:00
std::string AddTimestampComponent(char flag, struct tm& timeStruct,
2023-05-23 16:38:00 +02:00
time_t timeT, bool utcFlag,
uint32_t microseconds) const;
2016-07-09 11:21:54 +02:00
};