6#ifndef _TIME_SHIELD_TIME_UTILS_HPP_INCLUDED
7#define _TIME_SHIELD_TIME_UTILS_HPP_INCLUDED
49# if defined(CLOCK_REALTIME)
50 clock_gettime(CLOCK_REALTIME, &
ts);
52 timespec_get(&
ts, TIME_UTC);
60 template<
class T =
int>
63 return static_cast<T
>(
ts.tv_nsec);
69 template<
class T =
int>
78 template<
class T =
int>
Header file with preprocessor definitions for C++ standards and constexpr usage.
constexpr int64_t NS_PER_US
Nanoseconds per microsecond.
constexpr int64_t MS_PER_SEC
Milliseconds per second.
constexpr int64_t NS_PER_MS
Nanoseconds per millisecond.
constexpr int64_t NS_PER_SEC
Nanoseconds per second.
constexpr int64_t US_PER_SEC
Microseconds per second.
TIME_SHIELD_CONSTEXPR const ts_t ts(T1 year, T2 month, T2 day, T2 hour=0, T2 min=0, T2 sec=0)
Alias for to_timestamp function.
int64_t ts_t
Type for representing timestamps in seconds.
int64_t ts_ms_t
Type for representing timestamps in milliseconds.
double fts_t
Type for representing timestamps as floating-point numbers (e.g., fractional seconds).
int64_t ts_us_t
Type for representing timestamps in microseconds.
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.
const ts_ms_t now() noexcept
Get the current UTC timestamp in milliseconds.
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.
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.
const struct timespec get_timespec_impl() noexcept
Get the current timespec.
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.
Main namespace for the Time Shield library.