I agree, us anon's example, or some other library function that does date/time calculations.
Have you tested this for all sorts of arbitrary calculations of short and long date intervals, gapping over leap years and non-leapyears, etc, etc.
By the way, there's a bunch of duplication in your code. The first thing I would do is to convert your common for first and second year calculation into one function:
I removed a bunch of "int()" since the calculation itself is done completely in integer in the first place, it doesn't need to be "int()" around it - it's already done automagically by the compiler (or rather the processor - but by the compiler choosing integer math operations).
int dayNo(int y, int m, int d)
int yoff = 0;
int moff = 1;
int fy, sy;
if (m == 1 || m == 2)
yoff = 1;
moff = 13;
fy = (y - 1) / 100;
sy = 2 - fy + (fy / 4);
return int(365.25*(y - yoff)+int(30.6001*(m+moff)) + sy + d = 1720995;
I also used a few local variables to avoid having an almost identical calculation twice. It makes it easier to read the code, and it's easier to change ONE long complicated calculation than to do two different calculations.
Using this function makes it much easier to produce the days funciton:
int days (int yer2,int yer1,int mnth2,int mnth1,int day1,int day2)
int theyer1 = dayNo(yer1, mnth1, day1);
int theyer2 = dayNo(yer2, mnth2, day2);
I'm also dubious to the code in red below: