Host C Specs


Directory: src/c/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 4 / 0 / 4
Functions: 100.0% 1 / 0 / 1
Branches: -% 0 / 0 / 0

core/clock/astro.c
Line Branch Exec Source
1 /**
2 * @file astro.c
3 * @brief Pure astronomy math, host-testable off-device.
4 *
5 * @ingroup lib_core
6 */
7 #include "clock/astro.h"
8
9 2 int32_t astro_jd_centi(time_t utc)
10 {
11 // JD = 2440587.5 + utc/86400. split the seconds into whole days and the leftover so the
12 // multiply stays in 32 bits. the .5 is already baked into 244058750
13 2 long q = (long)utc / 86400;
14 2 long r = (long)utc % 86400;
15 2 return (int32_t)(244058750L + q * 100 + (r * 100) / 86400);
16 }
17