From df2bd378372f6460d421ca98a5144973cf7e2326 Mon Sep 17 00:00:00 2001 From: Kate Hsuan Date: Wed, 31 Aug 2022 10:38:04 +0800 Subject: [PATCH] panels: cc-util: a smart date time Convert the DateTime to string with time. The format will be: smart_date, \%X --- panels/common/cc-util.c | 12 ++++++++++++ panels/common/cc-util.h | 1 + 2 files changed, 13 insertions(+) diff --git a/panels/common/cc-util.c b/panels/common/cc-util.c index 9418d5607..cdad785c4 100644 --- a/panels/common/cc-util.c +++ b/panels/common/cc-util.c @@ -145,6 +145,18 @@ cc_util_get_smart_date (GDateTime *date) } } +char * +cc_util_get_smart_date_time (GDateTime *date) +{ + g_autofree gchar *date_str = NULL; + + if (date == NULL) + return NULL; + + date_str = g_date_time_format (date, "\%X"); + return g_strdup_printf ("%s, %s", cc_util_get_smart_date (date), date_str); +} + /* Copied from src/plugins/properties/bacon-video-widget-properties.c * in totem */ char * diff --git a/panels/common/cc-util.h b/panels/common/cc-util.h index 131c2afb7..3606703c3 100644 --- a/panels/common/cc-util.h +++ b/panels/common/cc-util.h @@ -24,4 +24,5 @@ char * cc_util_normalize_casefold_and_unaccent (const char *str); char * cc_util_get_smart_date (GDateTime *date); +char * cc_util_get_smart_date_time (GDateTime *date); char * cc_util_time_to_string_text (gint64 msecs);