aboutsummaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-09-17 22:08:50 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-09-17 22:08:50 +0200
commit3e400c3df5572524b7ba08b030f45eb3ba6b7734 (patch)
treec7fd7a5d391649c7905ee685cfa7fe7b4498cf1b /misc.c
parent361bb55f01ba28960a8127b0a16c1e7a7a8de61a (diff)
downloadcforum-3e400c3df5572524b7ba08b030f45eb3ba6b7734.tar.gz
Add database helper functions
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/misc.c b/misc.c
new file mode 100644
index 0000000..e5bdeef
--- /dev/null
+++ b/misc.c
@@ -0,0 +1,19 @@
+#include <err.h>
+#include <time.h>
+#include <stdio.h>
+#include "misc.h"
+
+char *
+date(int timestamp)
+{
+ char *buf;
+ time_t *t;
+
+ if(!(buf = malloc(20)))
+ err(1, "malloc");
+
+ t = localtime(&timestamp);
+ strftime(buf, 20, "%Y-%m-%d %H:%M", t);
+
+ return buf;
+} \ No newline at end of file