Initial import from FreeBSD RELENG_4:
[games.git] / contrib / ntp / libntp / gpstolfp.c
1 /*
2  * /src/NTP/ntp-4/libntp/gpstolfp.c,v 4.3 1999/02/28 11:42:44 kardel RELEASE_19990228_A
3  *
4  * $Created: Sun Jun 28 16:30:38 1998 $
5  *
6  * Copyright (C) 1998 by Frank Kardel
7  */
8 #include "ntp_fp.h"
9
10 #define GPSORIGIN       ULONG_CONST(2524953600) /* NTP origin - GPS origin in seconds */
11 #define SECSPERWEEK     (unsigned)(604800)      /* seconds per week - GPS tells us about weeks */
12 #define GPSWRAP         990     /* assume week count less than this in the previous epoch */
13
14 void
15 gpstolfp(
16          int weeks,
17          int days,
18          unsigned long  seconds,
19          l_fp * lfp
20          )
21 {
22   if (weeks < GPSWRAP)
23     {
24       weeks += 1024;
25     }
26
27   lfp->l_ui = weeks * SECSPERWEEK + days * 86400 + seconds + GPSORIGIN; /* convert to NTP time */
28   lfp->l_uf = 0;
29 }
30
31 /*
32  * gpstolfp.c,v
33  * Revision 4.3  1999/02/28 11:42:44  kardel
34  * (GPSWRAP): update GPS rollover to 990 weeks
35  *
36  * Revision 4.2  1998/07/11 10:05:25  kardel
37  * Release 4.0.73d reconcilation
38  *
39  * Revision 4.1  1998/06/28 16:47:15  kardel
40  * added gpstolfp() function
41  */