summaryrefslogtreecommitdiff
path: root/django/conf/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/conf/__init__.py')
-rw-r--r--django/conf/__init__.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/django/conf/__init__.py b/django/conf/__init__.py
index d94f6e9867..bda0ef3691 100644
--- a/django/conf/__init__.py
+++ b/django/conf/__init__.py
@@ -103,6 +103,12 @@ class Settings(object):
self.INSTALLED_APPS = new_installed_apps
if hasattr(time, 'tzset') and getattr(self, 'TIME_ZONE'):
+ # When we can, attempt to validate the timezone. If we can't find
+ # this file, no check happens and it's harmless.
+ zoneinfo_root = '/usr/share/zoneinfo'
+ if (os.path.exists(zoneinfo_root) and not
+ os.path.exists(os.path.join(zoneinfo_root, *(self.TIME_ZONE.split('/'))))):
+ raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE)
# Move the time zone info into os.environ. See ticket #2315 for why
# we don't do this unconditionally (breaks Windows).
os.environ['TZ'] = self.TIME_ZONE