From 743d514997ec54208a906980a96ce1bed3346d3f Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sun, 5 Mar 2006 22:09:39 +0000 Subject: [PATCH] strftime returns local-encoded string. decode it. Fixes #1662 --- src/chat_control.py | 4 +++- src/conversation_textview.py | 6 ++++-- src/history_manager.py | 10 +++++++--- src/vcard.py | 3 ++- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index 8de4c2b42..b263238cc 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -31,6 +31,7 @@ import gtkgui_helpers import message_control import dialogs import history_window +import locale from common import gajim from common import helpers @@ -477,7 +478,8 @@ class ChatControlBase(MessageControl): buffer = conv_textview.get_buffer() end_iter = buffer.get_end_iter() tim = time.localtime() - tim_format = time.strftime('%H:%M', tim) + tim_format = time.strftime('%H:%M', tim).decode( + locale.getpreferredencoding()) buffer.insert_with_tags_by_name(end_iter, '\n' + tim_format, 'time_sometimes') # scroll to the end of the textview diff --git a/src/conversation_textview.py b/src/conversation_textview.py index ffd203193..b81ca77b6 100644 --- a/src/conversation_textview.py +++ b/src/conversation_textview.py @@ -579,7 +579,8 @@ class ConversationTextview(gtk.TextView): if day_str: format += day_str + ' ' format += '%X' + after_str - tim_format = time.strftime(format, tim) + tim_format = time.strftime(format, tim).decode( + locale.getpreferredencoding()) buffer.insert_with_tags_by_name(end_iter, tim_format + ' ', *other_tags_for_time) elif gajim.config.get('print_time') == 'sometimes': @@ -589,7 +590,8 @@ class ConversationTextview(gtk.TextView): if seconds_passed > every_foo_seconds: self.last_time_printout = time.mktime(tim) end_iter = buffer.get_end_iter() - tim_format = time.strftime('%H:%M', tim) + tim_format = time.strftime('%H:%M', tim).decode( + locale.getpreferredencoding()) buffer.insert_with_tags_by_name(end_iter, tim_format + '\n', 'time_sometimes') other_text_tag = self.detect_other_text_tag(text, kind) diff --git a/src/history_manager.py b/src/history_manager.py index 0e722be3f..113712d31 100755 --- a/src/history_manager.py +++ b/src/history_manager.py @@ -23,6 +23,7 @@ import signal import gtk import gtk.glade import time +import locale import exceptions import dialogs @@ -265,7 +266,8 @@ class HistoryManager: # but store in liststore log_line_id, jid_id, time, message and subject time_ = row[2] try: - time_ = time.strftime('%x', time.localtime(float(time_))) + time_ = time.strftime('%x', time.localtime(float(time_))).decode( + locale.getpreferredencoding()) except ValueError: pass else: @@ -290,7 +292,8 @@ class HistoryManager: # but store in liststore log_line_id, jid_id, time, message and subject time_ = row[2] try: - time_ = time.strftime('%x', time.localtime(float(time_))) + time_ = time.strftime('%x', time.localtime(float(time_))).decode( + locale.getpreferredencoding()) except ValueError: pass else: @@ -419,7 +422,8 @@ class HistoryManager: message = row[2] try: - time_ = time.strftime('%x', time.localtime(float(time_))) + time_ = time.strftime('%x', time.localtime(float(time_))).decode( + locale.getpreferredencoding()) except ValueError: pass diff --git a/src/vcard.py b/src/vcard.py index a1fcd6541..79f6c80d5 100644 --- a/src/vcard.py +++ b/src/vcard.py @@ -34,6 +34,7 @@ import sys import time import gtkgui_helpers import dialogs +import locale from common import helpers from common import gajim @@ -321,7 +322,7 @@ class VcardWindow: stats += ': ' + c.status if c.last_status_time: stats += '\n' + _('since %s') % time.strftime('%c', - c.last_status_time) + c.last_status_time).decode(locale.getpreferredencoding()) one = False status_label = self.xml.get_widget('status_label') status_label.set_max_width_chars(15)