etsi_its_messages 1.0.0
Loading...
Searching...
No Matches
denm_utils.h File Reference

Utility functions for the ETSI ITS DENM (EN) More...

Go to the source code of this file.

Functions

uint64_t getUnixNanosecondsFromReferenceTime (const TimestampIts &reference_time)
 Get the Unix-Nanoseconds from a given ReferenceTime object.
 

Detailed Description

Utility functions for the ETSI ITS DENM (EN)

Definition in file denm_utils.h.

Function Documentation

◆ getUnixNanosecondsFromReferenceTime()

uint64_t getUnixNanosecondsFromReferenceTime ( const TimestampIts & reference_time)
inline

Get the Unix-Nanoseconds from a given ReferenceTime object.

Parameters
reference_timethe ReferenceTime object to get the Unix-Nanoseconds from
n_leap_secondsnumber of leap-seconds since 2004. (Default: etsi_its_msgs::N_LEAP_SECONDS)
Returns
uint64_t the corresponding Unix-Nanoseconds

Definition at line 44 of file denm_utils.h.

44 {
45 double unix_time_with_leap_seconds = reference_time.value * 1e-3 + etsi_its_msgs::UNIX_SECONDS_2004;
46 uint16_t n_leap_seconds =
47 etsi_its_msgs::getLeapSecondInsertionsSince2004(static_cast<uint64_t>(unix_time_with_leap_seconds));
48 return (unix_time_with_leap_seconds - n_leap_seconds) * 1e9;
49}
uint16_t getLeapSecondInsertionsSince2004(const uint64_t unix_seconds)
Get the leap second insertions since 2004 for given unix seconds.
Definition constants.h:60