Closes #14902: Fixed timezone conversion of a date/time in the past. Thanks to Yuriy Syrovetskiy for the report and Juancarlo Añez for the patch on which this fix is based.

This commit is contained in:
Vinay Sajip 2012-07-03 21:36:36 +01:00
parent 5da6039765
commit ed1f7c834f
2 changed files with 6 additions and 2 deletions

View file

@ -2899,8 +2899,10 @@ class FormatterTest(unittest.TestCase):
def test_time(self):
r = self.get_record()
dt = datetime.datetime(1993,4,21,8,3,0,0,utc)
r.created = time.mktime(dt.timetuple()) - time.timezone
dt = datetime.datetime(1993, 4, 21, 8, 3, 0, 0, utc)
# We use None to indicate we want the local timezone
# We're essentially converting a UTC time to local time
r.created = time.mktime(dt.astimezone(None).timetuple())
r.msecs = 123
f = logging.Formatter('%(asctime)s %(message)s')
f.converter = time.gmtime