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_check = settings.string("last-update-check");
let last_label = if last_check.is_empty() { let last_label = if last_check.is_empty() {
"Never".to_string() "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 { } else {
"Unknown".to_string() widgets::relative_time(&last_check)
}; };
let last_row = adw::ActionRow::builder() let last_row = adw::ActionRow::builder()
.title("Last checked") .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 { if let Some(ref last) = stats.last_launched {
let row = adw::ActionRow::builder() let row = adw::ActionRow::builder()
.title("Last launched") .title("Last launched")
.subtitle(last) .subtitle(&widgets::relative_time(last))
.build(); .build();
usage_group.add(&row); 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() let seen_row = adw::ActionRow::builder()
.title("First seen") .title("First seen")
.subtitle(&record.first_seen) .subtitle(&widgets::relative_time(&record.first_seen))
.build(); .build();
info_group.add(&seen_row); info_group.add(&seen_row);
let scanned_row = adw::ActionRow::builder() let scanned_row = adw::ActionRow::builder()
.title("Last checked") .title("Last checked")
.subtitle(&record.last_scanned) .subtitle(&widgets::relative_time(&record.last_scanned))
.build(); .build();
info_group.add(&scanned_row); info_group.add(&scanned_row);