Open softhack007 opened 1 year ago
Interesting , that would mean you could have day or week in there ? And might not be linked to the post about time but rather general limitation with text is that its only ASCII
Some docs on the "system time" api that also supports strftime()
and struct tm
time_t now;
char strftime_buf[64];
struct tm timeinfo;
// get unix epoch time
time(&now);
// Set timezone to China Standard Time
setenv("TZ", "CST-8", 1);
tzset();
localtime_r(&now, &timeinfo);
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
ESP_LOGI(TAG, "The current date/time in Shanghai is: %s", strftime_buf);
Is your feature request related to a problem? Please describe.
The WLED "scrolling text" effect has a few fixed formats to display date or time. Unfortunately people have diverging preferences on how a "digital clock" should look like, plus there are different formats that are considered "normal way" in each nation.
Describe the solution you'd like
The solution could be to allow userdefined time/date formats from the "strftime()" standard function.
https://cplusplus.com/reference/ctime/strftime/
For example, naming a segment "%I:%M%p" would result in "03:21PM" (12hr format, leading zeros, dots, capital letter AM/PM).
Additional context
This is an idea that came up in a discussion on discord. It would be rather simple to implement, because strftime() seems to be availeable on esp32, and WLED already has a feature to convert internal "unixtime" to the tm struct needed by the function.
Maybe a special "marker" would be necessary (like seg name starting with "##") to instruct scrolling text to use strftime format.
Thank you for your ideas for making WLED better!