FreeBSD/contrib/ntp/libntp/ntp_calendar.c
/*
 *---------------------------------------------------------------------
 * Convert a RD into the date part of a 'struct tm'.
 *---------------------------------------------------------------------
 */
Convert a RD into the date part of a 'struct tm'.
Convert a RD into the date part of a ' struct tm ' .
int
ntpcal_rd_to_tm(
	struct tm  *utm,
	int32_t	    rd
	)
{
	ntpcal_split split;
	int	     leapy;
	utm->tm_wday = rd % DAYSPERWEEK;
	if (utm->tm_wday < 0)
		utm->tm_wday += DAYSPERWEEK;
	split = ntpcal_split_eradays(rd - 1, &leapy);
	utm->tm_year = split.hi - 1899;
	utm->tm_yday = split.lo;	
	split = ntpcal_split_yeardays(split.lo, leapy);
	utm->tm_mon  = split.hi;	
	utm->tm_mday = split.lo + 1;	
	return leapy;
}
int ntpcal_rd_to_tm ( struct tm * utm , int32_t rd ) { ntpcal_split split ; int leapy ; utm -> tm_wday = rd % DAYSPERWEEK ; if ( utm -> tm_wday < 0 ) utm -> tm_wday += DAYSPERWEEK ; split = ntpcal_split_eradays ( rd - 1 , & leapy ) ; utm -> tm_year = split . hi - 1899 ; utm -> tm_yday = split . lo ; split = ntpcal_split_yeardays ( split . lo , leapy ) ; utm -> tm_mon = split . hi ; utm -> tm_mday = split . lo + 1 ; return leapy ; }
Convert a RD into the date part of a 'struct tm'.
Convert a RD into the date part of a ' struct tm ' .
/* get day-of-week first */ /* get year and day-of-year */ /* 0-based */ /* convert to month and mday */ /* 0-based */ /* 1-based */