Display shorter date in chats (#109)

This commit is contained in:
Nameless 2020-07-04 03:30:46 +08:00 committed by GitHub
parent 9224de4110
commit 5b53495b60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -552,11 +552,14 @@ def get_last_msg(chat: Dict[str, Any]) -> Tuple[Optional[int], str]:
def get_date(chat: Dict[str, Any]) -> str:
last_msg = chat.get("last_message")
if not last_msg:
return "<NA>"
return "<No date>"
dt = datetime.fromtimestamp(last_msg["date"])
date_fmt = "%d %b %y"
if datetime.today().date() == dt.date():
return dt.strftime("%H:%M")
return dt.strftime("%d %b %y")
date_fmt = "%H:%M"
elif datetime.today().year == dt.year:
date_fmt = "%d %b"
return dt.strftime(date_fmt)
def parse_content(content: Dict[str, Any]) -> str: