commit 6ad518e9af4d7b5fc3497582746867d1716ff6a6
parent 0889c34f135244e851b993c310bf56e359513e7a
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Fri, 24 Apr 2026 16:46:21 +0200
libc/time: Use localtime() in mktime
Mtime must adjust the input tm as is localtime() was called and we
were trying to avoid the call to locatime, but it created more problems
than solutions.
Diffstat:
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/src/libc/time/mktime.c b/src/libc/time/mktime.c
@@ -133,23 +133,17 @@ mktime(struct tm *ptm)
_tzset();
dst = _isdst(&tm);
- if (tm.tm_isdst == 0 || tm.tm_isdst < 0 && !dst) {
+ if (tm.tm_isdst == 0 || tm.tm_isdst < 0 && !dst)
off = _timezone;
- name = _tzname[0];
- } else {
+ else
off = _dstzone;
- name = _tzname[1];
- }
if (off > 0 && t > _TIME_MAX - off
|| off < 0 && t < _TIME_MIN - off) {
return -1;
}
t += off;
- tm.tm_isdst = dst;
- tm.tm_gmtoff = off;
- tm.tm_zone = name;
- *ptm = tm;
+ *ptm = *localtime(&t);
return t;
}