# HG changeset patch
# Node ID dc6b4ddcd317
# Parent  5c21747ff7dc
diff --git a/ChangeLog.API b/ChangeLog.API
--- a/ChangeLog.API
+++ b/ChangeLog.API
@@ -450,6 +450,7 @@ version 3.0.0 (??/??/????):
 		  or whatever is appropriate for your UI.
 		* purple_core_migrate
 		* Removed the general Purple DBus interface
+		* purple_date_format_full, use g_date_time_format instead.
 		* purple_date_format_long, use g_date_time_format instead.
 		* purple_date_format_short, use g_date_time_format instead.
 		* PurpleDebugUiOps
diff --git a/finch/gntdebug.c b/finch/gntdebug.c
--- a/finch/gntdebug.c
+++ b/finch/gntdebug.c
@@ -230,16 +230,24 @@ static void
 file_save(GntFileSel *fs, const char *path, const char *file, GntTextView *tv)
 {
 	FILE *fp;
+	GDateTime *date = NULL;
+	gchar *date_str = NULL;
 
 	if ((fp = g_fopen(path, "w+")) == NULL) {
 		purple_notify_error(NULL, NULL, _("Unable to open file."), NULL, NULL);
 		return;
 	}
 
-	fprintf(fp, "Finch Debug Log : %s\n", purple_date_format_full(NULL));
+	date = g_date_time_new_now_local();
+	date_str = g_date_time_format(date, "%c");
+
+	fprintf(fp, "Finch Debug Log : %s\n", date_str);
 	fprintf(fp, "%s", gnt_text_view_get_text(tv));
 	fclose(fp);
 	gnt_widget_destroy(GNT_WIDGET(fs));
+
+	g_free(date_str);
+	g_date_time_unref(date);
 }
 
 static void
