List for cgit developers and users
 help / color / mirror / Atom feed
From: john at keeping.me.uk (John Keeping)
Subject: [PATCH 5/8] ui: show ages in the originator's timezone
Date: Tue, 19 Jan 2016 19:33:05 +0000	[thread overview]
Message-ID: <6c9a2913f437568b6f9fc121728c4c6f66f262cf.1453231719.git.john@keeping.me.uk> (raw)
In-Reply-To: <cover.1453231719.git.john@keeping.me.uk>

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 at keeping.me.uk>
---
 ui-log.c      |  4 ++--
 ui-refs.c     |  6 +++---
 ui-repolist.c |  2 +-
 ui-shared.c   | 22 +++++++++++-----------
 ui-shared.h   |  2 +-
 5 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/ui-log.c b/ui-log.c
index bc625db..272c073 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -202,7 +202,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
 	}
 	else {
 		html("<td>");
-		cgit_print_age(commit->date, TM_WEEK * 2);
+		cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2);
 		html("</td>");
 	}
 
@@ -242,7 +242,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
 
 	if (revs->graph) {
 		html("</td><td>");
-		cgit_print_age(commit->date, TM_WEEK * 2);
+		cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2);
 	}
 
 	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)
 		html_txt(info->author);
 		cgit_close_filter(ctx.repo->email_filter);
 		html("</td><td colspan='2'>");
-		cgit_print_age(info->commit->date, -1);
+		cgit_print_age(info->committer_date, info->committer_tz, -1);
 	} else {
 		html("</td><td></td><td>");
 		cgit_object_link(ref->object);
@@ -161,9 +161,9 @@ static int print_tag(struct refinfo *ref)
 	html("</td><td colspan='2'>");
 	if (info) {
 		if (info->tagger_date > 0)
-			cgit_print_age(info->tagger_date, -1);
+			cgit_print_age(info->tagger_date, info->tagger_tz, -1);
 	} else if (ref->object->type == OBJ_COMMIT) {
-		cgit_print_age(ref->commit->commit->date, -1);
+		cgit_print_age(ref->commit->commit->date, 0, -1);
 	}
 	html("</td></tr>\n");
 
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)
 {
 	time_t t;
 	if (get_repo_modtime(repo, &t))
-		cgit_print_age(t, -1);
+		cgit_print_age(t, 0, -1);
 }
 
 static int is_match(struct cgit_repo *repo)
diff --git a/ui-shared.c b/ui-shared.c
index 2a622cd..0322968 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -636,15 +636,15 @@ const struct date_mode *cgit_date_mode(const char *format)
 	return &mode;
 }
 
