Commit e63e417e authored by Dan Pascu's avatar Dan Pascu

Fixed the date displayed for calls in the history menus

parent 278d33fe
...@@ -10,7 +10,7 @@ from application.notification import IObserver, NotificationCenter ...@@ -10,7 +10,7 @@ from application.notification import IObserver, NotificationCenter
from application.python import Null from application.python import Null
from application.python.types import Singleton from application.python.types import Singleton
from collections import deque from collections import deque
from datetime import datetime from datetime import date, datetime
from zope.interface import implements from zope.interface import implements
from sipsimple.account import BonjourAccount from sipsimple.account import BonjourAccount
...@@ -133,17 +133,16 @@ class HistoryEntry(object): ...@@ -133,17 +133,16 @@ class HistoryEntry(object):
return u'%s%s%s%s' % (self.remote_identity, time, duration, reason) return u'%s%s%s%s' % (self.remote_identity, time, duration, reason)
def format_date(dt): def format_date(when):
now = datetime.now() days = (date.today() - when.date()).days
delta = now - dt if days == 0:
if (dt.year, dt.month, dt.day) == (now.year, now.month, now.day): return when.strftime("at %H:%M")
return dt.strftime("at %H:%M") elif days == 1:
elif delta.days <= 1: return when.strftime("Yesterday at %H:%M")
return "Yesterday at %s" % dt.strftime("%H:%M") elif days < 7:
elif delta.days < 7: return when.strftime("on %A")
return dt.strftime("on %A") elif days < 365:
elif delta.days < 300: return when.strftime("on %B %d")
return dt.strftime("on %B %d")
else: else:
return dt.strftime("on %Y-%m-%d") return when.strftime("on %Y-%m-%d")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment