[gnome-packagekit] Port to GDateTime from deprecated GTimeVal
- From: Matthias Klumpp <mak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-packagekit] Port to GDateTime from deprecated GTimeVal
- Date: Tue, 27 Sep 2022 16:43:52 +0000 (UTC)
commit 1b7d288e2719a65a8ea793965311c91f3b7c682b
Author: Matthias Klumpp <matthias tenstral net>
Date: Tue Sep 27 18:42:48 2022 +0200
Port to GDateTime from deprecated GTimeVal
meson.build | 2 +-
src/gpk-log.c | 20 +++++++-------------
src/gpk-update-viewer.c | 7 +++----
3 files changed, 11 insertions(+), 18 deletions(-)
---
diff --git a/meson.build b/meson.build
index db7b68ec..fd7c3e05 100644
--- a/meson.build
+++ b/meson.build
@@ -79,7 +79,7 @@ foreach arg: test_link_args
endif
endforeach
-gio = dependency('gio-2.0', version : '>= 2.26')
+gio = dependency('gio-2.0', version : '>= 2.56')
gtk = dependency('gtk+-3.0', version : '>= 3.24')
packagekit = dependency('packagekit-glib2', version : '>= 0.9.1')
libm = cc.find_library('libm', required: false)
diff --git a/src/gpk-log.c b/src/gpk-log.c
index db11eb63..058cd2af 100644
--- a/src/gpk-log.c
+++ b/src/gpk-log.c
@@ -125,22 +125,16 @@ gpk_log_model_get_iter (GtkTreeModel *model, GtkTreeIter *iter, const gchar *id)
static gchar *
gpk_log_get_localised_date (const gchar *timespec)
{
- GDate *date;
- GTimeVal timeval;
- gchar buffer[100];
+ g_autoptr(GDateTime) date_time = NULL;
- /* the old date */
- g_time_val_from_iso8601 (timespec, &timeval);
-
- /* get printed string */
- date = g_date_new ();
- g_date_set_time_val (date, &timeval);
+ date_time = g_date_time_new_from_iso8601 (timespec, NULL);
+ if (date_time == NULL) {
+ g_warning ("failed to parse date %s", timespec);
+ return g_strdup (timespec);
+ }
/* TRANSLATORS: strftime formatted please */
- g_date_strftime (buffer, 100, _("%d %B %Y"), date);
-
- g_date_free (date);
- return g_strdup (buffer);
+ return g_date_time_format (date_time, _("%d %B %Y"));
}
static gchar *
diff --git a/src/gpk-update-viewer.c b/src/gpk-update-viewer.c
index faeb5d8c..535b46f1 100644
--- a/src/gpk-update-viewer.c
+++ b/src/gpk-update-viewer.c
@@ -524,7 +524,7 @@ gpk_update_viewer_compare_refs (GtkTreeRowReference *a, GtkTreeRowReference *b)
}
static gboolean
-gpk_update_viewer_pulse_active_rows (void)
+gpk_update_viewer_pulse_active_rows (gpointer user_data)
{
GSList *l;
GtkTreeRowReference *ref;
@@ -1631,20 +1631,19 @@ static gchar *
gpk_update_viewer_iso8601_format_locale_date (const gchar *iso_date)
{
g_autoptr(GDateTime) dt = NULL;
- GTimeVal timeval;
/* not valid */
if (iso_date == NULL || iso_date[0] == '\0')
return NULL;
/* parse ISO8601 date */
- if (!g_time_val_from_iso8601 (iso_date, &timeval)) {
+ dt = g_date_time_new_from_iso8601 (iso_date, NULL);
+ if (dt == NULL) {
g_warning ("failed to parse %s, falling back to ISO8601", iso_date);
return g_strdup (iso_date);
}
/* convert to a date object */
- dt = g_date_time_new_from_timeval_utc (&timeval);
return g_date_time_format (dt, "%x");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]