diff options
| author | 2025-04-13 14:30:50 +0200 | |
|---|---|---|
| committer | 2025-04-13 14:30:50 +0200 | |
| commit | 848bd3e865fb2daf75d76cbb75a4a39f9b82b516 (patch) | |
| tree | 9e99d760cc76a8e97df645432523bee3440e8b08 | |
| parent | More timezone tweaks. (diff) | |
| download | penes-snac2-848bd3e865fb2daf75d76cbb75a4a39f9b82b516.tar.gz penes-snac2-848bd3e865fb2daf75d76cbb75a4a39f9b82b516.tar.xz penes-snac2-848bd3e865fb2daf75d76cbb75a4a39f9b82b516.zip | |
Cache the timezone inside the snac struct.
| -rw-r--r-- | data.c | 2 | ||||
| -rw-r--r-- | html.c | 6 | ||||
| -rw-r--r-- | snac.h | 1 |
3 files changed, 5 insertions, 4 deletions
| @@ -282,6 +282,8 @@ int user_open(snac *user, const char *uid) | |||
| 282 | } | 282 | } |
| 283 | else | 283 | else |
| 284 | srv_log(xs_fmt("error parsing '%s'", cfg_file)); | 284 | srv_log(xs_fmt("error parsing '%s'", cfg_file)); |
| 285 | |||
| 286 | user->tz = xs_dict_get_def(user->config, "tz", "UTC"); | ||
| 285 | } | 287 | } |
| 286 | else | 288 | else |
| 287 | srv_debug(2, xs_fmt("error opening '%s' %d", cfg_file, errno)); | 289 | srv_debug(2, xs_fmt("error opening '%s' %d", cfg_file, errno)); |
| @@ -455,7 +455,7 @@ xs_html *html_note(snac *user, const char *summary, | |||
| 455 | } | 455 | } |
| 456 | 456 | ||
| 457 | if (edit_id == NULL || is_draft || is_scheduled(user, edit_id)) { | 457 | if (edit_id == NULL || is_draft || is_scheduled(user, edit_id)) { |
| 458 | xs *pdat = xs_fmt(L("Post date and time (timezone: %s):"), xs_dict_get_def(user->config, "tz", "UTC")); | 458 | xs *pdat = xs_fmt(L("Post date and time (timezone: %s):"), user->tz); |
| 459 | 459 | ||
| 460 | xs_html_add(form, | 460 | xs_html_add(form, |
| 461 | xs_html_tag("p", | 461 | xs_html_tag("p", |
| @@ -4367,9 +4367,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 4367 | time_t t = xs_parse_iso_date(post_pubdate, 0); | 4367 | time_t t = xs_parse_iso_date(post_pubdate, 0); |
| 4368 | 4368 | ||
| 4369 | if (t != 0) { | 4369 | if (t != 0) { |
| 4370 | const char *tz = xs_dict_get_def(snac.config, "tz", "UTC"); | 4370 | t -= xs_tz_offset(snac.tz); |
| 4371 | |||
| 4372 | t -= xs_tz_offset(tz); | ||
| 4373 | 4371 | ||
| 4374 | xs *iso_date = xs_str_iso_date(t); | 4372 | xs *iso_date = xs_str_iso_date(t); |
| 4375 | msg = xs_dict_set(msg, "published", iso_date); | 4373 | msg = xs_dict_set(msg, "published", iso_date); |
| @@ -61,6 +61,7 @@ typedef struct { | |||
| 61 | xs_str *actor; /* actor url */ | 61 | xs_str *actor; /* actor url */ |
| 62 | xs_str *md5; /* actor url md5 */ | 62 | xs_str *md5; /* actor url md5 */ |
| 63 | const xs_dict *lang;/* string translation dict */ | 63 | const xs_dict *lang;/* string translation dict */ |
| 64 | const char *tz; /* configured timezone */ | ||
| 64 | } snac; | 65 | } snac; |
| 65 | 66 | ||
| 66 | typedef struct { | 67 | typedef struct { |