From aac560829418855192783680d2fa3f80f8b84013 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Fri, 21 Aug 2020 00:07:41 +0200 Subject: refactor(templates/simple): use timeutil for time formatting --- templates/simple.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'templates') 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 #include #include -#include #include #include #include #include +#include #include -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"); -- cgit 1.4.1