commit 848bd3e
default
·
2025-04-13 12:30:50 +0000 UTC
parent 8153890
Cache the timezone inside the snac struct.
M
data.c
+2,
-0
1@@ -282,6 +282,8 @@ int user_open(snac *user, const char *uid)
2 }
3 else
4 srv_log(xs_fmt("error parsing '%s'", cfg_file));
5+
6+ user->tz = xs_dict_get_def(user->config, "tz", "UTC");
7 }
8 else
9 srv_debug(2, xs_fmt("error opening '%s' %d", cfg_file, errno));
M
html.c
+2,
-4
1@@ -455,7 +455,7 @@ xs_html *html_note(snac *user, const char *summary,
2 }
3
4 if (edit_id == NULL || is_draft || is_scheduled(user, edit_id)) {
5- xs *pdat = xs_fmt(L("Post date and time (timezone: %s):"), xs_dict_get_def(user->config, "tz", "UTC"));
6+ xs *pdat = xs_fmt(L("Post date and time (timezone: %s):"), user->tz);
7
8 xs_html_add(form,
9 xs_html_tag("p",
10@@ -4367,9 +4367,7 @@ int html_post_handler(const xs_dict *req, const char *q_path,
11 time_t t = xs_parse_iso_date(post_pubdate, 0);
12
13 if (t != 0) {
14- const char *tz = xs_dict_get_def(snac.config, "tz", "UTC");
15-
16- t -= xs_tz_offset(tz);
17+ t -= xs_tz_offset(snac.tz);
18
19 xs *iso_date = xs_str_iso_date(t);
20 msg = xs_dict_set(msg, "published", iso_date);
M
snac.h
+1,
-0
1@@ -61,6 +61,7 @@ typedef struct {
2 xs_str *actor; /* actor url */
3 xs_str *md5; /* actor url md5 */
4 const xs_dict *lang;/* string translation dict */
5+ const char *tz; /* configured timezone */
6 } snac;
7
8 typedef struct {