1 /*
2 * ymd2yd - compute the date in the year from y/m/d
3 *
4 * A thin wrapper around a more general calendar function.
5 */
6
7 #include <config.h>
8 #include "ntp_stdlib.h"
9 #include "ntp_calendar.h"
10
11 int
ymd2yd(int y,int m,int d)12 ymd2yd(
13 int y,
14 int m,
15 int d)
16 {
17 /*
18 * convert y/m/d to elapsed calendar units, convert that to
19 * elapsed days since the start of the given year and convert
20 * back to unity-based day in year.
21 *
22 * This does no further error checking, since the underlying
23 * function is assumed to work out how to handle the data.
24 */
25 return ntpcal_edate_to_yeardays(y-1, m-1, d-1) + 1;
26 }
27