1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

ztimer/periph_rtc: intialize struct tm to avoid TZ and IDST problems

{ .elem = 0 }  initializes the complete struct to 0
{} is not ISO C conform
This commit is contained in:
Karl Fessel 2021-04-01 15:24:52 +02:00
parent 15f2d0008a
commit 3f66735bde

View File

@ -46,7 +46,7 @@ static uint32_t _gmt_civil_to_timestamp(unsigned y, unsigned m, unsigned d,
719561) * 86400 + 3600 * h + 60 * mi + s;
}
void _timestamp_to_gmt_civil(struct tm *_tm, uint32_t epoch)
static void _timestamp_to_gmt_civil(struct tm *_tm, uint32_t epoch)
{
uint32_t s = epoch % 86400;
@ -88,7 +88,7 @@ static uint32_t _ztimer_periph_rtc_now(ztimer_clock_t *clock)
{
(void)clock;
struct tm time;
struct tm time = { .tm_year = 0 };
rtc_get_time(&time);
@ -110,7 +110,7 @@ static void _ztimer_periph_rtc_set(ztimer_clock_t *clock, uint32_t val)
target = now + val;
struct tm _tm;
struct tm _tm = { .tm_year = 0 };
_timestamp_to_gmt_civil(&_tm, target);
/* TODO: ensure this doesn't underflow */