Round value placed in datatime attribute

Fixes #1
This commit is contained in:
Wesley Moore 2024-11-24 17:19:41 +10:00
parent b5a249b756
commit 7a6fdbef14
No known key found for this signature in database

View file

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