Use relative timestamps everywhere instead of raw date strings

This commit is contained in:
lashman
2026-02-28 01:52:56 +02:00
parent 5254de4a52
commit 7697983045
2 changed files with 4 additions and 16 deletions

View File

@@ -302,20 +302,8 @@ fn build_updates_summary_group(db: &Rc<Database>) -> adw::PreferencesGroup {
let last_check = settings.string("last-update-check");
let last_label = if last_check.is_empty() {
"Never".to_string()
} else if let Ok(ts) = chrono::NaiveDateTime::parse_from_str(last_check.as_str(), "%Y-%m-%d %H:%M:%S") {
let now = chrono::Utc::now().naive_utc();
let elapsed = now.signed_duration_since(ts);
if elapsed.num_minutes() < 1 {
"Just now".to_string()
} else if elapsed.num_hours() < 1 {
format!("{}m ago", elapsed.num_minutes())
} else if elapsed.num_hours() < 24 {
format!("{}h ago", elapsed.num_hours())
} else {
format!("{}d ago", elapsed.num_days())
}
} else {
"Unknown".to_string()
widgets::relative_time(&last_check)
};
let last_row = adw::ActionRow::builder()
.title("Last checked")

View File

@@ -723,7 +723,7 @@ fn build_overview_tab(record: &AppImageRecord, db: &Rc<Database>) -> gtk::Box {
if let Some(ref last) = stats.last_launched {
let row = adw::ActionRow::builder()
.title("Last launched")
.subtitle(last)
.subtitle(&widgets::relative_time(last))
.build();
usage_group.add(&row);
}
@@ -853,13 +853,13 @@ fn build_overview_tab(record: &AppImageRecord, db: &Rc<Database>) -> gtk::Box {
let seen_row = adw::ActionRow::builder()
.title("First seen")
.subtitle(&record.first_seen)
.subtitle(&widgets::relative_time(&record.first_seen))
.build();
info_group.add(&seen_row);
let scanned_row = adw::ActionRow::builder()
.title("Last checked")
.subtitle(&record.last_scanned)
.subtitle(&widgets::relative_time(&record.last_scanned))
.build();
info_group.add(&scanned_row);