static void
chat_text_maybe_append_date_and_time (EmpathyChatTextView *view,
				      time_t               timestamp)
{
	EmpathyChatTextViewPriv *priv = GET_PRIV (view);
	GDate                   *date, *last_date;
	gboolean                 append_date = FALSE;
	gboolean                 append_time = FALSE;

	/* Get the date from last message */
	last_date = g_date_new ();
	g_date_set_time_t (last_date, priv->last_timestamp);

	/* Get the date of the message we are appending */
	date = g_date_new ();
	g_date_set_time_t (date, timestamp);

	/* If last message was from another day we append date and time */
	if (g_date_compare (date, last_date) > 0) {
		append_date = TRUE;
		append_time = TRUE;
	}
	
	g_date_free (last_date);
	g_date_free (date);

	/* If last message is 'old' append the time */
	if (timestamp - priv->last_timestamp >= TIMESTAMP_INTERVAL) {
		append_time = TRUE;
	}

	if (append_date || (!priv->only_if_date && append_time)) {
		chat_text_view_append_timestamp (view, timestamp, append_date);
	}
}
static void
chat_text_maybe_append_date_and_time (EmpathyChatTextView *view,
				      gint64               timestamp)
{
	EmpathyChatTextViewPriv *priv = GET_PRIV (view);
	GDateTime               *date, *last_date;
	gboolean                 append_date = FALSE;
	gboolean                 append_time = FALSE;
	GTimeSpan                delta;

	/* Get the date from last message */
	last_date = g_date_time_new_from_unix_utc (priv->last_timestamp);

	/* Get the date of the message we are appending */
	date = g_date_time_new_from_unix_utc (timestamp);

	delta = g_date_time_difference (date, last_date);
	/* If last message was from another day we append date and time */
	if (delta >= G_TIME_SPAN_DAY) {
		append_date = TRUE;
		append_time = TRUE;
	}

	g_date_time_unref (last_date);
	g_date_time_unref (date);

	/* If last message is 'old' append the time */
	if (delta >= TIMESTAMP_INTERVAL) {
		append_time = TRUE;
	}

	if (append_date || (!priv->only_if_date && append_time)) {
		chat_text_view_append_timestamp (view, timestamp, append_date);
	}
}