mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-26 01:03:37 +00:00
For polls, shows a 'Closes in d:h:m:s' string.
This commit is contained in:
parent
f543185c71
commit
3047f6220b
1 changed files with 22 additions and 6 deletions
28
html.c
28
html.c
|
@ -1025,12 +1025,6 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
|
|||
}
|
||||
|
||||
c = xs_str_cat(c, "</table>\n");
|
||||
|
||||
/* if it's *really* closed, say it */
|
||||
if (closed == 2) {
|
||||
xs *s1 = xs_fmt("<p>%s</p>\n", L("Closed"));
|
||||
c = xs_str_cat(c, s1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* poll still active */
|
||||
|
@ -1061,6 +1055,28 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
|
|||
|
||||
c = xs_str_cat(c, s1);
|
||||
}
|
||||
|
||||
/* if it's *really* closed, say it */
|
||||
if (closed == 2) {
|
||||
xs *s1 = xs_fmt("<p>%s</p>\n", L("Closed"));
|
||||
c = xs_str_cat(c, s1);
|
||||
}
|
||||
else {
|
||||
/* show when the poll closes */
|
||||
const char *end_time = xs_dict_get(msg, "endTime");
|
||||
if (!xs_is_null(end_time)) {
|
||||
time_t t0 = time(NULL);
|
||||
time_t t1 = xs_parse_iso_date(end_time, 0);
|
||||
|
||||
if (t1 > 0 && t1 > t0) {
|
||||
time_t diff_time = t1 - t0;
|
||||
xs *tf = xs_str_time_diff(diff_time);
|
||||
|
||||
xs *s1 = xs_fmt("<p>%s %s</p>", L("Closes in"), tf);
|
||||
c = xs_str_cat(c, s1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s = xs_str_cat(s, c);
|
||||
|
|
Loading…
Reference in a new issue