< previous page page_209 next page >

Page 209
8.4.3
Making an ISO Period
A complete ISO_PERIOD structure consists of three parts:
begin date/time
duration
end date/time
The three routines in this section accept two of the three components, and build the third. SCDTL practice is to build complete, not partial, ISO_PERIOD structures, so that an ISO_PERIOD structure is always in a known state and ready for use as an input argument.
(continued)
Listing 8.6
#include "scdtl_2.h"
#include "iso_2.h"


struct ISO_DATE_TIME iso_double_to_date_time (double jd)
{
   double jd1, frac, JD0;
   struct ISO_DATE_TIME dt;


   jd1 = jd;


   if (jd1 < 0.0)
      jd1 = -jd1;


   JD0 = JD_date_part (jd1);
   dt.date = JD0_to_date (JD0);
   frac = JD_time_part (jd1);
   dt.time = fraction_to_time (frac);


   return (dt);
}

Listing 8.7 iso_begin_and_duration_to_period ()
/* ibd2per.c
   +-------------------------------------------+
   |   Copyright (C) 1995 by Lance W. Latham.  |
   |         All rights reserved.              |
   +-------------------------------------------+


   Routine builds an ISO_PERIOD structure, using the begin date/time, expressed
   as an ISO_DATE_TIME structure, and the duration, expressed as an
   ISO_DURATION structure. The end date/time is calculated from the begin
   date/time and the duration, and inserted into the ISO_PERIOD structure.


   INPUTS:
   1. begin, a pointer to an ISO_DATE_TIME structure containing the 
      'begin' date/time for an ISO_PERIOD structure.
   2. duration, a pointer to an ISO_DURATION structure containing the
      'duration' elapsed time for an ISO_PERIOD structure.

 
< previous page page_209 next page >