1*cdfa2a7eSchristos /* $NetBSD: ymd2yd.c,v 1.5 2020/05/25 20:47:25 christos Exp $ */ 2abb0f93cSkardel 3abb0f93cSkardel /* 4abb0f93cSkardel * ymd2yd - compute the date in the year from y/m/d 58585484eSchristos * 68585484eSchristos * A thin wrapper around a more general calendar function. 7abb0f93cSkardel */ 8abb0f93cSkardel 98585484eSchristos #include <config.h> 10abb0f93cSkardel #include "ntp_stdlib.h" 118585484eSchristos #include "ntp_calendar.h" 12abb0f93cSkardel 13abb0f93cSkardel int ymd2yd(int y,int m,int d)14abb0f93cSkardelymd2yd( 15abb0f93cSkardel int y, 16abb0f93cSkardel int m, 178585484eSchristos int d) 18abb0f93cSkardel { 198585484eSchristos /* 208585484eSchristos * convert y/m/d to elapsed calendar units, convert that to 218585484eSchristos * elapsed days since the start of the given year and convert 228585484eSchristos * back to unity-based day in year. 238585484eSchristos * 248585484eSchristos * This does no further error checking, since the underlying 258585484eSchristos * function is assumed to work out how to handle the data. 268585484eSchristos */ 278585484eSchristos return ntpcal_edate_to_yeardays(y-1, m-1, d-1) + 1; 28abb0f93cSkardel } 29