From 8adfd0b966455491f94ed832ee34cb5078008b62 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sun, 6 Jul 2014 00:44:43 +0200 Subject: [PATCH] Fix error that makes class init fail on machines with UTC as time zone For a more universal solution, the default values for a GsweTimestamp are set according to the current UTC time, with time zone also set to UTC. --- src/gswe-timestamp.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gswe-timestamp.c b/src/gswe-timestamp.c index a2292b1..6d7353d 100644 --- a/src/gswe-timestamp.c +++ b/src/gswe-timestamp.c @@ -94,8 +94,7 @@ static void gswe_timestamp_class_init(GsweTimestampClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - GDateTime *local_time = g_date_time_new_now_local(); - GTimeZone *local_timezone = g_time_zone_new_local(); + GDateTime *local_time = g_date_time_new_now_utc(); g_type_class_add_private(klass, sizeof(GsweTimestampPrivate)); @@ -186,7 +185,18 @@ gswe_timestamp_class_init(GsweTimestampClass *klass) * * The time zone offset in hours, relative to UTC */ - g_object_class_install_property(gobject_class, PROP_GREGORIAN_TIMEZONE_OFFSET, g_param_spec_double("gregorian-timezone-offset", "Gregorian timezone offset", "The offset relative to UTC in the Gregorian calendar", -24.0, 24.0, g_time_zone_get_offset(local_timezone, 1) / 3600.0, G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + g_object_class_install_property( + gobject_class, + PROP_GREGORIAN_TIMEZONE_OFFSET, + g_param_spec_double( + "gregorian-timezone-offset", + "Gregorian timezone offset", + "The offset relative to UTC in the Gregorian calendar", + -24.0, 24.0, + 0.0, + G_PARAM_CONSTRUCT | G_PARAM_READWRITE + ) + ); /** * GsweTimestamp:julian-day-valid: