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