Diff options
Diffstat (limited to 'source')
-rw-r--r--source/ui-commit.c8
-rw-r--r--source/ui-shared.c9
-rw-r--r--source/ui-shared.h6
-rw-r--r--source/ui-tag.c8
4 files changed, 21 insertions, 10 deletions
diff --git a/source/ui-commit.c b/source/ui-commit.c
index 8e88faf..0916c33 100644
--- a/source/ui-commit.c
+++ b/source/ui-commit.c
@@ -31,11 +31,9 @@ static void print_ident_row(const char *role, const char *name, const char *emai
{
htmlf("<tr><th scope='row'>%s</th><td>", role);
cgit_print_person(name, email, "commit", 1);
- html("</td><td class='right'><time datetime='");
- html_attr(show_date(date, tz, cgit_date_mode(DATE_ISO8601_STRICT)));
- html("'>");
- html_txt(show_date(date, tz, cgit_date_mode(DATE_ISO8601)));
- html("</time></td></tr>\n");
+ html("</td><td class='right'>");
+ cgit_print_date(date, tz);
+ html("</td></tr>\n");
}
/*
diff --git a/source/ui-shared.c b/source/ui-shared.c
index 8c5e4e5..5e2a9de 100644
--- a/source/ui-shared.c
+++ b/source/ui-shared.c
@@ -1308,6 +1308,15 @@ void cgit_print_age(time_t t, int tz, time_t max_relative)
print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_YEAR, "age-years", "years");
}
+void cgit_print_date(timestamp_t date, int tz)
+{
+ html("<time datetime='");
+ html_attr(show_date(date, tz, cgit_date_mode(DATE_ISO8601_STRICT)));
+ html("'>");
+ html_txt(show_date(date, tz, cgit_date_mode(DATE_ISO8601)));
+ html("</time>");
+}
+
void cgit_print_person(const char *name, const char *email, const char *origin, int show_email)
{
cgit_open_filter(ctx.repo->email_filter, email ? email : "", origin);
diff --git a/source/ui-shared.h b/source/ui-shared.h
index 6b58ab3..ee350f0 100644
--- a/source/ui-shared.h
+++ b/source/ui-shared.h
@@ -109,6 +109,12 @@ extern struct date_mode cgit_date_mode(enum date_mode_type type);
extern void cgit_print_age(time_t t, int tz, time_t max_relative);
/*
+ * Print date as a <time> element, readable on the page and exact in its
+ * datetime attribute.
+ */
+extern void cgit_print_date(timestamp_t date, int tz);
+
+/*
* Print name through the email filter, followed by the address when
* show_email is set and enable-plain-email is on. A missing address reaches
* the filter as an empty string, since a filter must not be handed NULL.
diff --git a/source/ui-tag.c b/source/ui-tag.c
index 66ddf66..d60a58e 100644
--- a/source/ui-tag.c
+++ b/source/ui-tag.c
@@ -26,11 +26,9 @@ static void print_name_row(const char *revname, const struct object_id *oid)
static void print_date_row(struct taginfo *info)
{
- html("<tr><th scope='row'>tag date</th><td><time datetime='");
- html_attr(show_date(info->tagger_date, info->tagger_tz, cgit_date_mode(DATE_ISO8601_STRICT)));
- html("'>");
- html_txt(show_date(info->tagger_date, info->tagger_tz, cgit_date_mode(DATE_ISO8601)));
- html("</time></td></tr>\n");
+ html("<tr><th scope='row'>tag date</th><td>");
+ cgit_print_date(info->tagger_date, info->tagger_tz);
+ html("</td></tr>\n");
}
static void print_tagger_row(struct taginfo *info)