Closed rkoshak closed 2 years ago
Wouldn't you use the newly added .getMillisFromNow()
when passing into a setTimeout call?
I never looked at what that function does.
It still seems a bit awkward but I guess doable. If I wanted, for example to set a timer for 13:02 it would be something like
setTimeout(() => { do something }, time.toZDT('13:02').getMillisFromNow());
It'll be a hangup for users who are migrating from one of the other rules languages but not insurmountable.
As currently implemented,
setTimeout()
only supports the use case of creating a timer based on a delta/delay from now. However, it does not support absolute scheduling of a timer based on a full DateTime (e.g. scheduling a timer based on the state of a DateTime Item or the result of some sort of calculation). Because it doesn't support this latter use case, and I'm not sure it would be a good idea to add support for passing a Joda ZDT tosetTimeout()
which would break the standard, I propose we add back documentation for how to create a native OH Timer to handle that missing use case.Otherwise, if we insist on only "officially" supporting creating timers based on a delay in milliseconds I think that's a step backwards. It forces the end users to do all sorts of calculations and time manipulations.