From d834749ea303fffe9ee02b5d88639420fdfc9fa5 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 6 Apr 2020 12:36:56 +0100 Subject: [PATCH] Account for PST offset in mail timestamps --- houdini/handlers/play/mail.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/houdini/handlers/play/mail.py b/houdini/handlers/play/mail.py index 5a6f631..c1a35c6 100644 --- a/houdini/handlers/play/mail.py +++ b/houdini/handlers/play/mail.py @@ -1,4 +1,5 @@ import time +import pytz from houdini import handlers from houdini.data import db @@ -33,13 +34,17 @@ async def handle_get_mail(p): PenguinPostcard.send_date.desc()) postcards = [] + pst = pytz.timezone(p.server.config.timezone) async with p.server.db.transaction(): async for postcard in mail_query.gino.iterate(): sender_name, sender_id = ('sys', 0) if postcard.sender_id is None else ( postcard.parent.safe_nickname(p.server.config.lang), postcard.sender_id) + sent_pst = postcard.send_date.astimezone(pst) sent_timestamp = int(time.mktime(postcard.send_date.timetuple())) + sent_pst_timestamp = int(time.mktime(sent_pst.timetuple())) + sent_timestamp += sent_timestamp - sent_pst_timestamp postcards.append(f'{sender_name}|{sender_id}|{postcard.postcard_id}|' - f'{postcard.details}|{sent_timestamp}|{postcard.id}|{int(postcard.has_read)}') + f'{postcard.details}|{sent_timestamp+1}|{postcard.id}|{int(postcard.has_read)}') await p.send_xt('mg', *postcards)