Calculate the day number of the year
JavaScript ES6, 81 69 bytes
(y,m,d)=>d+parseInt("03479cehkmpr"[--m],36)+m*28-(y%(y%25?4:16)&&m>1)
Assuming months are 1-based, otherwise I could save 2 bytes.
Edit: Saved 12 bytes using @user81655's tip.
C, 96 102 89 61 bytes
g(y,m,d){printf("%d",m/2*31+--m/2*30-(y%(y%25?4:16)?2:1)+d);}
Pyth, 31 bytes
+s<X1+L28jC"3Ȕ"4!%|F_jQ*TT4tEE
Thanks to @Dennis and @Jakube for the leap year portion. Input is YYYY, MM, DD on separate lines.
+ add [day] to
s < sum of first [month]-1 values in the list
X add 1 to
1 the second element (January)...
+L \
28 |
j } lengths of all the months
C "3Ȕ" |
4 /
! % ... if the year is a leap year; that is, 4 divides...
|F _ j fold logical OR over reversed
Q the year
*TT converted to base 100
4
t E [month]-1
E [day]
Test suite.