6#ifndef _TIME_SHIELD_TIME_UTILS_HPP_INCLUDED
7#define _TIME_SHIELD_TIME_UTILS_HPP_INCLUDED
19# if defined(CLOCK_REALTIME)
20 clock_gettime(CLOCK_REALTIME, &
ts);
22 timespec_get(&
ts, TIME_UTC);
30 template<
class T =
int>
33 return static_cast<T
>(
ts.tv_nsec);
39 template<
class T =
int>
48 template<
class T =
int>
Header file with preprocessor definitions.
Main namespace for the Time Shield library.
int64_t ts_t
Integer timestamp type.
const ts_ms_t timestamp_ms() noexcept
Get the current UTC timestamp in milliseconds.
const ts_us_t ts_us() noexcept
Get the current UTC timestamp in microseconds.
const T us_of_sec() noexcept
Get the microsecond part of the current second.
const ts_us_t timestamp_us() noexcept
Get the current UTC timestamp in microseconds.
constexpr int64_t NS_PER_US
Nanoseconds per microsecond.
TIME_SHIELD_CONSTEXPR const ts_t ts(const T1 &year, const T2 &month, const T2 &day, const T2 &hour=0, const T2 &min=0, const T2 &sec=0)
Alias for to_timestamp function.
int64_t ts_ms_t
Integer timestamp milliseconds type.
const ts_ms_t now() noexcept
Get the current UTC timestamp in milliseconds.
constexpr int64_t MS_PER_SEC
Milliseconds per second.
const ts_t timestamp() noexcept
Get the current UTC timestamp in seconds.
const ts_ms_t ts_ms() noexcept
Get the current UTC timestamp in milliseconds.
const T ns_of_sec() noexcept
Get the nanosecond part of the current second.
double fts_t
Floating point timestamp type.
constexpr int64_t NS_PER_MS
Nanoseconds per millisecond.
const fts_t fts() noexcept
Get the current UTC timestamp in floating-point seconds.
const fts_t ftimestamp() noexcept
Get the current UTC timestamp in floating-point seconds.
int64_t ts_us_t
Integer timestamp microseconds type.
const struct timespec get_timespec_impl() noexcept
Get the current timespec.
constexpr int64_t NS_PER_SEC
Nanoseconds per second.
const T ms_of_sec() noexcept
Get the millisecond part of the current second.
const ts_t ts() noexcept
Get the current UTC timestamp in seconds.
constexpr int64_t US_PER_SEC
Microseconds per second.