Code

Ticket #7062: patch_tz.diff

File patch_tz.diff, 908 bytes (added by durdinator, 6 years ago)
Line 
1Index: core/handlers/modpython.py
2===================================================================
3--- core/handlers/modpython.py  (revision 7438)
4+++ core/handlers/modpython.py  (working copy)
5@@ -1,4 +1,5 @@
6 import os
7+import time
8 from pprint import pformat
9 
10 from django import http
11@@ -148,6 +149,13 @@
12         # that use settings now can work
13         from django.conf import settings
14 
15+        # Ensure the TZ environment variable is set appropriately for every request
16+        if hasattr(time, 'tzset'):
17+            # Move the time zone info into os.environ. See ticket #2315 for why
18+            # we don't do this unconditionally (breaks Windows).
19+            os.environ['TZ'] = self.TIME_ZONE
20+            time.tzset()
21+
22         # if we need to set up middleware, now that settings works we can do it now.
23         if self._request_middleware is None:
24             self.load_middleware()