mbgtools-lx  4.2.8
timeutil.h File Reference
#include <gpsdefs.h>
#include <mbgerror.h>
#include <mbgtime.h>
#include <time.h>
#include <stddef.h>

Go to the source code of this file.

Macros

#define _ext   extern
 

Typedefs

typedef int64_t mbg_time_t
 

Functions

static __mbg_inline time_t cvt_to_time_t (mbg_time_t t)
 
static __mbg_inline int mbg_gmtime (struct tm *p_tm, const time_t *p_time)
 
static __mbg_inline double ntp_tstamp_to_double (const NTP_TSTAMP *t)
 
static __mbg_inline ulong ntp_frac_to_nsec (uint32_t frac)
 
static __mbg_inline uint32_t nsec_to_ntp_frac (ulong nsec)
 
static __mbg_inline void timespec_to_ntp_tstamp (NTP_TSTAMP *t_ntp, const struct timespec *t_ts)
 
static __mbg_inline void ntp_tstamp_to_timespec (struct timespec *t_ts, const NTP_TSTAMP *t_ntp)
 
static __mbg_inline int timespec_is_set (const struct timespec *p)
 
static __mbg_inline double delta_timespec_d_s (const struct timespec *ts, const struct timespec *ts_ref)
 
static __mbg_inline int64_t delta_timespec_ll_ns (const struct timespec *ts, const struct timespec *ts_ref)
 
int snprint_gmtime_error (char *s, size_t max_len, int mbg_errno, time_t t, const char *calling_fnc)
 
int mbg_clock_gettime (clockid_t clock_id, struct timespec *tp)
 
int mbg_clock_settime (clockid_t clock_id, const struct timespec *tp)
 
void check_precise_time_api (void)
 
int snprint_utc_offs (char *s, size_t max_len, const char *info, long utc_offs)
 Print a UTC offset into a string. More...
 
int snprint_time_t_to_iso (time_t tstamp, int offs_hours, char *buf, size_t len)
 
int snprint_time_t_to_iso_ms (time_t tstamp, int offs_hours, time_t frac, char *buf, size_t len)
 
int snprint_time_t_to_iso_us (time_t tstamp, int offs_hours, time_t frac, char *buf, size_t len)
 
int snprint_time_t_to_iso_ns (time_t tstamp, int offs_hours, time_t frac, char *buf, size_t len)
 
int snprint_ntp_tstamp_to_iso_ms (const NTP_TSTAMP *ts, char *buf, size_t len)
 
int snprint_ntp_tstamp_to_iso_us (const NTP_TSTAMP *ts, char *buf, size_t len)
 
int snprint_ntp_tstamp_to_iso_ns (const NTP_TSTAMP *ts, char *buf, size_t len)
 

Macro Definition Documentation

◆ _ext

#define _ext   extern

Definition at line 55 of file timeutil.h.

Typedef Documentation

◆ mbg_time_t

Definition at line 101 of file timeutil.h.

Function Documentation

◆ check_precise_time_api()

void check_precise_time_api ( void  )

◆ cvt_to_time_t()

◆ delta_timespec_d_s()

static __mbg_inline double delta_timespec_d_s ( const struct timespec *  ts,
const struct timespec *  ts_ref 
)
static

Definition at line 215 of file timeutil.h.

References NSEC_PER_SEC.

◆ delta_timespec_ll_ns()

◆ mbg_clock_gettime()

int mbg_clock_gettime ( clockid_t  clock_id,
struct timespec *  tp 
)

◆ mbg_clock_settime()

int mbg_clock_settime ( clockid_t  clock_id,
const struct timespec *  tp 
)

◆ mbg_gmtime()

◆ nsec_to_ntp_frac()

static __mbg_inline uint32_t nsec_to_ntp_frac ( ulong  nsec)
static

Definition at line 162 of file timeutil.h.

References NSEC_PER_SEC, and NTP_FRAC_PER_SEC.

Referenced by timespec_to_ntp_tstamp().

◆ ntp_frac_to_nsec()

static __mbg_inline ulong ntp_frac_to_nsec ( uint32_t  frac)
static

