|
|
|
|
|
|
|
8.4.1.2 iso_double_to_duration () |
|
|
|
|
|
|
|
|
The routine iso_double_to_duration () (Listing 8.4) converts a type double to an elapsed time, expressed as an ISO_DURATION structure. |
|
|
|
|
|
|
|
|
8.4.2
ISO Date/Time and double |
|
|
|
|
|
|
|
|
The routines in this section interconvert an ISO_DATE_TIME structure and a type double value, which is assumed to be a complete Julian Day number. |
|
|
|
|
| Listing 8.3 | |
|
|
|
|
#include "scdtl_2.h"
#include "iso_2.h"
double iso_duration_to_double (struct ISO_DURATION *duration)
{
double jdz, frac;
struct DATE_INFO date;
struct TIME_INFO time;
date = duration->date;
if (date.year < 0)
date.year = -date.year;
if (date.month < 0)
date.month = -date.month;
if (date.day < 0)
date.day = -date.day;
jdz = ((double) date.year) * 360.0;
jdz += ((double) date.month) * 30.0;
jdz += ((double) date.day);
time = duration->time;
if (time.hours < 0)
time.hours = -time.hours;
if (time.minutes < 0)
time.minutes = -time.minutes;
if (time.seconds < 0)
time.seconds = -time.seconds;
frac = ((double) time.hours) / 24.0;
frac += ((double) time.minutes) / 1440.0;
frac += ((double) time.seconds) / 86400.0;
jdz += frac;
return (jdz);
}
|
|
|
|
|
|
|
|