aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/utils/system_time.cpp
blob: 6693a38d44aeb9cd1d0115bdd60506c84c4ebff9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//
// Copyright 2017 Ettus Research (National Instruments Corp.)
//
// SPDX-License-Identifier: GPL-3.0+
//

#include <uhdlib/utils/system_time.hpp>
#include <chrono>

uhd::time_spec_t uhd::get_system_time(void)
{
    const auto now     = std::chrono::steady_clock::now().time_since_epoch();
    const auto seconds = std::chrono::duration_cast<std::chrono::seconds>(now);
    const auto nanoseconds =
        std::chrono::duration_cast<std::chrono::nanoseconds>(now - seconds);
    return uhd::time_spec_t(seconds.count(), nanoseconds.count(), 1e9);
}