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




commit 6c491dcfb81fcd3e9c3b4404ffbc297a4d303c7b
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 | 8 +++++++-
 1 file changed, 7 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..8b45fe393 100644
--- a/panels/firmware-security/cc-firmware-security-panel.c
+++ b/panels/firmware-security/cc-firmware-security-panel.c
@@ -169,6 +169,8 @@ 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 (FwupdSecurityAttr) attr = fu_security_attr_new_from_variant(iter);
   GtkWidget *row;
@@ -184,7 +186,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]