예제 #1
0
파일: clocktime.c 프로젝트: 2asoft/freebsd
static u_int32
year_to_ntp(
	int32 year)
{
	u_int32 days;
	days = ntpcal_days_in_years(year-1) - DAY_NTP_STARTS + 1;
	return days * SECSPERDAY;
}
예제 #2
0
/* helper / reference implementation for the first week of year in the
 * ISO8601 week calendar. This is based on the reference definition of
 * the ISO week calendar start: The Monday closest to January,1st of the
 * corresponding year in the Gregorian calendar.
 */
static int32_t
refimpl_WeeksInIsoYears(
	int32_t years)
{
	int32_t days, weeks;

	days = ntpcal_weekday_close(
		ntpcal_days_in_years(years) + 1,
		CAL_MONDAY) - 1;
	/* the weekday functions operate on RDN, while we want elapsed
	 * units here -- we have to add / sub 1 in the midlle / at the
	 * end of the operation that gets us the first day of the ISO
	 * week calendar day.
	 */
	weeks = days / 7;
	days  = days % 7;
	TEST_ASSERT_EQUAL(0, days); /* paranoia check... */

	return weeks;
}