freebsd-dev/contrib/ntp/libntp/caljulian.c

42 lines
891 B
C
Raw Normal View History

1999-12-09 13:01:21 +00:00
/*
* caljulian - determine the Julian date from an NTP time.
*
* (Note: since we use the GREGORIAN calendar, this should be renamed to
* 'calgregorian' eventually...)
1999-12-09 13:01:21 +00:00
*/
#include <config.h>
1999-12-09 13:01:21 +00:00
#include <sys/types.h>
#include "ntp_types.h"
#include "ntp_calendar.h"
#if !(defined(ISC_CHECK_ALL) || defined(ISC_CHECK_NONE) || \
defined(ISC_CHECK_ENSURE) || defined(ISC_CHECK_INSIST) || \
defined(ISC_CHECK_INVARIANT))
# define ISC_CHECK_ALL
#endif
#include "ntp_assert.h"
1999-12-09 13:01:21 +00:00
void
caljulian(
uint32_t ntp,
struct calendar * jt
1999-12-09 13:01:21 +00:00
)
{
vint64 vlong;
ntpcal_split split;
2015-10-21 19:16:13 +00:00
INSIST(NULL != jt);
1999-12-09 13:01:21 +00:00
/*
* Unfold ntp time around current time into NTP domain. Split
* into days and seconds, shift days into CE domain and
* process the parts.
1999-12-09 13:01:21 +00:00
*/
vlong = ntpcal_ntp_to_ntp(ntp, NULL);
split = ntpcal_daysplit(&vlong);
ntpcal_daysplit_to_date(jt, &split, DAY_NTP_STARTS);
}