Sync usage with man page.
[netbsd-mini2440.git] / dist / ntp / libntp / caltontp.c
blob68b21ade2a30abe4fea435f0cfb03d1b4cbe39ff
1 /* $NetBSD$ */
3 /*
4 * caltontp - convert a date to an NTP time
5 */
6 #include <sys/types.h>
8 #include "ntp_types.h"
9 #include "ntp_calendar.h"
10 #include "ntp_stdlib.h"
12 u_long
13 caltontp(
14 register const struct calendar *jt
17 u_long ace_days; /* absolute Christian Era days */
18 u_long ntp_days;
19 int prior_years;
20 u_long ntp_time;
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;
38 * Do the obvious:
40 ntp_time =
41 ntp_days*SECSPERDAY+SECSPERMIN*(MINSPERHR*jt->hour + jt->minute);
43 return ntp_time;