Merge branch 'bugfix/mktime_tzset_v4.4' into 'release/v4.4'

core-system/newlib: updated docs to reflect that tzset() needs to be called (v4.4)

See merge request espressif/esp-idf!23901
This commit is contained in:
Marius Vikhammer
2023-06-08 15:59:53 +08:00

View File

@@ -75,6 +75,9 @@ If you need to obtain time with one second resolution, use the following method:
time(&now); time(&now);
// Set timezone to China Standard Time // Set timezone to China Standard Time
setenv("TZ", "CST-8", 1); setenv("TZ", "CST-8", 1);
/* According to the posix standard localtime/mktime should use timezone information as though localtime/mktime() calls tzset(),
but this is not the case in older versions of Newlib. We manually call tzset to ensure the timezone info is updated*/
tzset(); tzset();
localtime_r(&now, &timeinfo); localtime_r(&now, &timeinfo);