Show age in profile dialog

This commit is contained in:
Manuel Cortez 2019-09-18 13:56:07 -05:00
parent 29e8b00656
commit 33ba50a7b4
2 changed files with 10 additions and 2 deletions

View File

@ -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])) self.send_message("set", tab="main_info", control="bdate", value=d.format(_("MMMM D"), locale=languageHandler.curLang[:2]))
else: # mm.dd.yyyy else: # mm.dd.yyyy
d = arrow.get(person["bdate"], "D.M.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 # Format current city and home town
city = "" city = ""
if "home_town" in person and person["home_town"] != "": if "home_town" in person and person["home_town"] != "":

View File

@ -14,7 +14,7 @@ def text_size(wxObject, chars):
(x, y) = dc.GetMultiLineTextExtent("0"*chars) (x, y) = dc.GetMultiLineTextExtent("0"*chars)
return (x, -1) return (x, -1)
class mainInfo(wx.Panel): class baseTab(wx.Panel):
""" Panel to store main user information in a profile viewer.""" """ Panel to store main user information in a profile viewer."""
def get(self, control): def get(self, control):
@ -40,6 +40,8 @@ class mainInfo(wx.Panel):
def disable(self, control): def disable(self, control):
getattr(self, control).Enable(False) getattr(self, control).Enable(False)
class mainInfo(baseTab):
def __init__(self, panel): def __init__(self, panel):
super(mainInfo, self).__init__(panel) super(mainInfo, self).__init__(panel)
sizer = wx.BoxSizer(wx.VERTICAL) sizer = wx.BoxSizer(wx.VERTICAL)