--- a/ChangeLog.API Mon Oct 12 20:54:13 2020 -0500
+++ b/ChangeLog.API Mon Oct 12 20:57:09 2020 -0500
@@ -369,6 +369,8 @@
or whatever is appropriate for your UI.
* Removed the general Purple DBus interface
+ * purple_date_format_long, use g_date_time_format instead. + * purple_date_format_short, use g_date_time_format instead. * purple_dnsquery_a_account
* purple_event_loop_{get|set}_ui_ops. Manually drive the GLib
event loop yourself. See GLib Main Event Loop docs.
@@ -513,6 +515,8 @@
* purple_str_has_prefix. Use g_str_has_prefix instead
* purple_str_has_suffix. Use g_str_has_suffix instead
* purple_str_size_to_units. Use g_format_size() instead.
+ * purple_time_build. Use g_date_time_new* instead. + * purple_time_format. Use g_date_time_format instead. * purple_timeout_*. Use g_timeout_* or g_idle_* instead.
* purple_txt_resolve_account
--- a/libpurple/protocols/irc/msgs.c Mon Oct 12 20:54:13 2020 -0500
+++ b/libpurple/protocols/irc/msgs.c Mon Oct 12 20:57:09 2020 -0500
@@ -606,8 +606,8 @@
void irc_msg_topicinfo(struct irc_conn *irc, const char *name, const char *from, char **args)
PurpleChatConversation *chat;
char *msg, *timestamp, *datestamp;
chat = purple_conversations_find_chat_with_account(args[1], irc->account);
@@ -616,21 +616,30 @@
- t = (time_t)atol(args[3]);
+ mtime = g_ascii_strtoll(args[3], NULL, 10); + if(mtime == 0 || mtime == G_MININT64 || mtime == G_MAXINT64) { purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got apparently nonsensical topic timestamp %s\n", args[3]);
- timestamp = g_strdup(purple_time_format(tm));
- datestamp = g_strdup(purple_date_format_short(tm));
+ dt = g_date_time_new_from_unix_utc(mtime); + purple_debug(PURPLE_DEBUG_ERROR, "irc", "Failed to turn %" G_GINT64_FORMAT " into a GDateTime\n", mtime); + local = g_date_time_to_local(dt); + timestamp = g_date_time_format(local, "%X"); + datestamp = g_date_time_format(local, "%x"); msg = g_strdup_printf(_("Topic for %s set by %s at %s on %s"), args[1], args[2], timestamp, datestamp);
purple_conversation_write_system_message(PURPLE_CONVERSATION(chat),
msg, PURPLE_MESSAGE_NO_LINKIFY);
+ g_date_time_unref(local); void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args)
--- a/libpurple/protocols/jabber/buddy.c Mon Oct 12 20:54:13 2020 -0500
+++ b/libpurple/protocols/jabber/buddy.c Mon Oct 12 20:57:09 2020 -0500
@@ -739,17 +739,17 @@
if (jbr && jbr->tz_off != PURPLE_NO_TZ_OFF) {
+ char *timestamp = NULL; - timestamp = g_strdup_printf("%s %c%02d%02d", purple_time_format(now),
- jbr->tz_off < 0 ? '-' : '+',
- abs((int)(jbr->tz_off / (60 * 60))),
- abs((int)((jbr->tz_off % (60 * 60)) / 60)));
+ tz = g_time_zone_new_offset(jbr->tz_off); + dt = g_date_time_new_now(tz); + timestamp = g_date_time_format(dt, "%X %:z"); purple_notify_user_info_prepend_pair_plaintext(user_info, _("Local Time"), timestamp);
--- a/libpurple/util.c Mon Oct 12 20:54:13 2020 -0500
+++ b/libpurple/util.c Mon Oct 12 20:57:09 2020 -0500
@@ -101,50 +101,11 @@
-purple_date_format_short(const struct tm *tm)
- return purple_utf8_strftime("%x", tm);
-purple_date_format_long(const struct tm *tm)
- * This string determines how some dates are displayed. The default
- * string "%x %X" shows the date then the time. Translators can
- * change this to "%X %x" if they want the time to be shown first,
- * followed by the date.
- return purple_utf8_strftime(_("%x %X"), tm);
purple_date_format_full(const struct tm *tm)
return purple_utf8_strftime("%c", tm);
-purple_time_format(const struct tm *tm)
- return purple_utf8_strftime("%X", tm);
-purple_time_build(int year, int month, int day, int hour, int min, int sec)
- tm.tm_year = year - 1900;
- tm.tm_sec = sec >= 0 ? sec : time(NULL) % 60;
/* originally taken from GLib trunk 1-6-11 */
/* originally licensed as LGPL 2+ */
--- a/libpurple/util.h Mon Oct 12 20:54:13 2020 -0500
+++ b/libpurple/util.h Mon Oct 12 20:57:09 2020 -0500
@@ -125,34 +125,6 @@
const char *purple_utf8_strftime(const char *format, const struct tm *tm);
- * purple_date_format_short:
- * @tm: The time to format, or %NULL to use the current local time
- * Formats a time into the user's preferred short date 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, formatted as per the user's settings. In the USA this
- * is something like "02/18/13"
-const char *purple_date_format_short(const struct tm *tm);
- * purple_date_format_long:
- * @tm: The time to format, or %NULL to use the current local time
- * Formats a time into the user's preferred short date plus 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 timestamp, formatted as per the user's settings. In the USA
- * this is something like "02/18/13 15:26:44"
-const char *purple_date_format_long(const struct tm *tm);
* purple_date_format_full:
* @tm: The time to format, or %NULL to use the current local time
@@ -167,36 +139,6 @@
const char *purple_date_format_full(const struct tm *tm);
- * @tm: The time to format, or %NULL to use the current local time
- * Formats a time into the user's preferred 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 time, formatted as per the user's settings. In the USA this
- * is something like "15:26:44"
-const char *purple_time_format(const struct tm *tm);
- * Builds a time_t from the supplied information.
-time_t purple_time_build(int year, int month, int day, int hour,
* Used by purple_str_to_time to indicate no timezone offset was
--- a/pidgin/gtkblist.c Mon Oct 12 20:54:13 2020 -0500
+++ b/pidgin/gtkblist.c Mon Oct 12 20:57:09 2020 -0500
@@ -3434,9 +3434,17 @@
* must be wrong, show the actual date instead of
- tmp = g_strdup(purple_date_format_long(localtime(&signon)));
+ GDateTime *dt = NULL, *local = NULL; + dt = g_date_time_new_from_unix_utc(signon); + local = g_date_time_to_local(dt); + tmp = g_date_time_format(local, _("%x %X")); + g_date_time_unref(local); tmp = purple_str_seconds_to_string(time(NULL) - signon);
purple_notify_user_info_add_pair_plaintext(user_info, _("Logged In"), tmp);