aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2025-04-13 14:30:50 +0200
committerdefault <nobody@localhost>2025-04-13 14:30:50 +0200
commit848bd3e865fb2daf75d76cbb75a4a39f9b82b516 (patch)
tree9e99d760cc76a8e97df645432523bee3440e8b08
parent81538904210e9092760ce7c6b043eaaa166509b6 (diff)
Cache the timezone inside the snac struct.
-rw-r--r--data.c2
-rw-r--r--html.c6
-rw-r--r--snac.h1
3 files changed, 5 insertions, 4 deletions
diff --git a/data.c b/data.c
index 6661472..440e9df 100644
--- a/data.c
+++ b/data.c
@@ -282,6 +282,8 @@ int user_open(snac *user, const char *uid)
}
else
srv_log(xs_fmt("error parsing '%s'", cfg_file));
+
+ user->tz = xs_dict_get_def(user->config, "tz", "UTC");
}
else
srv_debug(2, xs_fmt("error opening '%s' %d", cfg_file, errno));
diff --git a/html.c b/html.c
index a6f79de..2e7f87c 100644
--- a/html.c
+++ b/html.c
@@ -455,7 +455,7 @@ xs_html *html_note(snac *user, const char *summary,
}
if (edit_id == NULL || is_draft || is_scheduled(user, edit_id)) {
- xs *pdat = xs_fmt(L("Post date and time (timezone: %s):"), xs_dict_get_def(user->config, "tz", "UTC"));
+ xs *pdat = xs_fmt(L("Post date and time (timezone: %s):"), user->tz);
xs_html_add(form,
xs_html_tag("p",
@@ -4367,9 +4367,7 @@ int html_post_handler(const xs_dict *req, const char *q_path,
time_t t = xs_parse_iso_date(post_pubdate, 0);
if (t != 0) {
- const char *tz = xs_dict_get_def(snac.config, "tz", "UTC");
-
- t -= xs_tz_offset(tz);
+ t -= xs_tz_offset(snac.tz);
xs *iso_date = xs_str_iso_date(t);
msg = xs_dict_set(msg, "published", iso_date);
diff --git a/snac.h b/snac.h
index 0d2aafe..5a19467 100644
--- a/snac.h
+++ b/snac.h
@@ -61,6 +61,7 @@ typedef struct {
xs_str *actor; /* actor url */
xs_str *md5; /* actor url md5 */
const xs_dict *lang;/* string translation dict */
+ const char *tz; /* configured timezone */
} snac;
typedef struct {