[gnome-control-center/wip/kate/improve-datetime] firmware-security: improve datetime format parsing




commit 815886033d7637104b071d387d9aa9ac58a3b05f
Author: Kate Hsuan <hpa redhat com>
Date:   Tue Aug 30 17:51:02 2022 +0800

    firmware-security: improve datetime format parsing
    
    1. Be able to show "Today" and "Yesterday".
    2. The time format will be "\%H:\%m:\%S" (22:10:00 AM)

 panels/firmware-security/cc-firmware-security-panel.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/panels/firmware-security/cc-firmware-security-panel.c 
b/panels/firmware-security/cc-firmware-security-panel.c
index 8a5bb5e9a..a0321db64 100644
--- a/panels/firmware-security/cc-firmware-security-panel.c
+++ b/panels/firmware-security/cc-firmware-security-panel.c
@@ -164,6 +164,16 @@ fu_security_attr_get_description_for_eventlog (FwupdSecurityAttr *attr)
   return g_string_free (str, FALSE);
 }
 
+static gchar *
+get_smart_date_time (GDateTime *date)
+{
+  if (date == NULL)
+    return NULL;
+
+  return g_strdup_printf ("%s, %s", cc_util_get_smart_date (date),
+                          g_date_time_format (date, "\%H:\%m:\%S"));
+}
+
 static void
 parse_event_variant_iter (CcfirmwareSecurityPanel *self,
                           GVariantIter            *iter)
@@ -184,7 +194,7 @@ parse_event_variant_iter (CcfirmwareSecurityPanel *self,
 
   /* build new row */
   date = g_date_time_new_from_unix_local (attr->timestamp);
-  date_string = g_date_time_format (date, "\%F \%H:\%m:\%S");
+  date_string = get_smart_date_time (date);
 
   row = adw_expander_row_new ();
   if (attr->flags & FWUPD_SECURITY_ATTR_FLAG_SUCCESS)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]