I guess I have no choice.
I will use your code to transform my one-line formula into a one-line call of a longer function.
I can't use millis() cause it returns an integer (a maximum value of 2,147,483,647),
so it will overflow in 24.8551348 days.
1000 ms/s * 60 sec/min * 60 min/hr * 24 hr/day = 86,400,000 ms/day
1000 ms/s * 60 sec/min * 60 min/hr * 24 hr/day * 365 days/year = 31,536,000,000 ms/year
Using your code as an improvement over my first code, I now have
- long walkTime0, walkTime1, walkTime01;
- ...
- walkTime0second()+60*(minute()+60*(hour()+24*(long)dayOfYear()));
- ...
walkTime1second()+60*(minute()+60*(hour()+24*(long)dayOfYear())); - walkTime01=walkTime1-walkTime0;
- ...
- int dayOfYear() {
int days=day();
int m=month()-1;
switch(m) {
case 11:
days += 30;
case 10:
days += 31;
case 9:
days += 30;
case 8:
days += 31;
case 7:
days += 31;
case 6:
days += 30;
case 5:
days += 31;
case 4:
days += 30;
case 3:
days += 31;
case 2:
if ( year() % 4 == 0 ) {
days += 29;
}
else {
days += 28;
}
case 1:
days += 31;
}//switch(m)
return days;
}//dayOfYear()
With this version, if the month changes in the meantime it will still work.
But if the year change in the meantime, it won't work.
I'll add yearOfMillenium to correct it later.