]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/ntp/libntp/caljulian.c
Upgrade NTP to 4.2.8p4.
[FreeBSD/releng/10.2.git] / contrib / ntp / libntp / caljulian.c
1 /*
2  * caljulian - determine the Julian date from an NTP time.
3  *
4  * (Note: since we use the GREGORIAN calendar, this should be renamed to
5  * 'calgregorian' eventually...)
6  */
7 #include <config.h>
8 #include <sys/types.h>
9
10 #include "ntp_types.h"
11 #include "ntp_calendar.h"
12
13 #if !(defined(ISC_CHECK_ALL) || defined(ISC_CHECK_NONE) || \
14       defined(ISC_CHECK_ENSURE) || defined(ISC_CHECK_INSIST) || \
15       defined(ISC_CHECK_INVARIANT))
16 # define ISC_CHECK_ALL
17 #endif
18
19 #include "ntp_assert.h"
20
21 void
22 caljulian(
23         uint32_t                ntp,
24         struct calendar *       jt
25         )
26 {
27         vint64          vlong;
28         ntpcal_split    split;
29         
30         
31         INSIST(NULL != jt);
32
33         /*
34          * Unfold ntp time around current time into NTP domain. Split
35          * into days and seconds, shift days into CE domain and
36          * process the parts.
37          */
38         vlong = ntpcal_ntp_to_ntp(ntp, NULL);
39         split = ntpcal_daysplit(&vlong);
40         ntpcal_daysplit_to_date(jt, &split, DAY_NTP_STARTS);
41 }