10 static std::string
systime2str(
const std::chrono::system_clock::time_point& tp)
12 const auto tt = std::chrono::system_clock::to_time_t(tp);
13 return std::ctime(&tt);
23 std::cout <<
"Clock adjustment mode: ";
28 std::cout <<
"SystemWide";
33 std::cout <<
"PerDriverPrivate";
42 std::cout << std::endl;
48 std::cout <<
"Enter system time adjustment in seconds (fractions allowed): " << std::endl;
51 const auto before = std::chrono::system_clock::now();
58 std::cout << ex.what() << std::endl;
59 std::cout << strerror(ex.
getErrno()) << std::endl;
62 const auto after = std::chrono::system_clock::now();
64 std::cout <<
"Time before: " <<
systime2str(before) <<
"\n" 66 <<
"Millisecond diff (after - before): " 67 << std::chrono::duration_cast<std::chrono::milliseconds>(after - before).count() << std::endl;
ClockAdjustmentMode getAdjustmentMode() const
void adjustUtc(const uavcan::UtcDuration adjustment) override
Adjust the clock globally for the whole system; requires root privileges.
static UtcDuration fromUSec(int64_t us)
static std::string systime2str(const std::chrono::system_clock::time_point &tp)
Adjust the clock only for the current driver instance.