shithub: npe

Download patch

ref: ab3b4d3d9fc91716220b146dc0f57653a5b1daf4
parent: b9dcbb8b9ff5526f470d5825043752f28533217b
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Jun 20 07:49:38 EDT 2021

time: add mktime

--- a/include/npe/time.h
+++ b/include/npe/time.h
@@ -22,5 +22,6 @@
 #define localtime npe_localtime
 struct tm *npe_localtime(time_t *timep);
 size_t strftime(char *s, size_t max, const char *format, const struct tm *tm);
+time_t mktime(struct tm *tm);
 
 #endif
--- a/libnpe/mkfile
+++ b/libnpe/mkfile
@@ -30,6 +30,7 @@
 	lrint.$O\
 	lrintf.$O\
 	mkdir.$O\
+	mktime.$O\
 	opendir.$O\
 	readdir.$O\
 	rename.$O\
--- /dev/null
+++ b/libnpe/mktime.c
@@ -1,0 +1,22 @@
+#include <time.h>
+#include "_npe.h"
+
+time_t
+mktime(struct tm *tm)
+{
+	Tm t;
+
+	t.sec = tm->tm_sec;
+	t.min = tm->tm_min;
+	t.hour = tm->tm_hour;
+	t.mday = tm->tm_mday;
+	t.mon = tm->tm_mon;
+	t.year = tm->tm_year;
+	t.wday = tm->tm_wday;
+	t.yday = tm->tm_yday;
+	t.tzoff = 0;
+	t.tz = nil;
+	/* ... = tm.tm_isdst; */ /* FIXME */
+
+	return tmnorm(&t) / Nsec;
+}