diff --git a/libpurple/protocols/gg/chat.c b/libpurple/protocols/gg/chat.c
--- a/libpurple/protocols/gg/chat.c
+++ b/libpurple/protocols/gg/chat.c
@@ -586,21 +586,21 @@ ggp_chat_roomlist_get_list(PurpleProtoco
 		PurpleRoomlistRoom *room;
 		ggp_chat_local_info *chat = &sdata->chats[i];
 		const gchar *name;
-		time_t date;
+		GDateTime *date = NULL;
 		const gchar *status;
 		int count = chat->participants_count;
 
-		date = (uint32_t)(chat->id >> 32);
+		date = g_date_time_new_from_unix_local((uint32_t)(chat->id >> 32));
 
-		if (chat->conv)
+		if (chat->conv) {
 			status = _("Joined");
-		else if (chat->left)
+		} else if (chat->left) {
 			/* Translators: For Gadu-Gadu, this is one possible status for a
 			   chat room. It means you had previously joined the chat room but
 			   you have since left it. You cannot rejoin without another
 			   invitation. */
 			status = _("Chat left");
-		else {
+		} else {
 			status = _("Can join chat");
 			count--;
 		}
@@ -610,10 +610,11 @@ ggp_chat_roomlist_get_list(PurpleProtoco
 		purple_roomlist_room_set_user_count(room, (guint)count);
 		purple_roomlist_room_add_field(room, "id", g_strdup(name));
 		purple_roomlist_room_add_field(room, "date",
-		                               g_strdup(purple_date_format_full(localtime(&date))));
+		                               g_date_time_format(date, "%c"));
 		purple_roomlist_room_add_field(room, "status", g_strdup(status));
 		purple_roomlist_room_add(roomlist, room);
 		g_object_unref(room);
+		g_date_time_unref(date);
 	}
 
 	/* TODO
diff --git a/libpurple/protocols/gg/multilogon.c b/libpurple/protocols/gg/multilogon.c
--- a/libpurple/protocols/gg/multilogon.c
+++ b/libpurple/protocols/gg/multilogon.c
@@ -41,7 +41,7 @@ typedef struct
 	uint64_t id;
 	uint32_t remote_addr;
 	gchar *name;
-	time_t logon_time;
+	GDateTime *logon_time;
 } ggp_multilogon_session_info;
 
 struct _ggp_multilogon_session_data
@@ -82,8 +82,10 @@ ggp_multilogon_free_sessions(PurpleConne
 	ggp_multilogon_session_data *mldata = ggp_multilogon_get_mldata(gc);
 	int i;
 
-	for (i = 0; i < mldata->session_count; i++)
+	for (i = 0; i < mldata->session_count; i++) {
 		g_free(mldata->sessions[i].name);
+		g_clear_pointer(&mldata->sessions[i].logon_time, g_date_time_unref);
+	}
 	g_free(mldata->sessions);
 
 	mldata->sessions = NULL;
@@ -137,16 +139,19 @@ ggp_multilogon_fill_sessions(PurpleReque
 	for (i = 0; i < mldata->session_count; i++) {
 		ggp_multilogon_session_info *sess = &mldata->sessions[i];
 		PurpleRequestDatasheetRecord *rec;
+		gchar *tmp = NULL;
 
 		rec = purple_request_datasheet_record_add(sheet,
 			ggp_keymapper_to_key(km, sess->id));
 
 		purple_request_datasheet_record_set_string_data(rec, 0,
 			ggp_ipv4_to_str(sess->remote_addr));
-		purple_request_datasheet_record_set_string_data(rec, 1,
-			purple_date_format_full(localtime(&sess->logon_time)));
-		purple_request_datasheet_record_set_string_data(rec, 2,
-			sess->name);
+
+		tmp = g_date_time_format(sess->logon_time, "%c");
+		purple_request_datasheet_record_set_string_data(rec, 1, tmp);
+		g_free(tmp);
+
+		purple_request_datasheet_record_set_string_data(rec, 2, sess->name);
 	}
 
 	purple_request_datasheet_record_remove_marked(sheet);
@@ -171,7 +176,7 @@ ggp_multilogon_info(PurpleConnection *gc
 		psess->id = ggp_multilogon_sid_from_libgadu(lsess->id);
 		psess->remote_addr = lsess->remote_addr;
 		psess->name = g_strdup(lsess->name);
-		psess->logon_time = lsess->logon_time;
+		psess->logon_time = g_date_time_new_from_unix_local(lsess->logon_time);
 	}
 
 	mldata->session_count = info->count;
diff --git a/libpurple/protocols/irc/msgs.c b/libpurple/protocols/irc/msgs.c
--- a/libpurple/protocols/irc/msgs.c
+++ b/libpurple/protocols/irc/msgs.c
@@ -450,11 +450,19 @@ void irc_msg_endwhois(struct irc_conn *i
 		g_string_free(irc->whois.channels, TRUE);
 	}
 	if (irc->whois.idle) {
-		gchar *timex = purple_str_seconds_to_string(irc->whois.idle);
-		purple_notify_user_info_add_pair_plaintext(user_info, _("Idle for"), timex);
-		g_free(timex);
+		GDateTime *signon = NULL;
+
+		tmp = purple_str_seconds_to_string(irc->whois.idle);
+		purple_notify_user_info_add_pair_plaintext(user_info, _("Idle for"),
+		                                           tmp);
+		g_free(tmp);
+
+		signon = g_date_time_new_from_unix_local(irc->whois.signon);
+		tmp = g_date_time_format(signon, "%c");
 		purple_notify_user_info_add_pair_plaintext(user_info,
-														_("Online since"), purple_date_format_full(localtime(&irc->whois.signon)));
+		                                           _("Online since"), tmp);
+		g_free(tmp);
+		g_date_time_unref(signon);
 	}
 	if (purple_strequal(irc->whois.nick, "elb")) {
 		purple_notify_user_info_add_pair_plaintext(user_info,
diff --git a/libpurple/protocols/novell/novell.c b/libpurple/protocols/novell/novell.c
--- a/libpurple/protocols/novell/novell.c
+++ b/libpurple/protocols/novell/novell.c
@@ -1914,7 +1914,8 @@ static void
 	const char *secondary = NULL;
 	const char *name = NULL;
 	char *primary = NULL;
-	time_t gmt;
+	GDateTime *gmt = NULL;
+	gchar *gmt_str = NULL;
 
 	ur = nm_find_user_record(user, nm_event_get_source(event));
 	if (ur)
@@ -1923,10 +1924,11 @@ static void
 	if (name == NULL)
 		name = nm_event_get_source(event);
 
-	gmt = nm_event_get_gmt(event);
+	gmt = g_date_time_new_from_unix_local(nm_event_get_gmt(event));
+	gmt_str = g_date_time_format(gmt, "%c");
 	title = _("Invitation to Conversation");
 	primary = g_strdup_printf(_("Invitation from: %s\n\nSent: %s"),
-							  name, purple_date_format_full(localtime(&gmt)));
+	                          name, gmt_str);
 	secondary = _("Would you like to join the conversation?");
 
 	/* Set up params list for the callbacks
@@ -1947,6 +1949,8 @@ static void
 						_("Yes"), G_CALLBACK(_join_conference_cb),
 						_("No"), G_CALLBACK(_reject_conference_cb));
 
+	g_free(gmt_str);
+	g_date_time_unref(gmt);
 	g_free(primary);
 }
 
diff --git a/libpurple/util.h b/libpurple/util.h
--- a/libpurple/util.h
+++ b/libpurple/util.h
@@ -87,20 +87,6 @@ void purple_util_uninit(void);
 /**************************************************************************/
 
 /**
- * purple_date_format_full:
- * @tm: The time to format, or %NULL to use the current local time
- *
- * Formats a time into the user's preferred full date and time format.
- *
- * The returned string is stored in a static buffer, so the result
- * should be g_strdup()'d if it's going to be kept.
- *
- * Returns: The date and time, formatted as per the user's settings.  In the
- *         USA this is something like "Mon Feb 18 15:26:44 2013"
- */
-const char *purple_date_format_full(const struct tm *tm);
-
-/**
  * PURPLE_NO_TZ_OFF:
  *
  * Used by purple_str_to_time to indicate no timezone offset was
diff --git a/libpurple/util.c b/libpurple/util.c
--- a/libpurple/util.c
+++ b/libpurple/util.c
@@ -48,39 +48,6 @@ purple_util_uninit(void) {
 }
 
 /**************************************************************************
- * Date/Time Functions
- **************************************************************************/
-const char *
-purple_date_format_full(const struct tm *tm)
-{
-	static char buf[128];
-	GDateTime *dt;
-	char *utf8;
-
-	if (tm == NULL)
-	{
-		dt = g_date_time_new_now_local();
-	} else {
-		dt = g_date_time_new_local(tm->tm_year + 1900, tm->tm_mon + 1,
-				tm->tm_mday, tm->tm_hour,
-				tm->tm_min, tm->tm_sec);
-	}
-
-	utf8 = g_date_time_format(dt, "%c");
-	g_date_time_unref(dt);
-
-	if (utf8 == NULL) {
-		purple_debug_error("util",
-				"purple_date_format_full(): Formatting failed\n");
-		return "";
-	}
-
-	g_strlcpy(buf, utf8, sizeof(buf));
-	g_free(utf8);
-	return buf;
-}
-
-/**************************************************************************
  * Path/Filename Functions
  **************************************************************************/
 static gboolean
diff --git a/pidgin/pidgindebug.c b/pidgin/pidgindebug.c
--- a/pidgin/pidgindebug.c
+++ b/pidgin/pidgindebug.c
@@ -114,6 +114,8 @@ save_response_cb(GtkNativeDialog *self, 
 		GFile *file = NULL;
 		GFileOutputStream *output = NULL;
 		GtkTextIter start, end;
+		GDateTime *date = NULL;
+		gchar *date_str = NULL;
 		gchar *tmp = NULL;
 		GError *error = NULL;
 
@@ -131,10 +133,14 @@ save_response_cb(GtkNativeDialog *self, 
 			return;
 		}
 
-		tmp = g_strdup_printf("Pidgin Debug Log : %s\n", purple_date_format_full(NULL));
+		date = g_date_time_new_now_local();
+		date_str = g_date_time_format(date, "%c");
+
+		tmp = g_strdup_printf("Pidgin Debug Log : %s\n", date_str);
 		g_output_stream_write_all(G_OUTPUT_STREAM(output), tmp, strlen(tmp),
 		                          NULL, NULL, &error);
 		g_free(tmp);
+		g_free(date_str);
 
 		if(error != NULL) {
 			purple_debug_error("debug", "Unable to save debug log: %s",
