Ejemplo n.º 1
0
static gboolean
iter_get_time (GVariant *variant,
	       gulong attr_type,
	       GckBuilder *builder)
{
	time_t time;
	struct tm tm;
	gchar buf[20];
	guint64 value;

	g_assert (variant != NULL);
	g_assert (builder != NULL);

	value = g_variant_get_uint64 (variant);
	if (value == 0) {
		gck_builder_add_empty (builder, attr_type);
		return TRUE;
	}

	time = value;
	if (!gmtime_r (&time, &tm))
		g_return_val_if_reached (FALSE);

	if (!strftime (buf, sizeof (buf), "%Y%m%d%H%M%S00", &tm))
		g_return_val_if_reached (FALSE);

	gck_builder_add_data (builder, attr_type, (const guchar *)buf, 16);
	return TRUE;
}
Ejemplo n.º 2
0
static gboolean
iter_get_time (DBusMessageIter *iter,
               gulong attr_type,
               GckBuilder *builder)
{
	time_t time;
	struct tm tm;
	gchar buf[20];
	guint64 value;

	g_assert (iter != NULL);
	g_assert (builder != NULL);

	g_return_val_if_fail (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_UINT64, FALSE);
	dbus_message_iter_get_basic (iter, &value);
	if (value == 0) {
		gck_builder_add_empty (builder, attr_type);
		return TRUE;
	}

	time = value;
	if (!gmtime_r (&time, &tm))
		g_return_val_if_reached (FALSE);

	if (!strftime (buf, sizeof (buf), "%Y%m%d%H%M%S00", &tm))
		g_return_val_if_reached (FALSE);

	gck_builder_add_data (builder, attr_type, (const guchar *)buf, 16);
	return TRUE;
}