diff --git a/src/main.rs b/src/main.rs index 952e278..fb6ea57 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use jiff::tz::TimeZone; -use jiff::Timestamp; +use jiff::{Timestamp, Unit}; use pleroma::Activities; use std::ffi::OsStr; use std::sync::OnceLock; @@ -227,7 +227,7 @@ markup::define! { div[class="activity-content"] { a[href=MAPPINGS.get().unwrap().get(&activity.id).and_then(|url| url.as_ref().map(|url| url.path()))] { - time[datetime=&activity.published] { @activity.human_published() } + time[datetime=&activity.datetime()] { @activity.human_published() } } @if let Some(in_reply_to) = &activity.in_reply_to { @@ -285,6 +285,17 @@ impl pleroma::Activity { published.strftime("%d %b %Y").to_string() } + + /// datetime for `time` element + fn datetime(&self) -> String { + let published = self + .published + .parse::() + .map(|ts| ts.round(Unit::Second).expect("rounding to succeeed")) + .expect("invalid published value"); + + published.to_string() + } } impl pleroma::Actor {