dirkx / SMPTE-EBU-TimecodeGenerator-ESP32

ESP32 based SMPTE/EBU timecode generator, with NTP slaving, for Leitch and similar studio/broadcast clocks.
Apache License 2.0
49 stars 16 forks source link

timezone read problem #6

Closed mikemccauley closed 2 years ago

mikemccauley commented 2 years ago

Hi, excellent program, but found a problem that took me a while to track down. My timezone is AEST-10, which I set in the source code

define NTP_DEFAULT_TZ "AEST-10"

and also set using the web interface. The wierd behaviour was that on first boot after SPIFFS format, timezone would be set correctly and time displayed correctly. Setting the timezone by the web interface would also correctly set the timezone, but if you then restart the ESP, or 3 days expires, the timezone would revert to -11 hours, not -10.

The issue is caused by code in ntp_setup. When _tz is read form the file, there is a trailing carriage return (0x0d) in _tz. This seems to confuse the ESP timezone code when it is passed to configTzTime(). The fix is to add _tz.trim(); after reading the timezone from the file:

String _tz = file.readStringUntil('\n');
_tz.trim(); // Remove trailing CR