about summary refs log tree commit diff
path: root/templates
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2020-08-21 00:07:41 +0200
committersternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2020-08-21 00:07:41 +0200
commitaac560829418855192783680d2fa3f80f8b84013 (patch)
tree848ced76f91d3ab23c85a061e9be6cfeb13faa76 /templates
parent875a5ce6222fa1027dc134b73c5cd6e8c06c1e4a (diff)
refactor(templates/simple): use timeutil for time formatting
Diffstat (limited to 'templates')
-rw-r--r--templates/simple.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/templates/simple.c b/templates/simple.c
index 8e1037e..06d69e8 100644
--- a/templates/simple.c
+++ b/templates/simple.c
@@ -2,16 +2,14 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <time.h>
 
 #include <core.h>
 #include <template.h>
 #include <config.h>
 #include <cgiutil.h>
+#include <timeutil.h>
 #include <xml.h>
 
-extern long timezone;
-
 static struct xml_context ctx;
 
 int make_link(char *buf, size_t size, char *abs_path) {
@@ -44,13 +42,9 @@ int make_link(char *buf, size_t size, char *abs_path) {
 }
 
 void output_entry_time(struct xml_context *ctx, struct entry entry) {
-    tzset();
-    char *format = timezone == 0 ? "%Y-%m-%d %TZ" : "%Y-%m-%d %T%z";
-
-    char strtime[32];
-    struct tm *local = localtime(&entry.time);
+    char strtime[MAX_TIMESTR_SIZE];
 
-    if(strftime(strtime, sizeof strtime, format, local) > 0) {
+    if(flocaltime(strtime, HTML_TIME_FORMAT_READABLE, MAX_TIMESTR_SIZE, &entry.time) > 0) {
         xml_open_tag_attrs(ctx, "time", 1, "datetime", strtime);
         xml_raw(ctx, strtime);
         xml_close_tag(ctx, "time");