From 83cf97ecb3d9356de045c579fd403f2b3b9358be Mon Sep 17 00:00:00 2001 From: fosero Date: Mon, 22 Feb 2016 12:28:34 +0100 Subject: [PATCH] utils: let format_utc_offset handle microseconds format_utc_offset can be called with the return value of g_date_time_get_utc_offset returning microseconds in a gint64. It is also still called with the return value of icaltimezone_get_utc_offset in seconds. Deal with both. https://bugzilla.gnome.org/show_bug.cgi?id=762438 --- src/gcal-utils.c | 6 +++++- src/gcal-utils.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gcal-utils.c b/src/gcal-utils.c index 43e63ade..a42cda76 100644 --- a/src/gcal-utils.c +++ b/src/gcal-utils.c @@ -793,7 +793,7 @@ get_source_parent_name_color (GcalManager *manager, } gchar* -format_utc_offset (gint offset) +format_utc_offset (gint64 offset) { const char *sign = "+"; gint hours, minutes, seconds; @@ -803,6 +803,10 @@ format_utc_offset (gint offset) sign = "-"; } + /* offset can be seconds or microseconds */ + if (offset >= 1000000) + offset = offset / 1000000; + hours = offset / 3600; minutes = (offset % 3600) / 60; seconds = offset % 60; diff --git a/src/gcal-utils.h b/src/gcal-utils.h index 84cf6548..a5984aac 100644 --- a/src/gcal-utils.h +++ b/src/gcal-utils.h @@ -121,6 +121,6 @@ void get_source_parent_name_color (GcalManager gchar **name, gchar **color); -gchar* format_utc_offset (gint offset); +gchar* format_utc_offset (gint64 offset); #endif // __GCAL_UTILS_H__