19 #include <openssl/ossl_typ.h> 31 return duration !=
T::max() && duration >= zero;
40 template <
typename ClockType = SteadyClock>
45 inline std::chrono::system_clock::time_point
48 std::chrono::duration_cast<std::chrono::system_clock::duration>(
57 return std::chrono::duration_cast<std::chrono::milliseconds>(
62 return std::chrono::duration_cast<std::chrono::seconds>(
67 return std::chrono::duration_cast<std::chrono::milliseconds>(
72 return std::chrono::duration_cast<std::chrono::seconds>(
76 template <
typename ClockType = SteadyClock>
78 std::chrono::time_point<ClockType> finish,
79 std::chrono::time_point<ClockType>
start) {
80 return std::chrono::duration_cast<std::chrono::microseconds>(
84 template <
typename ClockType = SteadyClock>
86 std::chrono::time_point<ClockType> finish,
87 std::chrono::time_point<ClockType>
start) {
88 return std::chrono::duration_cast<std::chrono::milliseconds>(
92 template <
typename ClockType = SteadyClock>
94 std::chrono::time_point<ClockType> finish,
95 std::chrono::time_point<ClockType>
start) {
96 return std::chrono::duration_cast<std::chrono::seconds>(
100 template <
typename ClockType = SteadyClock>
102 std::chrono::time_point<ClockType>
t) {
106 template <
typename ClockType = SteadyClock>
107 inline std::chrono::seconds
secondsSince(std::chrono::time_point<ClockType>
t) {
115 time_t
now =
toTimeT(getCurrentTime<SteadyClock>());
117 localtime_r(&now, &now_tm);
119 strftime(datebuf,
sizeof(
char) * 32,
"%Y-%m-%d", &now_tm);
122 strftime(timebuf,
sizeof(
char) * 32,
"%H:%M:%S", &now_tm);
130 time_t
t =
toTimeT(getCurrentTime<SteadyClock>());
131 t += dayOffset * 24 * 60 * 60;
133 localtime_r(&t, &final_tm);
134 strftime(datebuf,
sizeof(
char) * 32,
"%Y-%m-%d", &final_tm);
148 gmtime_r(&t, &final_tm);
150 if (strftime(buf,
sizeof(buf),
"%Y-%m-%dT%H:%M:%S %z", &final_tm) > 0) {
169 template <
typename ClockType = SteadyClock>
174 virtual std::chrono::time_point<ClockType>
now()
const {
175 return getCurrentTime<ClockType>();
179 const static std::chrono::time_point<ClockType> kZeroTimePoint{};
180 return kZeroTimePoint;
std::chrono::milliseconds millisecondsBetween(std::chrono::time_point< ClockType > finish, std::chrono::time_point< ClockType > start)
virtual uint64_t msSinceEpoch()
time_t toTimeT(TimePoint t)
std::chrono::seconds secondsBetween(std::chrono::time_point< ClockType > finish, std::chrono::time_point< ClockType > start)
bool durationInitialized(const T &duration)
std::chrono::steady_clock::time_point now()
void getDateOffsetStr(char datebuf[32], int dayOffset)
std::chrono::steady_clock SteadyClock
virtual std::chrono::time_point< ClockType > now() const
std::string getDateTimeStr(const ASN1_TIME *const time)
std::chrono::microseconds microsecondsBetween(std::chrono::time_point< ClockType > finish, std::chrono::time_point< ClockType > start)
SteadyClock::time_point TimePoint
std::chrono::seconds secondsSinceEpoch()
std::chrono::milliseconds millisecondsSince(std::chrono::time_point< ClockType > t)
SystemClock::time_point SystemTimePoint
virtual ~TimeUtilGeneric()
static const std::chrono::time_point< ClockType > & getZeroTimePoint()
std::chrono::time_point< ClockType > getCurrentTime()
std::chrono::milliseconds millisecondsSinceEpoch()
std::chrono::system_clock::time_point toSystemTimePoint(TimePoint t)
bool timePointInitialized(const T &time)
std::chrono::nanoseconds time()
std::chrono::system_clock SystemClock
std::chrono::seconds secondsSince(std::chrono::time_point< ClockType > t)