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




commit c33b5ff66254f8d6271a41431f7bfca321fe1bc2
Author: Kate Hsuan <hpa redhat com>
Date:   Mon Aug 29 11:46:53 2022 +0800

    firmware-security: improve datetime format parsing
    
    1. Be able to show "Today" and "Yesterday".
    2. The time format will be "\%l:\%m:\%S \%p" (10:10:00 AM)
    
    Fixes: https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/2034

 panels/firmware-security/cc-firmware-security-panel.c | 9 ++++++++-
 1 file changed, 8 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..f3ec8ec9a 100644
--- a/panels/firmware-security/cc-firmware-security-panel.c
+++ b/panels/firmware-security/cc-firmware-security-panel.c
@@ -169,7 +169,10 @@ parse_event_variant_iter (CcfirmwareSecurityPanel *self,
                           GVariantIter            *iter)
 {
   g_autofree gchar *date_string = NULL;
+  g_autofree gchar *date_str = NULL;
+  g_autofree gchar *time_str = NULL;
   g_autoptr (GDateTime) date = NULL;
+  g_autoptr (GDateTime) now_date = NULL;
   g_autoptr (FwupdSecurityAttr) attr = fu_security_attr_new_from_variant(iter);
   GtkWidget *row;
 
@@ -184,7 +187,11 @@ 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_str = cc_util_get_smart_date (date);
+
+  time_str = g_date_time_format (date, "\%l:\%m:\%S \%p");
+
+  date_string = g_strdup_printf ("%s, %s", date_str, time_str);
 
   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]