about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJohn Keeping2016-01-19 19:33:05 +0000
committerJason A. Donenfeld2016-02-08 14:22:21 +0100
commitf2a901d2e1db5217d6890b26c6dc1ec119505d02 (patch)
tree72f3039748dcf1b00b3d5741cc6282dee7f5492c
parentui-{commit,tag}: show dates in originator's timezone (diff)
downloadcgit-f2a901d2e1db5217d6890b26c6dc1ec119505d02.tar.gz
cgit-f2a901d2e1db5217d6890b26c6dc1ec119505d02.zip
ui: show ages in the originator's timezone
This affects the tooltip showing the full time and the case when a date
is sufficiently old to be shown in full rather than as an offset.

Signed-off-by: John Keeping <john@keeping.me.uk>
-rw-r--r--ui-log.c4
-rw-r--r--ui-refs.c6
-rw-r--r--ui-repolist.c2
-rw-r--r--ui-shared.c22
-rw-r--r--ui-shared.h2
5 files changed, 18 insertions, 18 deletions
diff --git a/ui-log.c b/ui-log.c index 5f6a69c..0a3938b 100644 --- a/ui-log.c +++ b/ui-log.c
@@ -204,7 +204,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
204 } 204 }
205 else { 205 else {
206 html("<td>"); 206 html("<td>");
207 cgit_print_age(commit->date, TM_WEEK * 2); 207 cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2);
208 html("</td>"); 208 html("</td>");
209 } 209 }
210 210
@@ -244,7 +244,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
244 244
245 if (revs->graph) { 245 if (revs->graph) {
246 html("</td><td>"); 246 html("</td><td>");
247 cgit_print_age(commit->date, TM_WEEK * 2); 247 cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2);
248 } 248 }
249 249
250 if (!lines_counted && (ctx.repo->enable_log_filecount || 250 if (!lines_counted && (ctx.repo->enable_log_filecount ||
diff --git a/ui-refs.c b/ui-refs.c index 0652b89..5b4530e 100644 --- a/ui-refs.c +++ b/ui-refs.c
@@ -73,7 +73,7 @@ static int print_branch(struct refinfo *ref)
73 html_txt(info->author); 73 html_txt(info->author);
74 cgit_close_filter(ctx.repo->email_filter); 74 cgit_close_filter(ctx.repo->email_filter);
75 html("</td><td colspan='2'>"); 75 html("</td><td colspan='2'>");
76 cgit_print_age(info->commit->date, -1); 76 cgit_print_age(info->committer_date, info->committer_tz, -1);
77 } else { 77 } else {
78 html("</td><td></td><td>"); 78 html("</td><td></td><td>");
79 cgit_object_link(ref->object); 79 cgit_object_link(ref->object);
@@ -161,9 +161,9 @@ static int print_tag(struct refinfo *ref)
161 html("</td><td colspan='2'>"); 161 html("</td><td colspan='2'>");
162 if (info) { 162 if (info) {
163 if (info->tagger_date > 0) 163 if (info->tagger_date > 0)
164 cgit_print_age(info->tagger_date, -1); 164 cgit_print_age(info->tagger_date, info->tagger_tz, -1);
165 } else if (ref->object->type == OBJ_COMMIT) { 165 } else if (ref->object->type == OBJ_COMMIT) {
166 cgit_print_age(ref->commit->commit->date, -1); 166 cgit_print_age(ref->commit->commit->date, 0, -1);
167 } 167 }
168 html("</td></tr>\n"); 168 html("</td></tr>\n");
169 169
diff --git a/ui-repolist.c b/ui-repolist.c index 6004469..30915df 100644 --- a/ui-repolist.c +++ b/ui-repolist.c
@@ -79,7 +79,7 @@ static void print_modtime(struct cgit_repo *repo)
79{ 79{
80 time_t t; 80 time_t t;
81 if (get_repo_modtime(repo, &t)) 81 if (get_repo_modtime(repo, &t))
82 cgit_print_age(t, -1); 82 cgit_print_age(t, 0, -1);
83} 83}
84 84
85static int is_match(struct cgit_repo *repo) 85static int is_match(struct cgit_repo *repo)
diff --git a/ui-shared.c b/ui-shared.c index 923d102..3ce86fe 100644 --- a/ui-shared.c +++ b/ui-shared.c
@@ -636,15 +636,15 @@ const struct date_mode *cgit_date_mode(const char *format)
636 return &mode; 636 return &mode;
637} 637}
638 638
639static void print_rel_date(time_t t, double value, 639static void print_rel_date(time_t t, int tz, double value,
640 const char *class, const char *suffix) 640 const char *class, const char *suffix)
641{ 641{
642 htmlf("<span class='%s' title='", class); 642 htmlf("<span class='%s' title='", class);
643 html_attr(fmt_date(t, FMT_LONGDATE, ctx.cfg.local_time)); 643 html_attr(show_date(t, tz, cgit_date_mode(FMT_LONGDATE)));
644 htmlf("'>%.0f %s</span>", value, suffix); 644 htmlf("'>%.0f %s</span>", value, suffix);
645} 645}
646 646
647void cgit_print_age(time_t t, time_t max_relative) 647void cgit_print_age(time_t t, int tz, time_t max_relative)
648{ 648{
649 time_t now, secs; 649 time_t now, secs;
650 650
@@ -657,34 +657,34 @@ void cgit_print_age(time_t t, time_t max_relative)
657 657
658 if (secs > max_relative && max_relative >= 0) { 658 if (secs > max_relative && max_relative >= 0) {
659 html("<span title='"); 659 html("<span title='");
660 html_attr(fmt_date(t, FMT_LONGDATE, ctx.cfg.local_time)); 660 html_attr(show_date(t, tz, cgit_date_mode(FMT_LONGDATE)));
661 html("'>"); 661 html("'>");
662 cgit_print_date(t, FMT_SHORTDATE, ctx.cfg.local_time); 662 html_txt(show_date(t, tz, cgit_date_mode(FMT_SHORTDATE)));
663 html("</span>"); 663 html("</span>");
664 return; 664 return;
665 } 665 }
666 666
667 if (secs < TM_HOUR * 2) { 667 if (secs < TM_HOUR * 2) {
668 print_rel_date(t, secs * 1.0 / TM_MIN, "age-mins", "min."); 668 print_rel_date(t, tz, secs * 1.0 / TM_MIN, "age-mins", "min.");
669 return; 669 return;
670 } 670 }
671 if (secs < TM_DAY * 2) { 671 if (secs < TM_DAY * 2) {
672 print_rel_date(t, secs * 1.0 / TM_HOUR, "age-hours", "hours"); 672 print_rel_date(t, tz, secs * 1.0 / TM_HOUR, "age-hours", "hours");
673 return; 673 return;
674 } 674 }
675 if (secs < TM_WEEK * 2) { 675 if (secs < TM_WEEK * 2) {
676 print_rel_date(t, secs * 1.0 / TM_DAY, "age-days", "days"); 676 print_rel_date(t, tz, secs * 1.0 / TM_DAY, "age-days", "days");
677 return; 677 return;
678 } 678 }
679 if (secs < TM_MONTH * 2) { 679 if (secs < TM_MONTH * 2) {
680 print_rel_date(t, secs * 1.0 / TM_WEEK, "age-weeks", "weeks"); 680 print_rel_date(t, tz, secs * 1.0 / TM_WEEK, "age-weeks", "weeks");
681 return; 681 return;
682 } 682 }
683 if (secs < TM_YEAR * 2) { 683 if (secs < TM_YEAR * 2) {
684 print_rel_date(t, secs * 1.0 / TM_MONTH, "age-months", "months"); 684 print_rel_date(t, tz, secs * 1.0 / TM_MONTH, "age-months", "months");
685 return; 685 return;
686 } 686 }
687 print_rel_date(t, secs * 1.0 / TM_YEAR, "age-years", "years"); 687 print_rel_date(t, tz, secs * 1.0 / TM_YEAR, "age-years", "years");
688} 688}
689 689
690void cgit_print_http_headers(void) 690void cgit_print_http_headers(void)
diff --git a/ui-shared.h b/ui-shared.h index 707cec9..e42f13a 100644 --- a/ui-shared.h +++ b/ui-shared.h
@@ -63,7 +63,7 @@ __attribute__((format (printf,1,0)))
63extern void cgit_vprint_error(const char *fmt, va_list ap); 63extern void cgit_vprint_error(const char *fmt, va_list ap);
64extern const struct date_mode *cgit_date_mode(const char *format); 64extern const struct date_mode *cgit_date_mode(const char *format);
65extern void cgit_print_date(time_t secs, const char *format, int local_time); 65extern void cgit_print_date(time_t secs, const char *format, int local_time);
66extern void cgit_print_age(time_t t, time_t max_relative); 66extern void cgit_print_age(time_t t, int tz, time_t max_relative);
67extern void cgit_print_http_headers(void); 67extern void cgit_print_http_headers(void);
68extern void cgit_redirect(const char *url, bool permanent); 68extern void cgit_redirect(const char *url, bool permanent);
69extern void cgit_print_docstart(void); 69extern void cgit_print_docstart(void);