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