star-cem

Compute the position of the sun
git clone git://git.meso-star.fr/star-cem.git
Log | Files | Refs | README | LICENSE

commit 450b65536509b53738bde76bab0cca845756a721
parent a325dba13f4afdcb5707263faee14111626d943a
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed,  8 Oct 2025 12:46:48 +0200

Fix of the Julian date calculation in the Meeus algorithm

It now gives the same result as its PSA variant.

Diffstat:
Msrc/scem_meeus.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/scem_meeus.c b/src/scem_meeus.c @@ -39,10 +39,10 @@ julian_day(const struct tm* time) /* In UTC */ + (double)time->tm_hour/24.0 + (double)time->tm_min/1440.0 + (double)time->tm_sec/86400.0; - m = time->tm_mon + 1; /* The months start at 0 */ + m = time->tm_mon + 1; /* tm_mon start at 0 */ y = time->tm_year + 1900; /* tm_year is relative to year 1900 (see tm(3type)) */ - if((unsigned)time->tm_mon < 3) { + if(m < 3) { y -= 1; m += 12; } @@ -51,7 +51,7 @@ julian_day(const struct tm* time) /* In UTC */ b = 2 - a + a/4; /* Found in "Astronomical Algorithms" by Jean Meeus */ - jd = (int)(365.25 * (double)(y+4715)) + jd = (int)(365.25 * (double)(y+4716)) + (int)(30.6001 * (double)(m+1)) + d + b - 1524.5;