From 33ba50a7b4832c97946070fab0c106acd31498fd Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 18 Sep 2019 13:56:07 -0500 Subject: [PATCH] Show age in profile dialog --- src/presenters/profiles.py | 8 +++++++- src/views/dialogs/profiles.py | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/presenters/profiles.py b/src/presenters/profiles.py index b534aa9..45674e2 100644 --- a/src/presenters/profiles.py +++ b/src/presenters/profiles.py @@ -66,7 +66,13 @@ class userProfilePresenter(base.basePresenter): self.send_message("set", tab="main_info", control="bdate", value=d.format(_("MMMM D"), locale=languageHandler.curLang[:2])) else: # mm.dd.yyyy d = arrow.get(person["bdate"], "D.M.YYYY") - self.send_message("set", tab="main_info", control="bdate", value=d.format(_("MMMM D, YYYY"), locale=languageHandler.curLang[:2])) + # Calculate user's years. + now = arrow.get() + timedelta = now-d + years = int(timedelta.days/365) + date = d.format(_("MMMM D, YYYY"), locale=languageHandler.curLang[:2]) + msg = _("{date} ({age} years)").format(date=date, age=years) + self.send_message("set", tab="main_info", control="bdate", value=msg) # Format current city and home town city = "" if "home_town" in person and person["home_town"] != "": diff --git a/src/views/dialogs/profiles.py b/src/views/dialogs/profiles.py index f12b39c..1c22552 100644 --- a/src/views/dialogs/profiles.py +++ b/src/views/dialogs/profiles.py @@ -14,7 +14,7 @@ def text_size(wxObject, chars): (x, y) = dc.GetMultiLineTextExtent("0"*chars) return (x, -1) -class mainInfo(wx.Panel): +class baseTab(wx.Panel): """ Panel to store main user information in a profile viewer.""" def get(self, control): @@ -40,6 +40,8 @@ class mainInfo(wx.Panel): def disable(self, control): getattr(self, control).Enable(False) +class mainInfo(baseTab): + def __init__(self, panel): super(mainInfo, self).__init__(panel) sizer = wx.BoxSizer(wx.VERTICAL)