Library /sys$common/syshlp/HELPLIB.HLB  —  DCE  DCE_DTS, Application Routines, utc_cmpintervaltime
 NAME

   utc_cmpintervaltime - Compares two binary timestamps or two relative
                         binary timestamps

 SYNOPSIS

   #include <dce/utc.h>

   int utc_cmpintervaltime( enum utc_cmptype *relation,
                            utc_t *utc1,
                            utc_t *utc2 );

 PARAMETERS

   Input

   utc1
       Binary timestamp or relative binary timestamp. Use NULL if you
       want this routine to use the current time for this parameter.

   utc2
       Binary timestamp or relative binary timestamp. Use NULL if you
       want this routine to use the current time for this parameter.

   Output

   relation
       Receives the result of the comparison of utc1:utc2 where the
       result is an enumerated type with one of the following values:

         + utc_equalTo

         + utc_lessThan

         + utc_greaterThan

         + utc_indeterminate

 DESCRIPTION

   The utc_cmpintervaltime() routine compares two binary timestamps and
   returns a flag indicating that the first time is greater than, less
   than, equal to, or overlapping with the second time. Two times overlap
   if the intervals (time - inaccuracy, time + inaccuracy) of the two
   times intersect.

   The input binary timestamps express two absolute or two relative
   times. Do not compare relative binary timestamps to absolute binary
   timestamps. If you do, no meaningful results and no errors are
   returned.

   The following routine does a temporal ordering of the time intervals.

        utc1 is utc_lessThan utc2 iff
                utc1.time + utc1.inacc < utc2.time - utc2.inacc

        utc1 is utc_greaterThan utc2 iff
                utc1.time - utc1.inacc > utc2.time + utc2.inacc

        utc1 utc_equalTo utc2 iff
                utc1.time == utc2.time and
                utc1.inacc == 0 and
                utc2.inacc == 0

        utc1 is utc_indeterminate with respect to utc2 if the intervals
        overlap.

 RETURN VALUES

    0    Indicates that the routine executed successfully.

   -1    Indicates an invalid time argument.

 EXAMPLES

   The following example checks to see if the current time is definitely
   after 13:00 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_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             */

      /*   Alter the tm structure to correspond to 13:00 local time   */

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

      /*  Convert to a binary timestamp...        */
      utc_mkgmtime(&testtime,   /* Out: Binary timestamp of 13:00     */
                   &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. Note the use of the NULL argument */

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

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

      if (relation != utc_greaterThan) {

      /*
       *     Note: It could be earlier than 13:00 local time or it
       *           could be indeterminate. If indeterminate, for some
       *           applications it might be worth waiting.
       */
       }

 RELATED INFORMATION

   Functions: utc_cmpmidtime
Close Help