Skip to content

Commit 2f26cc6

Browse files
author
Justus Pendleton
committed
use local timezone for mail date header
fixes [SF#1658173]
1 parent 063200f commit 2f26cc6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

roundup/mailer.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Sending Roundup-specific mail over SMTP.
22
"""
33
__docformat__ = 'restructuredtext'
4-
# $Id: mailer.py,v 1.19 2007-09-02 05:54:46 jpend Exp $
4+
# $Id: mailer.py,v 1.20 2007-09-20 19:42:48 jpend Exp $
55

66
import time, quopri, os, socket, smtplib, re, sys, traceback
77

@@ -10,6 +10,7 @@
1010

1111
from roundup.rfc2822 import encode_header
1212
from roundup import __version__
13+
from roundup.date import get_timezone
1314

1415
try:
1516
from email.Utils import formatdate
@@ -30,6 +31,11 @@ def __init__(self, config):
3031
self.debug = os.environ.get('SENDMAILDEBUG', '') \
3132
or config["MAIL_DEBUG"]
3233

34+
# set timezone so that things like formatdate(localtime=True)
35+
# use the configured timezone
36+
os.environ['TZ'] = get_timezone(self.config.TIMEZONE).tzname(None)
37+
time.tzset()
38+
3339
def get_standard_message(self, to, subject, author=None):
3440
'''Form a standard email message from Roundup.
3541
@@ -60,7 +66,7 @@ def get_standard_message(self, to, subject, author=None):
6066
writer.addheader('Subject', encode_header(subject, charset))
6167
writer.addheader('To', ', '.join(to))
6268
writer.addheader('From', author)
63-
writer.addheader('Date', formatdate())
69+
writer.addheader('Date', formatdate(localtime=True))
6470

6571
# Add a unique Roundup header to help filtering
6672
writer.addheader('X-Roundup-Name', encode_header(tracker_name,

0 commit comments

Comments
 (0)