From 86e4e2e2809412ed6221e297bf0df063ad3698bf Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 1 Aug 2026 22:15:27 -1000 Subject: Add `enable-relative-dates` and `date-format` --- source/ui-shared.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'source/ui-shared.c') diff --git a/source/ui-shared.c b/source/ui-shared.c index ace06b2..d023243 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -672,6 +672,28 @@ const struct date_mode cgit_date_mode(enum date_mode_type type) return mode; } +/* + * The mode date-format selects, used wherever an age column falls back to a + * calendar date. local-time still forces local rendering on top of it. + */ +static const struct date_mode cgit_configured_date_mode(void) +{ + struct date_mode mode = ctx.cfg.date_mode; + + if (ctx.cfg.local_time) + mode.local = 1; + return mode; +} + +static void print_abs_date(time_t t, int tz) +{ + html(""); + html_txt(show_date(t, tz, cgit_configured_date_mode())); + html(""); +} + static void print_rel_date(time_t t, int tz, double value, const char *class, const char *suffix) { @@ -691,12 +713,9 @@ void cgit_print_age(time_t t, int tz, time_t max_relative) if (secs < 0) secs = 0; - if (secs > max_relative && max_relative >= 0) { - html(""); - html_txt(show_date(t, tz, cgit_date_mode(DATE_SHORT))); - html(""); + if (!ctx.cfg.enable_relative_dates || + (secs > max_relative && max_relative >= 0)) { + print_abs_date(t, tz); return; } -- cgit v2.8.0