< previous page page_98 next page >

Page 98
Listing 5.10 JD_date_part()
/* jddtpart.c
   +-------------------------------------------+
   |   Copyright (C) 1995 by Lance W. Latham.  |
   |         All rights reserved.              |
   +-------------------------------------------+


   Returns the 'date' portion of a Julian Day number expressed as a type
   double. The fractional part returned is zero, indicating noon.


   INPUTS:
   1. jd, type double, the 'raw' Julian Day number with (possibly)
   non-zero fractional part, indicating that a time of day (other than
   noon) may be carried.


   OUTPUTS:
   1. Returned by routine, type double, the 'JD0', or Julian Day number
      for the date, with fractional part of zero, indicating noon.


   NOTES:
   1. The Julian Day starts at noon. A fractional part of zero indicates
      noon of the indicated day. Therefore, for a given day N, a JD number
      of N.0 indicates noon, (N-1).5 indicates midnight, and N.5 indicates
      midnight of the following day, (N+1).


      E.g., 100.0 is noon of JD 100, 99.5 is midnight, 99.75 is 6 a.m.,
      and 100.25 is 6 p.m. This function returns '100.0' for all of these
      values.


   2. Use function 'JD_time_part ()' to obtain the fractional displacement
      value for the time of day represented in the JD number.
*/


double JD_date_part (double jd)
{
   double frac, JD0;
   long jdl;


   jdl = (long) jd;
   JD0 = (double) jdl;
   frac = jd - JD0;


   if (frac >= 0.5)
      JD0 += 1.0;


   return (JD0);
}

 
< previous page page_98 next page >