feat(settings): show note full date

This commit is contained in:
Fernando López Guevara
2025-07-23 17:49:33 -03:00
parent 6a08d4b1b2
commit ab84304265
9 changed files with 29 additions and 14 deletions

View File

@@ -49,6 +49,7 @@ once_cell = { workspace = true }
md5 = { workspace = true }
bitflags = { workspace = true }
regex = "1"
chrono = { workspace = true }
[dev-dependencies]
tempfile = { workspace = true }

View File

@@ -80,6 +80,7 @@ pub use storage::{AccountStorage, DataPath, DataPathType, Directory};
pub use style::NotedeckTextStyle;
pub use theme::ColorTheme;
pub use time::time_ago_since;
pub use time::time_format;
pub use timecache::TimeCached;
pub use unknowns::{get_unknown_note_ids, NoteRefsUnkIdAction, SingleUnkIdAction, UnknownIds};
pub use urls::{supported_mime_hosted_at_url, SupportedMimeType, UrlMimes};

View File

@@ -1,4 +1,5 @@
use crate::{tr, Localization};
use chrono::DateTime;
use std::time::{SystemTime, UNIX_EPOCH};
// Time duration constants in seconds
@@ -83,6 +84,14 @@ fn time_ago_between(i18n: &mut Localization, timestamp: u64, now: u64) -> String
}
}
pub fn time_format(_i18n: &mut Localization, timestamp: i64) -> String {
// TODO: format this using the selected locale
DateTime::from_timestamp(timestamp, 0)
.unwrap()
.format("%Y-%m-%d %H:%M:%S")
.to_string()
}
pub fn time_ago_since(i18n: &mut Localization, timestamp: u64) -> String {
let now = SystemTime::now()
.duration_since(UNIX_EPOCH)