make dates rendered server-side & consistently in YYYY-MM-DD format
client-side time zone adjustment still persists---the server renders them out in UTC, but the client will adjust the date to its timezone during loading. this shouldn't cause any layout shifting because we use `font-variant-numeric: tabular-nums` (though Recursive seems to use tabular numbers either way.)
This commit is contained in:
parent
81373b1076
commit
1953b649cf
3 changed files with 20 additions and 5 deletions
|
@ -1,6 +1,8 @@
|
|||
use std::{borrow::Cow, fmt::Write};
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use treehouse_format::pull::BranchKind;
|
||||
use ulid::Ulid;
|
||||
|
||||
use crate::{
|
||||
config::Config,
|
||||
|
@ -153,6 +155,15 @@ pub fn branch_to_html(
|
|||
|
||||
s.push_str("<th-bb>");
|
||||
{
|
||||
if let Some(date_time) = Ulid::from_string(&branch.attributes.id)
|
||||
.ok()
|
||||
.as_ref()
|
||||
.map(Ulid::timestamp_ms)
|
||||
.and_then(|ms| DateTime::from_timestamp_millis(ms as i64))
|
||||
{
|
||||
write!(s, "<th-bd>{}</th-bd>", date_time.format("%F")).unwrap();
|
||||
}
|
||||
|
||||
if let Content::ResolvedLink(file_id) = &branch.attributes.content {
|
||||
let path = treehouse.tree_path(*file_id).expect(".tree file expected");
|
||||
write!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue