|
|
|
| Listing 8.4 | |
|
|
|
|
rem = long_mod (jdl, 360L);
ml = rem / 30L;
dl = long_mod (rem, 30L);
dur.date.year = (int) yl;
dur.date.month = (int) ml;
dur.date.day = (int) dl;
if (dur.time.hours >= 24)
{
dur.time.hours = 0;
dur.date.day++;
}
if (dur.date.day >= 30)
{
dur.date.day = 0;
dur.date.month++;
}
if (dur.date.month >= 12)
{
dur.date.month = 0;
if (dur.date.year != INT_MAX)
dur.date.year++;
}
return (dur);
}
|
|
|
|
|
|
|
| Listing 8.5 iso_date_time_to_double () | |
|
|
|
|
/* idt2dbl.c
+-------------------------------------------+
| Copyright (C) 1995 by Lance W. Latham. |
| All rights reserved. |
+-------------------------------------------+
Routine converts a date and time, combined as an ISO_DATE_TIME
structure, to a type double.
INPUTS:
1. dt, pointer to an ISO_DATE_TIME structure containing the date
as a DATE_INFO structure (year, month and day) and the time as a
TIME_INFO structure (hours, minutes and seconds).
OUTPUTS:
1. Returned by routine, type double, assumed to be a Julian Day number.
NOTES:
1. This routine converts a date and time to its equivalent Julian Day
number. To convert a duration of elapsed time into a difference
between two Julian day numbers, expressed as a type double, use
the ISO_DURATION structure and the routine 'iso_duration_to_double ()'.
*/
|
|
|
|
|
|
|
|