4 * caltontp - convert a date to an NTP time
9 #include "ntp_calendar.h"
10 #include "ntp_stdlib.h"
14 register const struct calendar
*jt
17 u_long ace_days
; /* absolute Christian Era days */
23 * First convert today's date to absolute days past 12/1/1 BC
25 prior_years
= jt
->year
-1;
26 ace_days
= jt
->yearday
/* days this year */
27 +(DAYSPERYEAR
*prior_years
) /* plus days in previous years */
28 +(prior_years
/4) /* plus prior years's leap days */
29 -(prior_years
/100) /* minus leapless century years */
30 +(prior_years
/400); /* plus leapful Gregorian yrs */
33 * Subtract out 1/1/1900, the beginning of the NTP epoch
35 ntp_days
= ace_days
- DAY_NTP_STARTS
;
41 ntp_days
*SECSPERDAY
+SECSPERMIN
*(MINSPERHR
*jt
->hour
+ jt
->minute
);