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