Loading...
Searching...
No Matches
beats.h
Go to the documentation of this file.
1
8#pragma once
9#include <stdbool.h>
10#include <stdint.h>
11
12// shared time constants for the .beats clock and the BMT conversion
13#define MS_PER_BEAT 86400
14#define MS_PER_DAY 86400000
15#define MS_PER_SEC 1000
16#define SECS_PER_DAY 86400
17#define SECS_PER_HOUR 3600
18#define SECS_PER_MIN 60
19#define BMT_UTC_OFFSET_S 3600
20
31#define BEATS_TOKEN "{B}"
32#define BEATS_TOKEN_LEN 3
33
38
45int beats_from_ms(int32_t ms_into_bmt_day);
46
56uint32_t ms_until_next_beat(int32_t ms_into_bmt_day);
57
75int32_t beats_ms_from_hms(int hour, int minute, int second, uint16_t ms);
76
87bool beats_has_token(const char *format);
88
99void beats_expand_token(char *text, int beats);
100
void beats_expand_token(char *text, int beats)
Overwrite every BEATS_TOKEN in a string with a three digit .beats reading.
Definition beats.c:73
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.
Definition beats.c:37
int beats_from_ms(int32_t ms_into_bmt_day)
Calculates swatch internet time in .beats (0..999) for a given ms.
Definition beats.c:12
uint32_t ms_until_next_beat(int32_t ms_into_bmt_day)
Calculates milliseconds until the next .beats boundary.
Definition beats.c:22
bool beats_has_token(const char *format)
Whether a date format asks for a .beats reading.
Definition beats.c:68