mbgtools-lx
4.2.8
|
#include <nanotime.h>
#include <mbgtime.h>
#include <mbgerror.h>
#include <mbgmktm.h>
#include <str_util.h>
#include <timeutil.h>
Go to the source code of this file.
Macros | |
#define | _NANOTIME |
Functions | |
double | nano_time_to_double (const NANO_TIME *p) |
Convert a NANO_TIME time to double. More... | |
void | double_to_nano_time (NANO_TIME *p, double d) |
Setup a NANO_TIME structure from a time provided as double. More... | |
size_t | snprint_nano_time (char *s, size_t max_len, const NANO_TIME *nt) |
Print nano time into string buffer. More... | |
void | normalize_nano_time_64 (NANO_TIME_64 *nt) |
Normalize a NANO_TIME_64 time. More... | |
double | nano_time_64_to_double (const NANO_TIME_64 *p) |
Convert a NANO_TIME_64 time to double. More... | |
void | double_to_nano_time_64 (NANO_TIME_64 *p, double d) |
Setup a NANO_TIME_64 structure from a time as double. More... | |
size_t | snprint_nano_time_64 (char *s, size_t max_len, const NANO_TIME_64 *nt) |
Print a normalized NANO_TIME_64 into a string buffer. More... | |
static __mbg_inline void | div_nano_time_64 (NANO_TIME_64 *p, long div, long mul) |
Generic function to divide NANO_TIME_64 value. More... | |
static __mbg_inline void | str_to_nano_time_64 (const char *s, NANO_TIME_64 *p, int base, int frac_digits) |
Generic function to set up a NANO_TIME_64 structure from a string. More... | |
void | str_s_to_nano_time_64 (const char *s, NANO_TIME_64 *p) |
Set up a NANO_TIME_64 structure from a string with a time in seconds and fractions. More... | |
void | str_ms_to_nano_time_64 (const char *s, NANO_TIME_64 *p) |
Set up a NANO_TIME_64 structure from a string with a time in milliseconds and fractions. More... | |
int | nano_time_64_to_tm_gps (TM_GPS *tm_gps, const NANO_TIME_64 *nt) |
Convert NANO_TIME_64 to TM_GPS. More... | |
int | tm_gps_to_nano_time_64 (NANO_TIME_64 *nt, const TM_GPS *tm) |
Convert TM_GPS to NANO_TIME_64. More... | |
#define _NANOTIME |
Definition at line 34 of file nanotime.c.
|
static |
Generic function to divide NANO_TIME_64 value.
[in,out] | p | Address of a NANO_TIME_64 structure to be divided |
[in] | div | The number by which to divide |
[in] | mul | The complementary number to div, i.e. mul = 1000000000 / div |
Definition at line 224 of file nanotime.c.
References NANO_TIME_64::nano_secs, and NANO_TIME_64::secs.
Referenced by str_ms_to_nano_time_64().
void double_to_nano_time | ( | NANO_TIME * | p, |
double | d | ||
) |
Setup a NANO_TIME structure from a time provided as double.
[out] | p | Address of a NANO_TIME structure to be set up |
[in] | d | The time to be converted, in seconds with fractions, as double |
Definition at line 80 of file nanotime.c.
References NANO_TIME::nano_secs, and NANO_TIME::secs.
void double_to_nano_time_64 | ( | NANO_TIME_64 * | p, |
double | d | ||
) |
Setup a NANO_TIME_64 structure from a time as double.
[out] | p | Address of a NANO_TIME_64 structure to be set up |
[in] | d | The time to be converted, in seconds with fractions, as double |
Definition at line 184 of file nanotime.c.
References NANO_TIME_64::nano_secs, and NANO_TIME_64::secs.
double nano_time_64_to_double | ( | const NANO_TIME_64 * | p | ) |
Convert a NANO_TIME_64 time to double.
[in] | p | Address of a NANO_TIME_64 structure to be converted |
Definition at line 163 of file nanotime.c.
References NANO_TIME_64::nano_secs, and NANO_TIME_64::secs.
int nano_time_64_to_tm_gps | ( | TM_GPS * | tm_gps, |
const NANO_TIME_64 * | nt | ||
) |
Convert NANO_TIME_64 to TM_GPS.
[out] | tm_gps | The TM_GPS to be filled |
[in] | nt | The NANO_TIME_64 to be converted |
Definition at line 341 of file nanotime.c.
References cvt_to_time_t(), TM_GPS::frac, TM_GPS::hour, mbg_gmtime(), mbg_rc_is_success, TM_GPS::mday, TM_GPS::min, TM_GPS::month, TM_GPS::offs_from_utc, TM_GPS::sec, NANO_TIME_64::secs, TM_GPS::wday, TM_GPS::yday, and TM_GPS::year.
double nano_time_to_double | ( | const NANO_TIME * | p | ) |
Convert a NANO_TIME time to double.
[in] | p | Address of a NANO_TIME structure to be converted |
Definition at line 59 of file nanotime.c.
References NANO_TIME::nano_secs, and NANO_TIME::secs.
void normalize_nano_time_64 | ( | NANO_TIME_64 * | nt | ) |
Normalize a NANO_TIME_64 time.
After normalization, the following can be assumed:
[in,out] | nt | The NANO_TIME_64 to be normalized |
Definition at line 128 of file nanotime.c.
References NANO_TIME_64::nano_secs, NSEC_PER_SEC, and NANO_TIME_64::secs.
size_t snprint_nano_time | ( | char * | s, |
size_t | max_len, | ||
const NANO_TIME * | nt | ||
) |
Print nano time into string buffer.
[out] | s | The string buffer to be filled |
[in] | max_len | Size of the output buffer for 0-terminated string |
[in] | nt | The NANO_TIME to be printed |
Definition at line 102 of file nanotime.c.
References _nano_time_negative, NANO_TIME::nano_secs, NANO_TIME::secs, and snprintf_safe().
Referenced by show_ptp_state().
size_t snprint_nano_time_64 | ( | char * | s, |
size_t | max_len, | ||
const NANO_TIME_64 * | nt | ||
) |
Print a normalized NANO_TIME_64 into a string buffer.
[out] | s | The string buffer to be filled |
[in] | max_len | Size of the output buffer for 0-terminated string |
[in] | nt | The NANO_TIME_64 to be printed |
Definition at line 204 of file nanotime.c.
References _abs64, _nano_time_negative, NANO_TIME_64::nano_secs, NANO_TIME_64::secs, and snprintf_safe().
void str_ms_to_nano_time_64 | ( | const char * | s, |
NANO_TIME_64 * | p | ||
) |
Set up a NANO_TIME_64 structure from a string with a time in milliseconds and fractions.
[in] | s | A string with a time in milliseconds, with fractions separated by decimal point |
[out] | p | Address of a NANO_TIME_64 structure to be set up |
Definition at line 315 of file nanotime.c.
References div_nano_time_64(), and str_s_to_nano_time_64().
void str_s_to_nano_time_64 | ( | const char * | s, |
NANO_TIME_64 * | p | ||
) |
Set up a NANO_TIME_64 structure from a string with a time in seconds and fractions.
[in] | s | A string with a time in seconds, with fractions separated by decimal point |
[out] | p | Address of a NANO_TIME_64 structure to be set up |
Definition at line 300 of file nanotime.c.
References str_to_nano_time_64().
Referenced by str_ms_to_nano_time_64().
|
static |
Generic function to set up a NANO_TIME_64 structure from a string.
[in] | s | A string with a time in seconds, with fractions separated by decimal point |
[out] | p | Address of a NANO_TIME_64 structure to be set up |
[in] | base | The base of the conversion, i.e. 10 for a string with decimal numbers, or 16 for a hex string |
[in] | frac_digits | The number of fractions required to represent 1 nanosecond, e.g. 9 for a decimal string like 0.000000001, or TODO for a hex string like 0x00000000.00000000 |
Definition at line 254 of file nanotime.c.
References NANO_TIME_64::nano_secs, and NANO_TIME_64::secs.
Referenced by str_s_to_nano_time_64().
int tm_gps_to_nano_time_64 | ( | NANO_TIME_64 * | nt, |
const TM_GPS * | tm | ||
) |
Convert TM_GPS to NANO_TIME_64.
[out] | nt | The NANO_TIME_64 to be filled |
[in] | tm | The TM_GPS to be converted |
Definition at line 380 of file nanotime.c.
References TM_GPS::hour, mbg_mktime(), TM_GPS::mday, TM_GPS::min, TM_GPS::month, NANO_TIME_64::nano_secs, TM_GPS::sec, NANO_TIME_64::secs, and TM_GPS::year.