|
|
|
| Listing 5.7 date_to_JD0() | |
|
|
|
|
/* date2JD0.c
+-------------------------------------------+
| Copyright (C) 1995 by Lance W. Latham. |
| All rights reserved. |
+-------------------------------------------+
Returns the Julian Day number (JD#) for a given date in the Western
(Julian and Gregorian) calendar, given as day, month and year. Returns
valid numbers for dates in both the Julian and Gregorian calendars.
Valid inputs are:
1. Julian calendar : from 01 JAN -4712 to 04 OCT 1582.
2. Gregorian calendar : from 15 OCT 1582 to 31 DEC 32767.
INPUTS:
1. d, a DATE_INFO structure containing the date. The lower year limit
is set by the definition of the Julian Day number. The upper year
limit is set by INT_MAX.
OUTPUTS:
1. Returned by routine, type double, representing the Julian Day number
for the given input date.
NOTES:
1. The algorithm is a standard Gregorian proleptic calendar conversion
routine. The earliest occurrence in the literature of a similar
routine for 'small' machines found to date is one published by
Michael Erlewine, 'Manual of Computer Programming for Astrologers',
page 40. The Erlewine code is in BASIC and the algorithm is credited
to a 'Richard C. Singleton', but no work is cited. The BASIC code
was apparently intended to operate for Julian calendar dates as well,
perhaps due to confusion regarding the proper application of proleptic
routines. Several bugs caused incorrect returns for Julian dates.
2. The fractional part returned is zero, meaning noon of the given date.
3. This routine does not validate the input date. This routine intercepts
dates from 05 OCT 1582 to 14 OCT 1582, which do not exist in the
Gregorian calendar, and sets them to the first valid date in the
Gregorian calendar, 15 OCT 1582. The last valid date in the Julian
calendar is 04 OCT 1582.
4. There are two conventions for denoting 'year' in the Western
calendar. The 'astronomical' convention uses '0' as an ordinal number,
and counts the year before A.D. 1 as A.D. 0, while the 'historical'
convention counts the year before A.D. 1 as 1 B.C.
|
|
|
|
|
|
|
|