#include "timeutils.h"
#include <flexptp_options.h>
Go to the source code of this file.
|
| TimestampI * | tsUToI (TimestampI *ti, const TimestampU *tu) |
| |
| TimestampU * | tsIToU (TimestampU *tu, const TimestampI *ti) |
| |
| TimestampI * | addTime (TimestampI *r, const TimestampI *a, const TimestampI *b) |
| |
| TimestampI * | subTime (TimestampI *r, const TimestampI *a, const TimestampI *b) |
| |
| TimestampI * | divTime (TimestampI *r, const TimestampI *a, int divisor) |
| |
| uint64_t | nsU (const TimestampU *t) |
| |
| int64_t | nsI (const TimestampI *t) |
| |
| void | normTime (TimestampI *t) |
| |
| int64_t | tsToTick (const TimestampI *ts, uint32_t tps) |
| |
| TimestampI * | nsToTsI (TimestampI *r, int64_t ns) |
| |
| bool | nonZeroI (const TimestampI *a) |
| |
| void | tsPrint (char *str, const TimestampI *ts) |
| |
|
| static unsigned | FIRST_DAY_OF_MONTH [] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 } |
| |
◆ addTime()
Add up timestamps. r = a + b;
- Parameters
-
| r | result |
| a | first operand |
| b | second operand |
- Returns
- r
Definition at line 24 of file timeutils.c.
◆ divTime()
Divide (inversely scale) a time value by an integer.
- Parameters
-
| r | pointer to the result field |
| a | dividend |
| divisor | divisor |
- Returns
- r
Definition at line 39 of file timeutils.c.
◆ nonZeroI()
Does the timestamp differ from zero?
- Parameters
-
- Returns
- a != 0
Definition at line 75 of file timeutils.c.
◆ normTime()
Normalize time. Move whole seconds from the nanoseconds field to the seconds.
- Parameters
-
| t | Time. It will be overwritten. |
Definition at line 57 of file timeutils.c.
◆ nsI()
Convert signed time into nanoseconds.
- Parameters
-
- Returns
- time in nanoseconds
Definition at line 52 of file timeutils.c.
◆ nsToTsI()
Convert nanoseconds to time.
- Parameters
-
| r | results |
| ns | time in nanoseconds |
- Returns
- r
Definition at line 69 of file timeutils.c.
◆ nsU()
Convert unsigned time into nanoseconds.
- Parameters
-
- Returns
- time in nanoseconds
Definition at line 47 of file timeutils.c.
◆ subTime()
Substract timestamps. r = a - b;
- Parameters
-
| r | result |
| a | first operand |
| b | second operand |
- Returns
- r
Definition at line 32 of file timeutils.c.
◆ tsIToU()
Convert signed timestamp to unsigned.
- Parameters
-
| tu | destination (signed) timestamp |
| ti | source (unsigned) timestamp |
Definition at line 15 of file timeutils.c.
◆ tsPrint()
| void tsPrint |
( |
char * |
str, |
|
|
const TimestampI * |
ts |
|
) |
| |
Print datetime to string.
- Parameters
-
| str | destination area, must provide at least 20 consecutive bytes! |
| ts | pointer to timestamp object holding the time value |
Definition at line 81 of file timeutils.c.
◆ tsToTick()
| int64_t tsToTick |
( |
const TimestampI * |
ts, |
|
|
uint32_t |
tps |
|
) |
| |
Convert duration (~time value) to hardware ticks.
- Parameters
-
| ts | time |
| tps | ticks per second |
- Returns
- duration in ticks (rounded to floor during division)
Definition at line 63 of file timeutils.c.
◆ tsUToI()
Convert unsigned timestamp to signed.
- Parameters
-
| ti | destination (signed) timestamp |
| tu | source (unsigned) timestamp |
Definition at line 8 of file timeutils.c.
◆ FIRST_DAY_OF_MONTH
| unsigned FIRST_DAY_OF_MONTH[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 } |
|
static |