Display timestamp human readable

This commit is contained in:
clerie 2025-02-09 22:18:43 +01:00
parent b6adc918c6
commit bfbecb87d9
2 changed files with 12 additions and 1 deletions

View File

@ -2,6 +2,10 @@ use anyhow::{
Context, Context,
Result, Result,
}; };
use chrono::{
DateTime,
Utc,
};
use crate::utils::{ use crate::utils::{
urlencode, urlencode,
}; };
@ -147,6 +151,13 @@ impl RevisionRow {
None => String::from("#"), None => String::from("#"),
} }
} }
pub fn last_modified_time(&self) -> Option<DateTime<Utc>> {
match &self.last_modified {
Some(last_modified) => DateTime::from_timestamp(last_modified.clone(), 0),
None => None,
}
}
} }
#[derive(FromRow)] #[derive(FromRow)]

View File

@ -11,7 +11,7 @@
<ul> <ul>
{% for revision in revisions %} {% for revision in revisions %}
<li><a href="{{ revision.revision_link() }}">{{ revision.revision_uri }}</a> {% match revision.last_modified %}{% when Some with (last_modified) %}({{ last_modified }}){% when None %}{% endmatch %}</li> <li><a href="{{ revision.revision_link() }}">{{ revision.revision_uri }}</a> {% match revision.last_modified_time() %}{% when Some with (last_modified_time) %}({{ last_modified_time }}){% when None %}{% endmatch %}</li>
{% endfor %} {% endfor %}
</ul> </ul>