HELPLIB.HLB  —  DECdts  utc_cmpmidtime, Example
    The following example checks if the current time (ignoring
    inaccuracies) is after 1:00 P.M. today local time.

    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_localtime(&tmtime,   /* Out: Current local time in tm struct */
             (long *)0,      /* Out: Nanoseconds of time             */
             (struct tm *)0, /* Out: Current inacc in tm struct      */
             (long *)0,      /* Out: Nanoseconds of inaccuracy       */
             (utc_t *)0);    /* In:  Current timestamp               */

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

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

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

    utc_mklocaltime(&testtime, /* Out: Binary timestamp of 1:00 P.M. */
                    &tmtime,   /* In:  1:00 P.M. 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_cmpmidtime(&relation,    /* Out: Comparison relation         */
                   (utc_t *)0,   /* In:  Current timestamp           */
                   &testtime);   /* In:  1:00 P.M. timestamp         */

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

    if (relation != utc_greaterThan) {

    /*          It is not later then 1:00 P.M. local time. Note that
     *          this depends on the setting of the user's environment.
     */
    }
Close Help