diff options
Diffstat (limited to 'source/ui-shared.c')
| -rw-r--r-- | source/ui-shared.c | 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 25 insertions, 6 deletions
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("<span title='"); + html_attr(show_date(t, tz, cgit_date_mode(DATE_ISO8601))); + html("'>"); + html_txt(show_date(t, tz, cgit_configured_date_mode())); + html("</span>"); +} + 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("<span title='"); - html_attr(show_date(t, tz, cgit_date_mode(DATE_ISO8601))); - html("'>"); - html_txt(show_date(t, tz, cgit_date_mode(DATE_SHORT))); - html("</span>"); + if (!ctx.cfg.enable_relative_dates || + (secs > max_relative && max_relative >= 0)) { + print_abs_date(t, tz); return; } |
