Skip to content

Commit

Permalink
Fix <time> tag validity
Browse files Browse the repository at this point in the history
  • Loading branch information
w4 committed Jan 21, 2024
1 parent 235951b commit 460d607
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/methods/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
use std::borrow::Borrow;
use time::format_description::well_known::Rfc3339;

pub fn format_time(s: time::OffsetDateTime) -> Result<String, askama::Error> {
s.format(&Rfc3339)
pub fn format_time(s: impl Borrow<time::OffsetDateTime>) -> Result<String, askama::Error> {
(*s.borrow())
.format(&Rfc3339)
.map_err(Box::from)
.map_err(askama::Error::Custom)
}
Expand Down
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</td>
<td>
<a href="/{% if let Some(path) = path %}{{ path }}/{% endif %}{{ repository.name }}">
<time datetime="{{ repository.last_modified }}" title="{{ repository.last_modified }}">
<time datetime="{{ repository.last_modified|format_time }}" title="{{ repository.last_modified|format_time }}">
{{- repository.last_modified.clone()|timeago -}}
</time>
</a>
Expand Down
6 changes: 3 additions & 3 deletions templates/repo/macros/refs.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{{ commit.get().author.name }}
</td>
<td>
<time datetime="{{ commit.get().author.time }}" title="{{ commit.get().author.time }}">
<time datetime="{{ commit.get().author.time|format_time }}" title="{{ commit.get().author.time|format_time }}">
{{- commit.get().author.time|timeago -}}
</time>
</td>
Expand Down Expand Up @@ -50,7 +50,7 @@
</td>
<td>
{% if let Some(tagger) = tag.get().tagger -%}
<time datetime="{{ tagger.time }}" title="{{ tagger.time }}">
<time datetime="{{ tagger.time|format_time }}" title="{{ tagger.time|format_time }}">
{{- tagger.time|timeago -}}
</time>
{%- endif %}
Expand All @@ -74,7 +74,7 @@
{% set commit = commit.get() %}
<tr>
<td>
<time datetime="{{ commit.committer.time }}" title="{{ commit.committer.time }}">
<time datetime="{{ commit.committer.time|format_time }}" title="{{ commit.committer.time|format_time }}">
{{- commit.committer.time.clone()|timeago -}}
</time>
</td>
Expand Down

0 comments on commit 460d607

Please sign in to comment.