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
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
83c9d27d90
commit
83cf97ecb3
+5
-1
@@ -793,7 +793,7 @@ get_source_parent_name_color (GcalManager *manager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gchar*
|
gchar*
|
||||||
format_utc_offset (gint offset)
|
format_utc_offset (gint64 offset)
|
||||||
{
|
{
|
||||||
const char *sign = "+";
|
const char *sign = "+";
|
||||||
gint hours, minutes, seconds;
|
gint hours, minutes, seconds;
|
||||||
@@ -803,6 +803,10 @@ format_utc_offset (gint offset)
|
|||||||
sign = "-";
|
sign = "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* offset can be seconds or microseconds */
|
||||||
|
if (offset >= 1000000)
|
||||||
|
offset = offset / 1000000;
|
||||||
|
|
||||||
hours = offset / 3600;
|
hours = offset / 3600;
|
||||||
minutes = (offset % 3600) / 60;
|
minutes = (offset % 3600) / 60;
|
||||||
seconds = offset % 60;
|
seconds = offset % 60;
|
||||||
|
|||||||
+1
-1
@@ -121,6 +121,6 @@ void get_source_parent_name_color (GcalManager
|
|||||||
gchar **name,
|
gchar **name,
|
||||||
gchar **color);
|
gchar **color);
|
||||||
|
|
||||||
gchar* format_utc_offset (gint offset);
|
gchar* format_utc_offset (gint64 offset);
|
||||||
|
|
||||||
#endif // __GCAL_UTILS_H__
|
#endif // __GCAL_UTILS_H__
|
||||||
|
|||||||
Reference in New Issue
Block a user