odometer:
Just use one of your "YMD to straight days" functions on each of the two dates, and then subtract.
Yes, using the "Julian Day Number" for getting the difference would be a good solution.
Makes the programming logic simple.
Here is a code providing a Julian Day function as well as functions calculating the number of days between dates and the number of minutes between time stamps that are accurate to one minute.
Example sketch:
long JD(int year, int month, int day)
{ // COMPUTES THE JULIAN DATE (JD) GIVEN A GREGORIAN CALENDAR
return day-32075+1461L*(year+4800+(month-14)/12)/4+367*(month-2-(month-14)/12*12)/12-3*((year+4900+(month-14)/12)/100)/4;
}
long daysDiff(int year1, int mon1, int day1, int year2, int mon2, int day2)
{
return JD(year2, mon2, day2) - JD(year1, mon1, day1);
}
long minutesDiff(int year1, int mon1, int day1, int hour1, int min1, int year2, int mon2, int day2, int hour2, int min2 )
{
int mDiff= (hour2*60+min2) - (hour1*60+min1);
return daysDiff(year1, mon1, day1, year2, mon2, day2)*1440 + mDiff;
}
void setup()
{
Serial.begin(9600);
long x= minutesDiff(2015,12,24,23,59, 2017,1,1,0,0 );
Serial.println(x);
x= minutesDiff(2015,12,31,0,1, 2016,1,1,0,1);
Serial.println(x);
x=minutesDiff(2016,2,28,23,59, 2016,3,1,0,0 );
Serial.println(x);
x=minutesDiff(2016,12,31,23,59, 2017,1,1,0,0);
Serial.println(x);
x=minutesDiff(2017,2,28,23,59, 2017,3,1,0,0 );
Serial.println(x);
}
void loop()
{
}