shithub: scc

Download patch

ref: a0a1e887b8323fdda306435b6e89ce003c3dc10f
parent: 823acc68023d0d810d7d830f13da713625bc51f4
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Sep 26 03:54:00 EDT 2018

[lib/c] Simplify mktime()

--- a/lib/c/mktime.c
+++ b/lib/c/mktime.c
@@ -78,7 +78,7 @@
 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 @@
 
 	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;
 }