|
|
|
| Listing 7.2 JD0_to_julian_proleptic () | |
|
|
|
|
/* JD02julp.c
+-------------------------------------------+
| Copyright (C) 1995 by Lance W. Latham. |
| All rights reserved. |
+-------------------------------------------+
Routine converts a Julian Day number, expressed as a type double,
into the corresponding Julian proleptic calendar date.
INPUTS:
1. jd, type double, the Julian Day number. Valid values are
'jd' >= 0.
OUTPUTS:
1. Returned by routine, a DATE_INFO structure, containing the proleptic
Julian date corresponding to the input Julian Day number.
NOTES:
1. This routine can be used to convert JD0 numbers into their
corresponding proleptic Julian dates.
2. This conversion does not allow a Julian Day number to be converted to
an 'Old Style' (O.S.) date.
3. This routine intercepts values of 'jd' less than 0, and sets
them to their corresponding absolute value. No warning is issued
in this case, and no other validation is performed.
4. The two auxiliary routines return the month and day for the first
year (the leap year), and the second through fourth years (the
common years). This order is dictated by the fact that the year
-4712 defines the starting point for the Julian Day number, and
is itself a leap year, by the Julian calendar rule.
5. The limitations of 'type int' determine the actual maximum input
value for 'jd'. In the case where the integer is limited to 16
bits, 'yl' cannot be greater than 32767, which limits 'ql' to
9369, which limits 'jdl', and hence, 'jd' to 13,688,109.0 . This
is not a limitation in any practical application.
*/
#include "scdtl_6.h"
struct DATE_INFO JD0_to_julian_proleptic (double jd)
{
int y, r;
long jdl, ql, yl;
struct DATE_INFO jdate;
struct DATE_INFO j2jp_aux_1 (int r);
struct DATE_INFO j2jp_aux_2 (int r);
jdl = (long) jd;
if (jdl < 0L)
jdl = -jdl;
|
|
|
|
|
|
|
|