summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--html.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/html.c b/html.c
index 1e890e3..6a5aa10 100644
--- a/html.c
+++ b/html.c
@@ -2272,6 +2272,49 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2272 } 2272 }
2273 } 2273 }
2274 2274
2275 if (strcmp(type, "Event") == 0) { /** Event start and end times **/
2276 const char *s_time = xs_dict_get(msg, "startTime");
2277
2278 if (xs_type(s_time) == XSTYPE_STRING) {
2279 const char *e_time = xs_dict_get(msg, "endTime");
2280 const char *tz = xs_dict_get(msg, "timezone");
2281
2282 xs *s = xs_replace_i(xs_dup(s_time), "T", " ");
2283 xs *e = NULL;
2284
2285 if (xs_type(e_time) == XSTYPE_STRING)
2286 e = xs_replace_i(xs_dup(e_time), "T", " ");
2287
2288 /* if the event has a timezone, crop the offsets */
2289 if (xs_type(tz) == XSTYPE_STRING) {
2290 s = xs_crop_i(s, 0, 19);
2291
2292 if (e)
2293 e = xs_crop_i(e, 0, 19);
2294 }
2295 else
2296 tz = "";
2297
2298 /* if start and end share the same day, crop it from the end */
2299 if (e && memcmp(s, e, 11) == 0)
2300 e = xs_crop_i(e, 11, strlen(e));
2301
2302 if (e)
2303 s = xs_str_cat(s, " / ", e);
2304
2305 if (*tz)
2306 s = xs_str_cat(s, " (", tz, ")");
2307
2308 /* replace ugly decimals */
2309 s = xs_replace_i(s, ".000", "");
2310
2311 xs_html_add(snac_content_wrap,
2312 xs_html_tag("p",
2313 xs_html_text(L("Time: ")),
2314 xs_html_text(s)));
2315 }
2316 }
2317
2275 /* show all hashtags that has not been shown previously in the content */ 2318 /* show all hashtags that has not been shown previously in the content */
2276 const xs_list *tags = xs_dict_get(msg, "tag"); 2319 const xs_list *tags = xs_dict_get(msg, "tag");
2277 if (xs_type(tags) == XSTYPE_LIST && xs_list_len(tags)) { 2320 if (xs_type(tags) == XSTYPE_LIST && xs_list_len(tags)) {