How reliable are alarms?

Actually the Alarm API should be pretty precise (well…, to the exact minute, not second).

I needed to implement scheduler for the Night mode / Day mode (for my Darko Thunderbird addon) and it turns out the Alarm API is great for this.

To clarify:

  • if you setup alarm in the past, it will fire right away
  • if you setup future date and your PC wakes up from hibernation after the date, it will fire right after waking up
  • if you setup 8 hours from now, it will fire 8 hours from now (if your PC is on) no matter how long was your PC sleeping / hibernating in the meantime

This is the first time I’ve used this API and I have to say it’s pretty cool. Much clearer and easier than using window.setInterval and checking current date/time…

Also the permission it requires is in the Not alerted list so it can be added to existing addons.

4 Likes