From cc7eb2ae9605d0e0ac1e5a7982a5bfc4ef413752 Mon Sep 17 00:00:00 2001 From: Alexander Cherniuk Date: Tue, 30 Mar 2010 15:27:59 +0300 Subject: [PATCH] Cleaned the code for the 'Idle since' tooltip item --- src/tooltips.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/tooltips.py b/src/tooltips.py index 169090446..74a316337 100644 --- a/src/tooltips.py +++ b/src/tooltips.py @@ -33,6 +33,7 @@ import gobject import os import time import locale +from datetime import datetime import gtkgui_helpers @@ -584,21 +585,17 @@ class RosterTooltip(NotificationAreaTooltip): gobject.markup_escape_text(keyID))) if contact.last_activity_time: - text = _(' since %s') + text = _("Idle since: %s") - if time.strftime('%j', time.localtime())== \ - time.strftime('%j', contact.last_activity_time): - # it's today, show only the locale hour representation - local_time = time.strftime('%I:%M %p', - contact.last_activity_time) + last_active = datetime(*contact.last_activity_time[:6]) + current = datetime.now() + + if last_active.date() == current.date(): + formatted = last_active.strftime("%X") else: - # time.strftime returns locale encoded string - local_time = time.strftime('%c', - contact.last_activity_time) - local_time = local_time.decode( - locale.getpreferredencoding()) - text = text % local_time - properties.append(('Idle' + text, None)) + formatted = last_active.strftime("%c") + + properties.append((text % formatted, None)) while properties: property_ = properties.pop(0)