Use relative timestamps everywhere instead of raw date strings
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user