Loading...
Searching...
No Matches
hour_latch.h File Reference

Decides when an hourly buzz fires, so it fires once for each real hour. More...

#include <stdbool.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  HourLatch
 Remembers the hour that last buzzed. More...

Macros

#define HOUR_LATCH_EMPTY   {.last_start = -1}
 a latch that has not buzzed yet

Functions

time_t hour_latch_start (time_t now, int tm_min, int tm_sec)
 When the local hour holding a moment began, as seconds since the epoch.
bool hour_latch_take (HourLatch *latch, int tick_min, time_t start)
 Whether a tick should buzz the hour, and if so, marks the hour as buzzed.
void hour_latch_seed (HourLatch *latch, time_t start)
 Marks an hour as buzzed without buzzing it.

Detailed Description

Decides when an hourly buzz fires, so it fires once for each real hour.

More than one ticker can run inside minute 0, such as the minute tick and the .beats timer, and each would buzz without a latch. The latch remembers when the hour that last buzzed began, as seconds since the epoch, rather than its hour number. Two different real hours never share a start, so the hour the clocks repeat when they fall back still gets its buzz.