HELPLIB.HLB  —  DECdts  utc_anytime, 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);
Close Help