-static void print_rel_date(time_t t, double value,
+static void print_rel_date(time_t t, int tz, double value,
 	const char *class, const char *suffix)
 {
 	htmlf("<span class='%s' title='", class);
-	html_attr(fmt_date(t, FMT_LONGDATE, ctx.cfg.local_time));
+	html_attr(show_date(t, tz, cgit_date_mode(FMT_LONGDATE)));
 	htmlf("'>%.0f %s</span>", value, suffix);
 }
 
-void cgit_print_age(time_t t, time_t max_relative)
+void cgit_print_age(time_t t, int tz, time_t max_relative)
 {
 	time_t now, secs;
 
@@ -657,34 +657,34 @@ void cgit_print_age(time_t t, time_t max_relative)
 
 	if (secs > max_relative && max_relative >= 0) {
 		html("<span title='");
-		html_attr(fmt_date(t, FMT_LONGDATE, ctx.cfg.local_time));
+		html_attr(show_date(t, tz, cgit_date_mode(FMT_LONGDATE)));
 		html("'>");
-		cgit_print_date(t, FMT_SHORTDATE, ctx.cfg.local_time);
+		html_txt(show_date(t, tz, cgit_date_mode(FMT_SHORTDATE)));
 		html("</span>");
 		return;
 	}
 
 	if (secs < TM_HOUR * 2) {
-		print_rel_date(t, secs * 1.0 / TM_MIN, "age-mins", "min.");
+		print_rel_date(t, tz, secs * 1.0 / TM_MIN, "age-mins", "min.");
 		return;
 	}
 	if (secs < TM_DAY * 2) {
-		print_rel_date(t, secs * 1.0 / TM_HOUR, "age-hours", "hours");
+		print_rel_date(t, tz, secs * 1.0 / TM_HOUR, "age-hours", "hours");
 		return;
 	}
 	if (secs < TM_WEEK * 2) {
-		print_rel_date(t, secs * 1.0 / TM_DAY, "age-days", "days");
+		print_rel_date(t, tz, secs * 1.0 / TM_DAY, "age-days", "days");
 		return;
 	}
 	if (secs < TM_MONTH * 2) {
-		print_rel_date(t, secs * 1.0 / TM_WEEK, "age-weeks", "weeks");
+		print_rel_date(t, tz, secs * 1.0 / TM_WEEK, "age-weeks", "weeks");
 		return;
 	}
 	if (secs < TM_YEAR * 2) {
-		print_rel_date(t, secs * 1.0 / TM_MONTH, "age-months", "months");
+		print_rel_date(t, tz, secs * 1.0 / TM_MONTH, "age-months", "months");
 		return;
 	}
-	print_rel_date(t, secs * 1.0 / TM_YEAR, "age-years", "years");
+	print_rel_date(t, tz, secs * 1.0 / TM_YEAR, "age-years", "years");
 }
 
 void cgit_print_http_headers(void)
diff --git a/ui-shared.h b/ui-shared.h
index 7c097c1..ed351c2 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -63,7 +63,7 @@ __attribute__((format (printf,1,0)))
 extern void cgit_vprint_error(const char *fmt, va_list ap);
 extern const struct date_mode *cgit_date_mode(const char *format);
 extern void cgit_print_date(time_t secs, const char *format, int local_time);
-extern void cgit_print_age(time_t t, time_t max_relative);
+extern void cgit_print_age(time_t t, int tz, time_t max_relative);
 extern void cgit_print_http_headers(void);
 extern void cgit_redirect(const char *url, bool permanent);
 extern void cgit_print_docstart(void);
-- 
2.7.0.226.gfe986fe



  parent reply	other threads:[~2016-01-19 19:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19 19:33 [PATCH 0/8] Show times " john
2016-01-19 19:33 ` [PATCH 1/8] ui-shared: remove "format" from cgit_print_age() john
2016-01-19 19:33 ` [PATCH 2/8] parsing: add timezone to ident structures john
2016-01-19 19:33 ` [PATCH 3/8] ui-shared: add cgit_date_mode() john
2016-02-08 13:20   ` Jason
2016-02-08 13:23     ` Jason
2016-01-19 19:33 ` [PATCH 4/8] ui-{commit,tag}: show dates in originator's timezone john
2016-01-19 19:33 ` john [this message]
2016-01-19 19:33 ` [PATCH 6/8] ui-shared: use show_date for footer timestamp john
2016-01-19 19:33 ` [PATCH 7/8] ui-atom: use show_date directly for atom dates john
2016-01-19 19:33 ` [PATCH 8/8] ui-shared: remove cgit_print_date() john
2016-02-08 13:23 ` [PATCH 0/8] Show times in the originator's timezone Jason
2016-02-08 13:38   ` Jason
2016-02-08 14:08     ` john
2016-02-08 14:33       ` Jason
2016-02-08 15:05         ` [PATCH 1/2] Avoid DATE_STRFTIME for long/short dates john
2016-02-08 15:06           ` [PATCH 2/2] ui-atom: avoid DATE_STRFTIME john

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6c9a2913f437568b6f9fc121728c4c6f66f262cf.1453231719.git.john@keeping.me.uk \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).