154359Sroberto/*
254359Sroberto * ymd2yd - compute the date in the year from y/m/d
3285612Sdelphij *
4285612Sdelphij * A thin wrapper around a more general calendar function.
554359Sroberto */
654359Sroberto
7285612Sdelphij#include <config.h>
854359Sroberto#include "ntp_stdlib.h"
9285612Sdelphij#include "ntp_calendar.h"
1054359Sroberto
1154359Srobertoint
1254359Srobertoymd2yd(
1354359Sroberto	int y,
1454359Sroberto	int m,
15285612Sdelphij	int d)
1654359Sroberto{
17285612Sdelphij	/*
18285612Sdelphij	 * convert y/m/d to elapsed calendar units, convert that to
19285612Sdelphij	 * elapsed days since the start of the given year and convert
20285612Sdelphij	 * back to unity-based day in year.
21285612Sdelphij	 *
22285612Sdelphij	 * This does no further error checking, since the underlying
23285612Sdelphij	 * function is assumed to work out how to handle the data.
24285612Sdelphij	 */
25285612Sdelphij	return ntpcal_edate_to_yeardays(y-1, m-1, d-1) + 1;
2654359Sroberto}
27