Hi!
Using adafruit's RTCLib, I am making an alarm.
To do this, I set my alarm, then display "alarm-rtc.now()"
First issue:
There is not DateTime minus operator defined. I would add my own, but I've never written an operator definition.
To fix this, I instead use "alarm-TimeSpan(rtc.now().unixtime())." This, however, returns a MASSIVE number.
For "Apr 4th, 2017, 2:30:00" minus "Apr 4th, 2017, 2:32:00" I get "Apr 21, 2106, 6:00:00"
This is, as is obvious, very incorrect!
Any help?
Thanks!
With 69 posts, you should have learned by now to POST YOUR CODE, using code tags.
1 Like
Hey, I gave you all the code you needed 
My code is massive - more than just an alarm, actually - rather an OS. 16 files, 30-100 lines each, as such, it wouldn't be worthwhile to post (or easy to sift through and find the relevant parts).
--Back on topic!
--
I realize now this is kind of an abuse of the DateTime and TimeSpan functions. I think the correct way to do this is:
uint32_t diff=alarm.unixtime()-rtc.now().unixtime();
byte sec=diff%60;
byte min=(diff/60)%60;//Relying on integer dividing to floor this!
byte hr=diff/3600;//Relying on integer dividing to floor this!
Edit: fixed a derp in code
Hey, I gave you all the code you needed 
Ahh, how silly of me! You don't know what causes the problem, but you do know how much information we will need to fix it for you.