[gnome-control-center/wip/kate/improve-datetime: 1/2] panels: cc-util: a smart date time
- From: Kate Hsuan <khsuan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/kate/improve-datetime: 1/2] panels: cc-util: a smart date time
- Date: Wed, 31 Aug 2022 02:44:12 +0000 (UTC)
commit 145eb80277af9ea37608b95283ac78f676f9a8c3
Author: Kate Hsuan <hpa redhat com>
Date: Wed Aug 31 10:38:04 2022 +0800
panels: cc-util: a smart date time
Convert the DateTime to string with time in 24H format. For example:
1. Aug 1, 10:10:00
2. Today, 10:10:00
3. Yesterday, 10:10:00
panels/common/cc-util.c | 10 ++++++++++
panels/common/cc-util.h | 1 +
2 files changed, 11 insertions(+)
---
diff --git a/panels/common/cc-util.c b/panels/common/cc-util.c
index 9418d5607..649d84a52 100644
--- a/panels/common/cc-util.c
+++ b/panels/common/cc-util.c
@@ -145,6 +145,16 @@ cc_util_get_smart_date (GDateTime *date)
}
}
+char *
+cc_util_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"));
+}
+
/* 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]