JD ymd2jd(YMD ymd) { JD jd; int m, y; y = ymdGetYear(ymd); m = ymdGetMonth(ymd); /* normalize the month */ if (m < 1) { y -= (1 - m) / 12; m = (m % 12) + 12; } if (m > 12) { y += (m - 1) / 12; m = ((m - 1) % 12) + 1; } jdSetDay(jd, gcal2j(y, m, 0)); jdIncDay(jd, ymdGetDay(ymd)); /* now the fractional day... */ jd.hms = ymd.hms; /* julian days start 12 hours after civil days */ jdDecHours(jd, 12.0); return(jd); }
double ymd2dd(YMD ymd) { double dd; double j0; double j; /* normalize the time */ ymd = ymd2ymd(ymd); /* get the julian day number of the target date */ j = ymd2j(ymd); /* get the julian day number of the start of the year */ j0 = gcal2j(ymdGetYear(ymd), 1, 1) - 0.5; dd = j - j0 + 1; return(dd); }