Fix !forecast showing all days as Sunday on musl libc
strptime on musl (Alpine Linux) does not compute tm_wday from the parsed date, unlike glibc. Call mktime() after strptime to normalize the struct tm and reliably compute the day of week on all platforms.
This commit is contained in:
parent
61a6a95801
commit
3727a5f72b
2 changed files with 2 additions and 1 deletions
2
zynk.c
2
zynk.c
|
|
@ -1504,7 +1504,7 @@ static char *fetch_forecast(const char *city_url, const char *city_display) {
|
|||
}
|
||||
}
|
||||
struct tm tm = {0};
|
||||
if (strptime(date, "%Y-%m-%d", &tm)) strftime(fmt_date[ndays], sizeof fmt_date[ndays], "%a %d %b", &tm);
|
||||
if (strptime(date, "%Y-%m-%d", &tm)) { mktime(&tm); strftime(fmt_date[ndays], sizeof fmt_date[ndays], "%a %d %b", &tm); }
|
||||
else snprintf(fmt_date[ndays], sizeof fmt_date[ndays], "%s", date);
|
||||
snprintf(line[ndays], sizeof line[ndays], "%s: %s\u00b0C %s", fmt_date[ndays], temp, cond);
|
||||
ndays++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue