[gnome-notes/133-gtimeval-deprecation] memo-provider: GTimeVal Deprecation
- From: Isaque Galdino de Araujo <igaldino src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-notes/133-gtimeval-deprecation] memo-provider: GTimeVal Deprecation
- Date: Wed, 16 Oct 2019 02:33:17 +0000 (UTC)
commit 47b51f50ef04b15ff23aa8d1c8c4bd331d5deb12
Author: Isaque Galdino <igaldino gmail com>
Date: Tue Oct 15 23:31:59 2019 -0300
memo-provider: GTimeVal Deprecation
src/libbiji/provider/biji-memo-provider.c | 36 +++++++++++--------------------
1 file changed, 13 insertions(+), 23 deletions(-)
---
diff --git a/src/libbiji/provider/biji-memo-provider.c b/src/libbiji/provider/biji-memo-provider.c
index 157ca29..f4d0031 100644
--- a/src/libbiji/provider/biji-memo-provider.c
+++ b/src/libbiji/provider/biji-memo-provider.c
@@ -74,25 +74,22 @@ static GParamSpec *properties[BIJI_MEMO_PROP] = { NULL, };
gboolean
time_val_from_icaltime (ICalTime *itt, glong *result)
{
- GTimeVal t;
- gchar *iso;
+ g_autoptr(GDateTime) t = NULL;
+ g_autofree char *iso = NULL;
if (!itt)
return FALSE;
- t.tv_sec = 0;
- t.tv_usec = 0;
-
iso = isodate_from_time_t (i_cal_time_as_timet (itt));
- if (g_time_val_from_iso8601 (iso, &t))
- {
- *result = t.tv_sec;
- g_free (iso);
- return TRUE;
- }
+ t = g_date_time_new_from_iso8601 (iso, NULL);
+ if (t == NULL)
+ {
+ return FALSE;
+ }
- return FALSE;
+ *result = g_date_time_to_unix (t);
+ return TRUE;
}
@@ -100,20 +97,13 @@ time_val_from_icaltime (ICalTime *itt, glong *result)
ICalTime *
icaltime_from_time_val (glong t)
{
- GTimeVal tv;
- GDate *date;
+ g_autoptr(GDateTime) tv = NULL;
ICalTime *out;
- tv.tv_sec = t;
- tv.tv_usec = 0;
-
- date = g_date_new ();
- g_date_set_time_val (date, &tv);
- out = i_cal_time_new_from_day_of_year (
- g_date_get_day_of_year (date),
- g_date_get_year (date));
+ tv = g_date_time_new_from_unix_utc (t);
+ out = i_cal_time_new_from_day_of_year (g_date_time_get_day_of_year (tv),
+ g_date_time_get_year (tv));
- g_date_free (date);
return out;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]