[gnome-calendar] utils: let format_utc_offset handle microseconds



commit 83cf97ecb3d9356de045c579fd403f2b3b9358be
Author: fosero <fosero users noreply github com>
Date:   Mon Feb 22 12:28:34 2016 +0100

    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 43e63ad..a42cda7 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 84cf654..a5984aa 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__


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]