Skip to content

getEpoch has a race condition causing it to be off by one day #114

@ant32

Description

@ant32

Ran into an issue where the epoch time was off by exactly one day. This is caused by getEpoch function first reading date and then reading time. Date time may have rolled over to new day in between.

syncTime();

time_t STM32RTC::getEpoch(uint32_t *subSeconds)
{
  struct tm tm;

  syncDate();
  syncTime(); // <-- date may have changed and time sometimes reads 00:00:00 of the following date.

Discussion here
https://github.com/orgs/stm32duino/discussions/2600#discussioncomment-11545824

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions