about summary refs log tree commit diff stats
path: root/ui-shared.c
diff options
context:
space:
mode:
authorJohn Keeping2016-02-08 15:05:54 +0000
committerJason A. Donenfeld2016-02-08 18:28:18 +0100
commit9c15f3c6954e43c5ffd36230e666eccf112803f2 (patch)
treec905d68a9798a25a9534de41679d4eacc615bd51 /ui-shared.c
parentui-stats: cast pointer before checking for zero (diff)
downloadcgit-9c15f3c6954e43c5ffd36230e666eccf112803f2.tar.gz
cgit-9c15f3c6954e43c5ffd36230e666eccf112803f2.zip
Avoid DATE_STRFTIME for long/short dates
Git's DATE_STRFTIME ignores the timezone argument and just uses the
local timezone regardless of whether the "local" flag is set.

Since our existing FMT_LONGDATE and FMT_SHORTDATE are pretty-much
perfect matches to DATE_ISO8601 and DATE_SHORT, switch to taking a
date_mode_type directly in cgit_date_mode().

Signed-off-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/ui-shared.c b/ui-shared.c index d1f9249..03dcc08 100644 --- a/ui-shared.c +++ b/ui-shared.c
@@ -607,11 +607,10 @@ void cgit_submodule_link(const char *class, char *path, const char *rev)
607 path[len - 1] = tail; 607 path[len - 1] = tail;
608} 608}
609 609
610const struct date_mode *cgit_date_mode(const char *format) 610const struct date_mode *cgit_date_mode(enum date_mode_type type)
611{ 611{
612 static struct date_mode mode; 612 static struct date_mode mode;
613 mode.type = DATE_STRFTIME; 613 mode.type = type;
614 mode.strftime_fmt = format;
615 mode.local = ctx.cfg.local_time; 614 mode.local = ctx.cfg.local_time;
616 return &mode; 615 return &mode;
617} 616}
@@ -620,7 +619,7 @@ static void print_rel_date(time_t t, int tz, double value,
620 const char *class, const char *suffix) 619 const char *class, const char *suffix)
621{ 620{
622 htmlf("<span class='%s' title='", class); 621 htmlf("<span class='%s' title='", class);
623 html_attr(show_date(t, tz, cgit_date_mode(FMT_LONGDATE))); 622 html_attr(show_date(t, tz, cgit_date_mode(DATE_ISO8601)));
624 htmlf("'>%.0f %s</span>", value, suffix); 623 htmlf("'>%.0f %s</span>", value, suffix);
625} 624}
626 625
@@ -637,9 +636,9 @@ void cgit_print_age(time_t t, int tz, time_t max_relative)
637 636
638 if (secs > max_relative && max_relative >= 0) { 637 if (secs > max_relative && max_relative >= 0) {
639 html("<span title='"); 638 html("<span title='");
640 html_attr(show_date(t, tz, cgit_date_mode(FMT_LONGDATE))); 639 html_attr(show_date(t, tz, cgit_date_mode(DATE_ISO8601)));
641 html("'>"); 640 html("'>");
642 html_txt(show_date(t, tz, cgit_date_mode(FMT_SHORTDATE))); 641 html_txt(show_date(t, tz, cgit_date_mode(DATE_SHORT)));
643 html("</span>"); 642 html("</span>");
644 return; 643 return;
645 } 644 }
@@ -781,7 +780,7 @@ void cgit_print_docend(void)
781 else { 780 else {
782 htmlf("<div class='footer'>generated by <a href='http://git.zx2c4.com/cgit/about/'>cgit %s</a> at ", 781 htmlf("<div class='footer'>generated by <a href='http://git.zx2c4.com/cgit/about/'>cgit %s</a> at ",
783 cgit_version); 782 cgit_version);
784 html_txt(show_date(time(NULL), 0, cgit_date_mode(FMT_LONGDATE))); 783 html_txt(show_date(time(NULL), 0, cgit_date_mode(DATE_ISO8601)));
785 html("</div>\n"); 784 html("</div>\n");
786 } 785 }
787 html("</div> <!-- id=cgit -->\n"); 786 html("</div> <!-- id=cgit -->\n");