smoke timer calculation crashes on start due to not understanding datetime
nilsbenson opened this issue · comments
The timer calculation currently only uses time, not a full date/time.
Look at using the functionality in Toybox::Time (Duration, Moment, etc) for date/time calculations. We should store the full UTC date time to app settings/properties and use the full UTC date/time when calculating how long it's been since the app went to sleep. This way we always work correctly when daylight savings time happens and it won't matter how long the app has been sleeping we'll have the full date(s) to work with.
actually, this crash was due to not cleaning and rebuilding the project after pulling changes. however, I do think we should probably use full date/time and the built-in time stuff. Imagine smoking overnight, once the date changes the times will still be messed up.
Yes, the overnight behavior is something I had not considered. Good point. Will work on this today.
The API objects for date/time should make it easier. We just need to make sure we are using UTC so that when daylight savings time changes, or the user changes time zones (not likely but if you're in el paso it could happen) the time calculation stays correct.
I pushed the time calculation using the Time objects. Basically I'm persisting a Moment on app exit. On the app start I recover it, create the current time as a Moment. Then do a diff of the two in UNIX time. The diff is the sleep duration.
We can probably comment this out for the upcoming release since we're not using it.
go ahead and comment it out for now - I just branched off development for low-n-slow which will be for the smoking stuff. We'll continue testing this week and merging any bug fixes from dev into it and release dev at the end of the week if it looks good?
Let's do it