Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Feb 21, 2005 6:36 pm |
|
|
You will have to test it
Code: |
/* Function JulianToGregorian. Takes 4 arguments: Julian day number, */
/* and dd, mm, and yyyy for a Gregorian date. Function calculates */
/* Gregorian date corresponding to JDN and stores it in dd, mm, yyyy */
/* Note: this function makes use of a widely-published algorithm. */
/* Unfortunately, it seems to have been optimsed for efficiency */
/* rather than for comprehensibility. There's a lesson here: */
/* if you don't need to understand something, don't. */
void JulianToGregorian (int32 jd, int16 * dd, int16 * mm, int16 * yyyy)
{
int32 temp,
i,
n,
j ;
temp = jd + 68569 ;
n = (4 * temp) / 146097 ;
temp = temp - (146097 * n + 3) / 4 ;
i = (4000 * (temp + 1)) / 1461001 ;
temp = temp - (1461 * i) / 4 + 31 ;
j = (80 * temp) / 2447 ;
*dd = temp - (2447 * j) / 80 ;
temp = j / 11 ;
*mm = j + 2 - (12 * temp) ;
*yyyy = 100 * (n - 49) + i + temp ;
}
|
|
|