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
|
|
@ -1,6 +1,7 @@
|
|||
2026.07.19 – Fix !weather returning HTML.
|
||||
|
||||
- Fixed `!weather` command returning `<!DOCTYPE html>` instead of weather data: wttr.in now returns HTML when it detects a browser User-Agent, so replaced the fake Firefox UA string with `zynk/VERSION`.
|
||||
- Fixed `!forecast` showing all days as Sunday on musl libc (Alpine Linux): `strptime` on musl does not compute `tm_wday`, so added `mktime()` to normalize the struct before formatting.
|
||||
- Version bumped to 0.34.1.
|
||||
|
||||
2026.07.19 – Uptime command, remove !hello.
|
||||
|
|
|
|||
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