FreeBSD/contrib/ntp/libntp/ntp_calendar.c
/*
 *---------------------------------------------------------------------
 * Convert ELAPSED years/months/days of gregorian calendar to elapsed
 * days in year.
 *
 * Note: This will give the true difference to the start of the given
 * year, even if months & days are off-scale.
 *---------------------------------------------------------------------
 */
Convert ELAPSED years/months/days of gregorian calendar to elapsed
days in year.

This will give the true difference to the start of the given
year, even if months & days are off-scale.
Convert ELAPSED years / months / days of gregorian calendar to elapsed days in year . This will give the true difference to the start of the given year even if months & days are off - scale .
int32_t
ntpcal_edate_to_yeardays(
	int32_t years,
	int32_t mons,
	int32_t mdays
	)
{
	ntpcal_split tmp;
	if (0 <= mons && mons < 12) {
		years += 1;
		mdays += real_month_table[is_leapyear(years)][mons];
	} else {
		tmp = ntpcal_days_in_months(mons);
		mdays += tmp.lo
		       + ntpcal_days_in_years(years + tmp.hi)
		       - ntpcal_days_in_years(years);
	}
	return mdays;
}
int32_t ntpcal_edate_to_yeardays ( int32_t years , int32_t mons , int32_t mdays ) { ntpcal_split tmp ; if ( 0 <= mons && mons < 12 ) { years += 1 ; mdays += real_month_table [ is_leapyear ( years ) ] [ mons ] ; } else { tmp = ntpcal_days_in_months ( mons ) ; mdays += tmp . lo + ntpcal_days_in_years ( years + tmp . hi ) - ntpcal_days_in_years ( years ) ; } return mdays ; }
Convert ELAPSED years/months/days of gregorian calendar to elapsed
 days in year.
Convert ELAPSED years / months / days of gregorian calendar to elapsed days in year .