summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'html.c')
-rw-r--r--html.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/html.c b/html.c
index 3f5435c..83a163f 100644
--- a/html.c
+++ b/html.c
@@ -210,6 +210,27 @@ xs_str *format_text_with_emoji(snac *user, const char *text, int ems, const char
210} 210}
211 211
212 212
213xs_str *html_date_label(snac *user, const char *date)
214{
215 time_t t = xs_parse_iso_date(date, 0);
216
217 /* check if a user has actually set a timezone */
218 if (t != 0 && xs_dict_get(user->config, "tz") != NULL) {
219 t += xs_tz_offset(user->tz);
220
221 time_t today = time(NULL);
222 if (today - t >= 3600 * 24 * 30 * 6) {
223 /* more than half a year ago */
224 return xs_str_utctime(t, "%Y-%m-%d %H:%M");
225 }
226
227 return xs_str_utctime(t, "%b%d %H:%M");
228 }
229
230 return xs_crop_i(xs_dup(date), 0, 10);
231}
232
233
213xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, 234xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
214 const char *udate, const char *url, int scope, 235 const char *udate, const char *url, int scope,
215 int in_people, const char *proxy, const char *lang, 236 int in_people, const char *proxy, const char *lang,
@@ -361,11 +382,11 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
361 xs_html_raw(" ")); 382 xs_html_raw(" "));
362 } 383 }
363 else { 384 else {
364 xs *date_label = xs_crop_i(xs_dup(date), 0, 10); 385 xs *date_label = html_date_label(user, date);
365 xs *date_title = xs_dup(date); 386 xs *date_title = xs_dup(date);
366 387
367 if (!xs_is_null(udate)) { 388 if (!xs_is_null(udate)) {
368 xs *sd = xs_crop_i(xs_dup(udate), 0, 10); 389 xs *sd = html_date_label(user, udate);
369 390
370 date_label = xs_str_cat(date_label, " / ", sd); 391 date_label = xs_str_cat(date_label, " / ", sd);
371 392
@@ -4203,7 +4224,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
4203 if (strcmp(type, "Follow") == 0 && pending_check(user, actor_id)) 4224 if (strcmp(type, "Follow") == 0 && pending_check(user, actor_id))
4204 label = L("Follow Request"); 4225 label = L("Follow Request");
4205 4226
4206 xs *s_date = xs_crop_i(xs_dup(date), 0, 10); 4227 xs *s_date = html_date_label(user, date);
4207 4228
4208 xs_html *this_html_label = xs_html_container( 4229 xs_html *this_html_label = xs_html_container(
4209 xs_html_tag("b", 4230 xs_html_tag("b",