Elapsed time?
in
Programming Questions
•
1 year ago
long walkTime0, walkTime1, walkTime01;
...
walkTime0=second()+60*(minute()+60*(hour()+24*day()));
...
walkTime1=second()+60*(minute()+60*(hour()+24*day()));
walkTime01=walkTime1-walkTime0;
walkTime1=second()+60*(minute()+60*(hour()+24*day()));
walkTime01=walkTime1-walkTime0;
...
Those instructions give me the elapsed time in seconds from event0 till event1.
But if the month or year change in the meantime, it won't work.
I can't add similar extra terms cause different months or years have different length.
Also I can't use millis() cause it's an integer that will overflow for long runtime.
How should I proceed from here?
All I need is the number of seconds between 2 events in my program.
I thought my code was doing this correctly, but it doesn't.
1