Computes the absolute value of a relative binary timestamp. Format #include <utc.h> int utc_abstime(result, *utc1) utc_t result; const utc_t *utc1;
1 – Parameters
Input utc1 Relative binary timestamp. Output result Absolute value of the input relative binary timestamp.
2 – Description
The Absolute Time routine computes the absolute value of a relative binary timestamp. The input timestamp represents a relative (delta) time.
3 – Returns
0 Indicates that the routine executed successfully. -1 Indicates an invalid time parameter or invalid results.
4 – Example
The following example scales a relative time, computes its absolute value, and prints the result. utc_t relutc, scaledutc; char timstr[UTC_MAX_STR_LEN]; /* * Make sure relative timestamp represents a positive interval... */ utc_abstime(&relutc, /* Out: Abs-value of rel time */ &relutc); /* In: Relative time to scale */ /* * Scale it by a factor of 17... */ utc_multime(&scaledutc, /* Out: Scaled relative time */ &relutc, /* In: Relative time to scale */ 17L); /* In: Scale factor */ utc_ascreltime(timstr, /* Out: ASCII relative time */ UTC_MAX_STR_LEN, /* In: Length of input string */ &scaledutc); /* In: Relative time to */ /* convert */ printf("%s\n",timstr); /* * Scale it by a factor of 17.65... */ utc_mulftime(&scaledutc, /* Out: Scaled relative time */ &relutc, /* In: Relative time to scale */ 17.65); /* In: Scale factor */ utc_ascreltime(timstr, /* Out: ASCII relative time */ UTC_MAX_STR_LEN, /* In: Length of input string */ &scaledutc); /* In: Relative time to */ /* convert */ printf("%s\n",timstr);