mbgtools-lx  4.2.8
timeutil.c File Reference
#include <timeutil.h>
#include <mbgtime.h>
#include <str_util.h>

Go to the source code of this file.

Macros

#define _TIMEUTIL
 

Functions

int snprint_gmtime_error (char *s, size_t max_len, int mbg_errno, time_t t, const char *calling_fnc)
 
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)
 
static __mbg_inline int __to_iso_frac (time_t tstamp, int offset, time_t frac, const char *fmt, char *buf, size_t max_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

◆ _TIMEUTIL

#define _TIMEUTIL

Definition at line 41 of file timeutil.c.

Function Documentation

◆ __to_iso_frac()

static __mbg_inline int __to_iso_frac ( time_t  tstamp,
int  offset,
time_t  frac,
const char *  fmt,
char *  buf,
size_t  max_len 
)
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().