Change date formatting for chat messages

This commit is contained in:
Manuel Cortez 2018-12-05 15:56:23 -06:00
parent c91e04b4d8
commit 965f14e249

View File

@ -129,7 +129,13 @@ def clean_audio(audio):
def compose_message(message, session): def compose_message(message, session):
user = session.get_user_name(message["from_id"], "nom") user = session.get_user_name(message["from_id"], "nom")
original_date = arrow.get(message["date"]) original_date = arrow.get(message["date"])
created_at = original_date.format(_(u"dddd, MMMM D, YYYY H:m:s"), locale=languageHandler.getLanguage()) now = arrow.now()
original_date = original_date.to(now.tzinfo)
# Format the date here differently depending in if this is the same day for both dates or not.
if original_date.day == now.day:
created_at = original_date.format(_(u"H:mm."), locale=languageHandler.getLanguage())
else:
created_at = original_date.format(_(u"H:mm. dddd, MMMM D, YYYY"), locale=languageHandler.getLanguage())
# No idea why some messages send "text" instead "body" # No idea why some messages send "text" instead "body"
if message.has_key("body"): if message.has_key("body"):
body = message["body"] body = message["body"]