VMS Help  —  DECdts  utc_mkbintime
    Converts a timespec structure to a binary timestamp.

    Format

      #include <utc.h>

      int utc_mkbintime(*utc, *timesp, *inaccsp)

         utc_t *utc;
         const timespec_t *timesp;
         const timespec_t *inaccsp;
         long tdf;

1  –  Parameters

    Input

 timesp

    A timespec structure that expresses time since 1970-01-
    01:00:00:00.0+0:00I0.

 inaccsp

    A timespec structure that expresses inaccuracy. If tv_sec is set
    to a value of -1, the inaccuracy is considered to be infinite.

 tdf

    TDF component of the binary timestamp.

    Output

 utc

    Resulting binary timestamp.

2  –  Description

    The Make Binary Time routine converts a timespec structure time
    to a binary timestamp. The TDF input is used as the TDF of the
    binary timestamp.

3  –  Returns

     0   Indicates that the routine executed successfully.
    -1   Indicates an invalid time argument or invalid results.

4  –  Example

    The following example obtains the current time from time(),
    converts it to a binary timestamp with an inaccuracy of 5.2
    seconds, and specifies GMT.

    timespec_t   ttime, tinacc;
    utc_t        utc;

    /*
     *   Obtain the current time (without the inaccuracy)...
     */

    ttime.tv_sec = time((time_t *)0);
    ttime.tv_nsec = 0;

    /*
     *   Specify the inaccuracy...
     */

    tinacc.tv_sec = 5;
    tinacc.tv_nsec = 200000000;

    /*
     *   Convert to a binary timestamp...
     */

    utc_mkbintime(&utc,       /* Out: Binary timestamp          */
                  &ttime,     /* In:  Current time in timespec  */
                  &tinacc,    /* In:  5.2 seconds in timespec   */
                  0);         /* In:  TDF of GMT                */

5  –  Related Functions

    utc_bintime, utc_mkbinreltime
Close Help