Definition at line 145 of file timeutil.h.

References NSEC_PER_SEC, and NTP_FRAC_PER_SEC.

Referenced by ntp_tstamp_to_timespec().

◆ ntp_tstamp_to_double()

static __mbg_inline double ntp_tstamp_to_double ( const NTP_TSTAMP t)
static

Definition at line 136 of file timeutil.h.

References NTP_TSTAMP::fractions, NTP_FRAC_PER_SEC, and NTP_TSTAMP::seconds.

◆ ntp_tstamp_to_timespec()

static __mbg_inline void ntp_tstamp_to_timespec ( struct timespec *  t_ts,
const NTP_TSTAMP t_ntp 
)
static

◆ snprint_gmtime_error()

int snprint_gmtime_error ( char *  s,
size_t  max_len,
int  mbg_errno,
time_t  t,
const char *  calling_fnc 
)

◆ snprint_ntp_tstamp_to_iso_ms()

int snprint_ntp_tstamp_to_iso_ms ( const NTP_TSTAMP ts,
char *  buf,
size_t  len 
)

◆ snprint_ntp_tstamp_to_iso_ns()

int snprint_ntp_tstamp_to_iso_ns ( const NTP_TSTAMP ts,
char *  buf,
size_t  len 
)

◆ snprint_ntp_tstamp_to_iso_us()

int snprint_ntp_tstamp_to_iso_us ( const NTP_TSTAMP ts,
char *  buf,
size_t  len 
)

◆ snprint_time_t_to_iso()

int snprint_time_t_to_iso ( time_t  tstamp,
int  offs_hours,
char *  buf,
size_t  len 
)

◆ snprint_time_t_to_iso_ms()

int snprint_time_t_to_iso_ms ( time_t  tstamp,
int  offs_hours,
time_t  frac,
char *  buf,
size_t  len 
)

Definition at line 283 of file timeutil.c.

References __to_iso_frac(), and MSEC_PER_SEC.

Referenced by delta_timespec_ll_ns(), and snprint_ntp_tstamp_to_iso_ms().

◆ snprint_time_t_to_iso_ns()

int snprint_time_t_to_iso_ns ( time_t  tstamp,
int  offs_hours,
time_t  frac,
char *  buf,
size_t  len 
)

Definition at line 309 of file timeutil.c.

References __to_iso_frac(), and NSEC_PER_SEC.

Referenced by delta_timespec_ll_ns(), and snprint_ntp_tstamp_to_iso_ns().

◆ snprint_time_t_to_iso_us()

int snprint_time_t_to_iso_us ( time_t  tstamp,
int  offs_hours,
time_t  frac,
char *  buf,
size_t  len 
)

Definition at line 296 of file timeutil.c.

References __to_iso_frac(), and USEC_PER_SEC.

Referenced by delta_timespec_ll_ns(), and snprint_ntp_tstamp_to_iso_us().

◆ snprint_utc_offs()

int snprint_utc_offs ( char *  s,
size_t  max_len,
const char *  info,
long  utc_offs 
)

Print a UTC offset into a string.

Format of the string is "[info]+hh[:mm[:ss]]h"

Parameters
[out]sAddress of a string buffer to be filled.
[in]max_lenSize of the string buffer.
[in]infoAn optional info string to be prepended, may be NULL.
[in]utc_offsThe UTC offset to be printed, in [s].
Returns
The number of characters written to the output buffer, except the terminating 0.

Definition at line 211 of file timeutil.c.

References _int_from_size_t, MINS_PER_HOUR, SECS_PER_HOUR, sn_cpy_str_safe(), and snprintf_safe().

Referenced by delta_timespec_ll_ns(), get_tz_name(), mbg_snprint_hr_time(), and show_time_and_status().

◆ timespec_is_set()

static __mbg_inline int timespec_is_set ( const struct timespec *  p)
static

Definition at line 203 of file timeutil.h.

◆ timespec_to_ntp_tstamp()

static __mbg_inline void timespec_to_ntp_tstamp ( NTP_TSTAMP t_ntp,
const struct timespec *  t_ts 
)
static