etsi_its_messages v3.4.0
Loading...
Searching...
No Matches
cpm_ts_utils.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright Institute for Automotive Engineering (ika), RWTH Aachen University
3
8
9#pragma once
10
18inline uint64_t getUnixNanosecondsFromReferenceTime(const TimestampIts& reference_time) {
19 double unix_time_with_leap_seconds = reference_time.value * 1e-3 + etsi_its_msgs::UNIX_SECONDS_2004;
20 uint16_t n_leap_seconds =
21 etsi_its_msgs::getLeapSecondInsertionsSince2004(static_cast<uint64_t>(unix_time_with_leap_seconds));
22 return (unix_time_with_leap_seconds - n_leap_seconds) * 1e9;
23}
uint16_t getLeapSecondInsertionsSince2004(const uint64_t unix_seconds)
Get the leap second insertions since 2004 for given unix seconds.
Definition constants.h:37
uint64_t getUnixNanosecondsFromReferenceTime(const TimestampIts &reference_time)
Get the Unix-Nanoseconds from a given ReferenceTime object.