scc

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

commit 7fd6e57efd93fafec42def9ffdf01cfbb13899b3
parent 4222cda40a32d6f958820ce6da4505e74c27cbd9
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 26 Sep 2018 07:54:00 +0100

[lib/c] Simplify mktime()

Diffstat:
Mlib/c/mktime.c | 14+++++---------
1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/lib/c/mktime.c b/lib/c/mktime.c @@ -78,7 +78,7 @@ normalize(struct tm *tm) time_t mktime(struct tm *tm) { - int i, year, min, hour, dst; + int i, year, dst; time_t t; struct tm *aux; @@ -100,17 +100,13 @@ mktime(struct tm *tm) aux = localtime(&t); - hour = aux->tm_gmtoff / SECHOUR; - min = aux->tm_gmtoff / SECMIN; dst = 0; - if (tm->tm_isdst == 0 && aux->tm_isdst == 1) - dst = -1; - else if (tm->tm_isdst > 0 && aux->tm_isdst == 0) - dst = +1; + dst = -SECHOUR; + else if (tm->tm_isdst == 1 && aux->tm_isdst == 0) + dst = +SECHOUR; - t += (hour +dst) * SECHOUR; - t -= min * SECMIN; + t += aux->tm_gmtoff + dst; return t; }