diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/mail.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/utils/mail.py b/utils/mail.py index f26e7b8..c1cd3d8 100644 --- a/utils/mail.py +++ b/utils/mail.py @@ -70,10 +70,13 @@ def get_mail_details(msg): except IndexError: maildetails.subject = subject received_time = msg.get("Date") - time_str_fmt = "%a, %d %b %Y %H:%M:%S %z" - time_obj = datetime.strptime(received_time, time_str_fmt) - time_obj = time_obj.astimezone(pytz.timezone('Asia/Hong_Kong')) - maildetails.receivedtime = time_obj.strftime(time_str_fmt) + if received_time.endswith('(CST)'): + maildetails.receivedtime = received_time + else: + time_str_fmt = "%a, %d %b %Y %H:%M:%S %z" + time_obj = datetime.strptime(received_time, time_str_fmt) + time_obj = time_obj.astimezone(pytz.timezone('Asia/Hong_Kong')) + maildetails.receivedtime = time_obj.strftime(time_str_fmt) parts = msg.get_payload() content_charset = parts[0].get_content_charset() |