diff options
| author | 2023-06-27 17:08:09 +0200 | |
|---|---|---|
| committer | 2023-06-27 17:08:09 +0200 | |
| commit | 3047f6220b1f2ac9b80057cbb919f823d0a74ec0 (patch) | |
| tree | a5faa76dff8bd730bb25c2f2f64490fbdf50467f /html.c | |
| parent | Backport from xs. (diff) | |
| download | snac2-3047f6220b1f2ac9b80057cbb919f823d0a74ec0.tar.gz snac2-3047f6220b1f2ac9b80057cbb919f823d0a74ec0.tar.xz snac2-3047f6220b1f2ac9b80057cbb919f823d0a74ec0.zip | |
For polls, shows a 'Closes in d:h:m:s' string.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 28 |
1 files changed, 22 insertions, 6 deletions
| @@ -1025,12 +1025,6 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local, | |||
| 1025 | } | 1025 | } |
| 1026 | 1026 | ||
| 1027 | c = xs_str_cat(c, "</table>\n"); | 1027 | c = xs_str_cat(c, "</table>\n"); |
| 1028 | |||
| 1029 | /* if it's *really* closed, say it */ | ||
| 1030 | if (closed == 2) { | ||
| 1031 | xs *s1 = xs_fmt("<p>%s</p>\n", L("Closed")); | ||
| 1032 | c = xs_str_cat(c, s1); | ||
| 1033 | } | ||
| 1034 | } | 1028 | } |
| 1035 | else { | 1029 | else { |
| 1036 | /* poll still active */ | 1030 | /* poll still active */ |
| @@ -1061,6 +1055,28 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local, | |||
| 1061 | 1055 | ||
| 1062 | c = xs_str_cat(c, s1); | 1056 | c = xs_str_cat(c, s1); |
| 1063 | } | 1057 | } |
| 1058 | |||
| 1059 | /* if it's *really* closed, say it */ | ||
| 1060 | if (closed == 2) { | ||
| 1061 | xs *s1 = xs_fmt("<p>%s</p>\n", L("Closed")); | ||
| 1062 | c = xs_str_cat(c, s1); | ||
| 1063 | } | ||
| 1064 | else { | ||
| 1065 | /* show when the poll closes */ | ||
| 1066 | const char *end_time = xs_dict_get(msg, "endTime"); | ||
| 1067 | if (!xs_is_null(end_time)) { | ||
| 1068 | time_t t0 = time(NULL); | ||
| 1069 | time_t t1 = xs_parse_iso_date(end_time, 0); | ||
| 1070 | |||
| 1071 | if (t1 > 0 && t1 > t0) { | ||
| 1072 | time_t diff_time = t1 - t0; | ||
| 1073 | xs *tf = xs_str_time_diff(diff_time); | ||
| 1074 | |||
| 1075 | xs *s1 = xs_fmt("<p>%s %s</p>", L("Closes in"), tf); | ||
| 1076 | c = xs_str_cat(c, s1); | ||
| 1077 | } | ||
| 1078 | } | ||
| 1079 | } | ||
| 1064 | } | 1080 | } |
| 1065 | 1081 | ||
| 1066 | s = xs_str_cat(s, c); | 1082 | s = xs_str_cat(s, c); |