scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 56f71b43eec528d053af918f5ac199b5c38c7811
parent c82f5444f05f9b08b9f8e53b2fa43f640270f22a
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Mon, 27 Apr 2026 16:20:18 +0200

time/libc: Consider the tz offset for dst rules

DST rules are specified in localtime calendar, and it means that we have
to consider the epoch offset for the timezone before calling _isdst().

Diffstat:
Msrc/libc/time/localtime.c | 10++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/libc/time/localtime.c b/src/libc/time/localtime.c @@ -7,17 +7,15 @@ struct tm * localtime(const time_t *timep) { - time_t t; int dst; + time_t t; long off; char *name; struct tm *tm; - t = *timep; - tm = gmtime(&t); _tzset(); - - if (_isdst(tm)) { + t = *timep - _timezone; + if (_isdst(gmtime(&t))) { dst = 1; off = _dstzone; name = _tzname[1]; @@ -27,7 +25,7 @@ localtime(const time_t *timep) name = _tzname[0]; } - t -= off; + t = *timep - off; tm = gmtime(&t); tm->tm_zone = name; tm->tm_isdst = dst;