HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
hires_system_clock.hpp
1// Copyright Take Vos 2019.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "required.hpp"
8#include <date/tz.h>
9#include <chrono>
10#include <type_traits>
11
12namespace tt {
13
17 using rep = int64_t;
18 using period = std::nano;
21 static const bool is_steady = false;
22
23 static time_point now() noexcept;
24
25 static std::chrono::system_clock::time_point to_system_time_point(time_point x) noexcept {
26 static_assert(std::chrono::system_clock::period::num == 1, "Precision of system clock must be 1 second or better.");
27 static_assert(std::chrono::system_clock::period::den <= 1000000000, "Precision of system clock must be 1ns or worse.");
28
29 constexpr int64_t nano_to_sys_ratio = 1000000000LL / std::chrono::system_clock::period::den;
30
31 return std::chrono::system_clock::time_point{
32 std::chrono::system_clock::duration(x.time_since_epoch().count() / nano_to_sys_ratio)
33 };
34 }
35};
36
37
38
39}
Timestamp.
Definition hires_system_clock.hpp:16