Library /sys$common/syshlp/helplib.hlb  —  DECdts  utc_anytime
    Converts a binary timestamp to a tm structure, using the time
    differential factor (TDF) information contained in the timestamp
    to determine the TDF returned with the tm structure.

    Format

      #include <utc.h>

      int utc_anytime(timetm, *tns, *inacctm, *ins, *tdf, *utc)

         struct tm timetm;
         long *tns;
         struct tm *inacctm;
         long *ins;
         long *tdf;
         const utc_t *utc;

1  –  Parameters

    Input

 utc

    Binary timestamp.

    Output

 timetm

    Time component of the binary timestamp expressed in the
    timestamp's local time.

 tns

    Nanoseconds since time component of the binary timestamp.

 inacctm

    Seconds of inaccuracy component of the binary timestamp. If the
    inaccuracy is finite, then tm_mday returns a value of -1 and tm_
    mon and tm_year return values of 0. The field tm_yday contains
    the inaccuracy in days. If the inaccuracy is infinite, all tm
    structure fields return values of -1.

 ins

    Nanoseconds of inaccuracy component of the binary timestamp.

 tdf

    TDF component of the binary timestamp in units of seconds east or
    west of GMT.

2  –  Description

    The Any Time routine converts a binary timestamp to a tm
    structure. The TDF information contained in the timestamp
    is returned with the time and inaccuracy components; the TDF
    component determines the offset from GMT and the local time value
    of the tm structure. Additional returns include nanoseconds since
    Time and nanoseconds of inaccuracy.

3  –  Returns

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

4  –  Example

    The following example converts a timestamp, using the TDF
    information in the timestamp, then prints the result.

    utc_t               evnt;
    struct tm           tmevnt;
    timespec_t          tevnt, ievnt;
    char                tznam[80];

    /*
     *   Assume evnt contains the timestamp to convert...
     *
     *   Get time as a tm structure, using the time zone information in
     *   the timestamp...
     */
    utc_anytime(&tmevnt,         /* Out: tm struct of time of evnt  */
                (long *)0,       /* Out: nanosec of time of evnt    */
                (struct tm *)0,  /* Out: tm struct of inacc of evnt */
                (long *)0,       /* Out: nanosec of inacc of evnt   */
                (int *)0,        /* Out: tdf of evnt                */
                &evnt);          /* In:  binary timestamp of evnt   */

    /*
     *   Get the time and inaccuracy as timespec structures...
     */
    utc_bintime(&tevnt,          /* Out: timespec of time of evnt   */
                &ievnt,          /* Out: timespec of inacc of evnt  */
                (int *)0,        /* Out: tdf of evnt                */
                &evnt);          /* In:  Binary timestamp of evnt   */

    /*
     *   Construct the time zone name from time zone information in the
     *   timestamp...
     */
    utc_anyzone(tznam,           /* Out: Time zone name             */
                80,              /* In:  Size of time zone name     */
                (long *)0,       /* Out: tdf of event               */
                (long *)0,       /* Out: Daylight saving flag       */
                &evnt);          /* In:  Binary timestamp of evnt   */

    /*
     *   Print timestamp in the format:
     *
     *           1991-03-05-21:27:50.023I0.140 (GMT-5:00)
     *           1992-04-02-12:37:24.003Iinf (GMT+7:00)
     *
     */

    printf("%d-%02d-%02d-%02d:%02d:%02d.%03d",
            tmevnt.tm_year+1900, tmevnt.tm_mon+1, tmevnt.tm_mday,
            tmevnt.tm_hour, tmevnt.tm_min, tmevnt.tm_sec,
            (tevnt.tv_nsec/1000000));

    if ((long)ievnt.tv_sec == -1)
        printf("Iinf");
    else
        printf("I%d.%03d", ievnt.tv_sec, (ievnt.tv_nsec/1000000));

    printf(" (%s)\n", tznam);

5  –  Related Functions

    utc_mkanytime, utc_anyzone, utc_gettime, utc_getusertime, utc_
    gmtime, utc_localtime
Close Help