cpw.darkrain42.xmpp.iq-handlers: 3bdb82c3: Format the time as "localtimeformat [+-]...

paul at darkrain42.org paul at darkrain42.org
Mon Feb 9 02:20:28 EST 2009


-----------------------------------------------------------------
Revision: 3bdb82c347184599c389f7ed65d02c61f2708b89
Ancestor: 5472f724a9c074472bb1560fc6b9b0a54e33a43e
Author: paul at darkrain42.org
Date: 2009-02-09T07:13:44
Branch: im.pidgin.cpw.darkrain42.xmpp.iq-handlers
URL: http://d.pidgin.im/viewmtn/revision/info/3bdb82c347184599c389f7ed65d02c61f2708b89

Modified files:
        libpurple/protocols/jabber/buddy.c

ChangeLog: 

Format the time as "localtimeformat [+-]HHMM". Iterative development is fun.

This shows up, for me, as "Local Time: 10:50:15 PM -0800". Marcus, I figure
this bypasses the need to localize 'GMT'.

Are there any locales where either the tz offset is always printed (my reading
is that this would show up in the conversation window, so I doubt it) or where
a tz offset is printed before the time?

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/buddy.c	c7afdb623507fbabbda878b8c36aad1fd3a903a5
+++ libpurple/protocols/jabber/buddy.c	440eaa04f54f49143dda86ccdb3f0c707425d34f
@@ -806,21 +806,16 @@ static void jabber_buddy_info_show_if_re
 			time_t now_t;
 			struct tm *now;
 			char *timestamp;
-			char *timezone;
 			time(&now_t);
 			now_t += jbr->tz_off;
 			now = gmtime(&now_t);
 
-			if (jbr->tz_off)
-				timezone = g_strdup_printf("%02d:%02d", (int)(jbr->tz_off / (60*60)),
-				                           abs((jbr->tz_off % (60*60)) / 60));
-			else
-				timezone = NULL;
-			timestamp = g_strdup_printf("%s GMT%s", purple_time_format(now),
-			                            timezone ? timezone : "");
+			timestamp = g_strdup_printf("%s %c%02d%02d", purple_time_format(now),
+			                            jbr->tz_off < 0 ? '-' : '+',
+			                            abs(jbr->tz_off / (60*60)),
+			                            abs((jbr->tz_off % (60*60)) / 60));
 			purple_notify_user_info_prepend_pair(user_info, _("Local Time"), timestamp);
 			g_free(timestamp);
-			g_free(timezone);
 		}
 		if(jbir) {
 			if(jbir->idle_seconds > 0) {
@@ -996,21 +991,16 @@ static void jabber_buddy_info_show_if_re
 				time_t now_t;
 				struct tm *now;
 				char *timestamp;
-				char *timezone;
 				time(&now_t);
 				now_t += jbr->tz_off;
 				now = gmtime(&now_t);
 
-				if (jbr->tz_off)
-					timezone = g_strdup_printf("%02d:%02d", (int)(jbr->tz_off / (60*60)),
-					                           abs((jbr->tz_off % (60*60)) / 60));
-				else
-					timezone = NULL;
-				timestamp = g_strdup_printf("%s GMT%s", purple_time_format(now),
-				                            timezone ? timezone : "");
+				timestamp = g_strdup_printf("%s %c%02d%02d", purple_time_format(now),
+				                            jbr->tz_off < 0 ? '-' : '+',
+				                            abs(jbr->tz_off / (60*60)),
+				                            abs((jbr->tz_off % (60*60)) / 60));
 				purple_notify_user_info_prepend_pair(user_info, _("Local Time"), timestamp);
 				g_free(timestamp);
-				g_free(timezone);
 			}
 
 			if(jbr->name && (jbir = g_hash_table_lookup(jbi->resources, jbr->name))) {


More information about the Commits mailing list