22#ifndef LELY_UTIL_CHRONO_HPP_
23#define LELY_UTIL_CHRONO_HPP_
34inline ::std::chrono::nanoseconds
36 using ::std::chrono::nanoseconds;
37 using ::std::chrono::seconds;
42template <
class Rep,
class Period>
44to_timespec(const ::std::chrono::duration<Rep, Period>&
d)
noexcept {
45 using ::std::chrono::duration_cast;
46 using ::std::chrono::nanoseconds;
47 using ::std::chrono::seconds;
49 if (
sec.count() < ::std::numeric_limits<time_t>::min())
50 return timespec{::std::numeric_limits<time_t>::min(), 0};
51 if (
sec.count() > ::std::numeric_limits<time_t>::max())
52 return timespec{::std::numeric_limits<time_t>::max(), 0};
56 static_cast<long>(
nsec.count())};
63template <
class Clock,
class Duration>
65to_timespec(const ::std::chrono::time_point<Clock, Duration>&
t)
noexcept {
This header file is part of the compatibility library; it includes <chrono> and defines any missing f...
This header file is part of the C11 and POSIX compatibility library; it includes <time....
A time type with nanosecond resolution.
timespec to_timespec(const ::std::chrono::duration< Rep, Period > &d) noexcept
Converts a C++11 duration to a C11 time interval.
inline ::std::chrono::nanoseconds from_timespec(const timespec &ts) noexcept
Converts a C11 time interval to a C++11 duration.