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