Ticket #2315: windows_timezone_fix.2.patch

File windows_timezone_fix.2.patch, 2.2 KB (added by Chris Beaven, 17 years ago)

import moved, docs included

  • django/conf/__init__.py

     
    77"""
    88
    99import os
     10import time
    1011from django.conf import global_settings
    1112
    1213ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE"
     
    105106                new_installed_apps.append(app)
    106107        self.INSTALLED_APPS = new_installed_apps
    107108
    108         # move the time zone info into os.environ
    109         os.environ['TZ'] = self.TIME_ZONE
     109        # If time doesn't have tzset (Windows environment), changing the local
     110        # timezone environment variable causes the timezone in Python to be set
     111        # to UTC no matter what self.TIME_ZONE is.
     112        if hasattr(time, 'tzset'):
     113            # move the time zone info into os.environ
     114            os.environ['TZ'] = self.TIME_ZONE
    110115
    111116    def get_all_members(self):
    112117        return dir(self)
  • django/conf/project_template/settings.py

     
    1818
    1919# Local time zone for this installation. All choices can be found here:
    2020# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
     21# If running in a Windows environment this must be set to the same as your system time zone.
    2122TIME_ZONE = 'America/Chicago'
    2223
    2324# Language code for this installation. All choices can be found here:
  • docs/settings.txt

     
    827827environment variable, and it'll be up to you to ensure your processes are
    828828running in the correct environment.
    829829
     830Note to Windows users: Django can not reliably use alternate time zones in a
     831Windows environment. When running Django on Windows this variable must be set
     832to match the system timezone. You can read more about that in this `bug report (#2315)`_
     833
     834.. _bug report (#2315): http://code.djangoproject.com/ticket/2315
     835
    830836URL_VALIDATOR_USER_AGENT
    831837------------------------
    832838
Back to Top