HELPLIB.HLB  —  DECdts  utc_cmpintervaltime, Example
    The following example checks to see if the current time is
    definitely after 1:00 P.M. today GMT.

    struct tm           tmtime, tmzero;
    enum utc_cmptype    relation;
    utc_t               testtime;

    /*
     *   Zero the tm structure for inaccuracy...
     */

    memset(&tmzero, 0, sizeof(tmzero));

    /*
     *   Get the current time, mapped to a tm structure...
     *
     *        NOTE: The NULL argument is used to get the current time.
     */

    utc_gmtime(&tmtime,      /* Out: Current GMT time in tm struct   */
             (long *)0,      /* Out: Nanoseconds of time             */
             (struct tm *)0, /* Out: Current inaccuracy in tm struct */
             (long *)0,      /* Out: Nanoseconds of inaccuracy       */
             (utc_t *)0);    /* In:  Current timestamp               */

    /*
     *   Construct a tm structure that corresponds to 1:00 PM...
     */

    tmtime.tm_hour = 13;
    tmtime.tm_min = 0;
    tmtime.tm_sec = 0;

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

    utc_mkgmtime(&testtime,  /* Out: Binary timestamp of 1:00 PM  */
                 &tmtime,    /* In:  1:00 PM in tm struct         */
                 0,          /* In:  Nanoseconds of time          */
                 &tmzero,    /* In:  Zero inaccuracy in tm struct */
                 0);         /* In:  Nanoseconds of inaccuracy    */

    /*
     *   Compare to the current time, noting the use of the
     *   NULL argument...
     */

    utc_cmpintervaltime(&relation,    /* Out: Comparison relation */
                        (utc_t *)0,   /* In:  Current timestamp   */
                        &testtime);   /* In:  1:00 PM timestamp   */

    /*
     *   If it is not later - wait, print a message, etc.
     */

    if (relation != utc_greaterThan) {

    /*
     *     Note: It could be earlier than 1:00 PM or it could be
     *           indeterminate. If indeterminate, for some applications
     *           it might be worth waiting.
     */
    }
Close Help