# How reliable are alarms?

**URL:** <https://discourse.mozilla.org/t/how-reliable-are-alarms/40978>\
**Category:** Development\
**Created:** [May 30, 2019, 5:20pm UTC](https://discourse.mozilla.org/t/how-reliable-are-alarms/40978 "2019-05-30T17:20:44Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![juraj.masiar](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/juraj.masiar/32/30587_2.png) [@juraj.masiar](https://discourse.mozilla.org/u/juraj.masiar)\
**Post date:** [November 14, 2020, 6:42pm UTC](https://discourse.mozilla.org/t/how-reliable-are-alarms/40978/8 "2020-11-14T18:42:33Z")

</div>

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](https://addons.thunderbird.net/addon/darko_t/) 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](https://extensionworkshop.com/documentation/develop/request-the-right-permissions/#advised-permissions) list so it can be added to existing addons.

---

_[View the full topic](https://discourse.mozilla.org/t/how-reliable-are-alarms/40978)._
