ITADN

[sched] Setting an alarm for an earlier time of day makes the alarm fire immediately.

#4232Openthyttan 创建于 2026-05-25
T
thyttancommented
### Affected hardware version Bangle 2 ### Your firmware version 2v29.75 ### The bug Setting an alarm using the sheduling library, for a time that already passed today makes the alarm fire immediately. I am not sure if this is actually a bug. It may be the intended behavior. My expectation would have been for the alarm to fire at the set time the next day instead. Setting an alarm at such a time through the alarms app does indeed set the alarm for the next day instead. I am unsure of how this is achieved. Here're the lines responsible for the behavior: https://github.com/espruino/BangleApps/blob/b9038c87970ed833695e60d2475701aa8e774eed/apps/sched/boot.js#L19-L21 Here's a diff with a fix: https://github.com/espruino/BangleApps/compare/master...thyttan:sched?expand=1 However that fix seems to go against recent changes to fix other bugs in issues #2712, #4220. I wonder if you @ticalc-travis have any immediate thoughts regarding this since you seem to have thought about the scheduling library quite a bit not that long ago. ### Reproduce Use the Web IDE to upload the following script to RAM. ```js { S = require("sched"); const TIME_AT_NEXT_BUZZ = 10 * 1000; //10 seconds after midnight. S.setAlarm("test", { on: true, t: TIME_AT_NEXT_BUZZ, //dow: 0b1111111, // all days of the week. //last: Date().getDate(), // Don't fire until tomorrow. }); S.reload(); } ``` ### Background I'm working on making the `twenties` app use the scheduling library instead of setting it's own timeouts. Draft PR at #4231. That's when I happened upon this behavior. Notably I set and make use of the `.js` attribute when scheduling the alarm.
1 条评论