mirror of
https://github.com/esphome/esphome.git
synced 2026-09-11 23:37:34 +00:00
Optimize get_build_time_string to avoid repeated formatting
Apply same concurrency fix as get_config_hash to prevent race conditions when multiple threads access the function.
This commit is contained in:
@@ -44,9 +44,11 @@ time_t get_build_time() { return (time_t) build_time; }
|
||||
|
||||
const char *get_build_time_string() {
|
||||
static char time_str[32];
|
||||
time_t bt = get_build_time();
|
||||
struct tm *tm_info = localtime(&bt);
|
||||
strftime(time_str, sizeof(time_str), "%b %d %Y, %H:%M:%S", tm_info);
|
||||
if (!time_str[0]) {
|
||||
time_t bt = get_build_time();
|
||||
struct tm *tm_info = localtime(&bt);
|
||||
strftime(time_str, sizeof(time_str), "%b %d %Y, %H:%M:%S", tm_info);
|
||||
}
|
||||
return time_str;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user