Pure swatch .beats math, operates on ms since Biel Mean Time (UTC+1) midnight. Also holds the token a date format uses to ask for a .beats reading. More...
#include <stdbool.h>#include <stdint.h>Go to the source code of this file.
Macros | |
| #define | MS_PER_BEAT 86400 |
| Milliseconds in one .beat which is one thousandth of a day. | |
| #define | MS_PER_DAY 86400000 |
| Milliseconds in a full day. | |
| #define | MS_PER_SEC 1000 |
| Milliseconds in one second. | |
| #define | SECS_PER_DAY 86400 |
| Seconds in a full day. | |
| #define | SECS_PER_HOUR 3600 |
| Seconds in one hour. | |
| #define | SECS_PER_MIN 60 |
| Seconds in one minute. | |
| #define | BMT_UTC_OFFSET_S 3600 |
| Biel Mean Time is UTC plus 1 hour, in seconds. | |
| #define | BEATS_TOKEN "{B}" |
| The marker a date format carries where a .beats reading should go. | |
| #define | BEATS_TOKEN_LEN 3 |
| Length of BEATS_TOKEN, which matches a three digit reading. | |
Functions | |
| int | beats_from_ms (int32_t ms_into_bmt_day) |
| Calculates swatch internet time in .beats (0..999) for a given ms. | |
| uint32_t | ms_until_next_beat (int32_t ms_into_bmt_day) |
| Calculates milliseconds until the next .beats boundary. | |
| int32_t | beats_ms_from_hms (int hour, int minute, int second, uint16_t ms) |
| Milliseconds into the Biel Mean Time day, from a UTC wall clock. | |
| bool | beats_has_token (const char *format) |
| Whether a date format asks for a .beats reading. | |
| void | beats_expand_token (char *text, int beats) |
| Overwrite every BEATS_TOKEN in a string with a three digit .beats reading. | |
Pure swatch .beats math, operates on ms since Biel Mean Time (UTC+1) midnight. Also holds the token a date format uses to ask for a .beats reading.
| #define BEATS_TOKEN "{B}" |
The marker a date format carries where a .beats reading should go.
Braces rather than a percent, because the date format is handed to strftime first and every percent belongs to it (B is already the month name). strftime copies anything else through untouched, so the token survives the pass and can be filled in afterwards.
Three characters wide on purpose. A reading is always three digits, so swapping one for the other is a same-length overwrite that cannot grow the string past the buffer it arrived in.