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; }
/* 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; }