Hello everyone,
I'm experiencing an issue with time functions on my Arduino Nano 33 IoT, specifically with gmtime().
I'm trying to get the correct UTC time on my Nano 33 IoT connected to Arduino IoT Cloud, but gmtime() seems to be returning an incorrect value.
Board: Arduino Nano 33 IoT SAMD21
Libraries involved: RTCZero.h, time.h, and using ArduinoCloud.getLocalTime().
I'm fetching the epoch ArduinoCloud.getLocalTime(). I've verified this epoch using online converters, and it correctly represents the current UTC time.
However, when I pass this correct UTC epoch to gmtime(), the resulting struct tm (and the hours/minutes extracted from it) is consistently double of the hours ahead of the actual UTC time. For instance, if the actual UTC is 10:00, gmtime() (with the correct 10:00 UTC epoch) populates the tm_hour field as if it were 14:00.
My local timezone is UTC+2. The board seems to be showing UTC+4, even when using gmtime() which should ignore local timezone settings.
I've confirmed the epoch from the cloud is correct UTC.
The issue persists even when gmtime() is called directly with the correct UTC epoch, not just through other library functions.
Has anyone else experienced gmtime() on the Nano 33 IoT (or other SAMD21 boards) returning a time that is several hours ahead of the actual UTC, even when provided with a correct UTC epoch ?
Is this a known issue with the SAMD21 core's C standard library implementation of gmtime() ?
Are there any known workarounds other than manually subtracting the observed offset, or any configurations I might be missing that could cause gmtime() to behave this way ?
Any insights or suggestions would be greatly appreciated.
Thank you !