[kforge-dev] timezone mystery - solved

John Bywater john.bywater at appropriatesoftwarefoundation.org
Mon Feb 26 23:52:43 UTC 2007


Problem: Was having trouble with timezones when running KForge software. 
Basically, whatever I did, the timezone was always being set to several 
hours back from UK local time, so localtime values were off, log files 
were off, etc.

Solution: The right value for each KForge service needs to be set in the 
service's KForge Django setting module when KForge is installed.

In the kforge package Python module:

kforge/django/settings/main.py


this line needs adding to the bottom:

TIME_ZONE = "Europe/London"


....of course, chaging the value to match something suitable in here (on 
Debian, at least):

/usr/share/zoneinfo


The KForge installation instructions, and the KForge Guide need will 
updating with this information. I guess just after the indication to set 
a unique SECRET_KEY in the same file?

Best wishes,


John.

PS So it turns out that (in certain unidentified configurations of 
Apache only) Django always insists on setting the timezone in the 
environment, which affects the returned value of localtime() calls. 
Perhaps the unreliability is something to do with Django not calling 
time.tzset() after setting the environment as advised in the Python manual?

PPS I've got not idea why Django doesn't default to its own environment. 
Django's global settings have a value set, which seems a bit rude. I 
looked in the Django source briefly, and it seems to 'move' the 
TIME_ZONE setting into the environment TZ variable, whatever its value! 
 From django/conf/__init__.py:

# move the time zone info into os.environ
os.environ['TZ'] = self.TIME_ZONE






More information about the kforge-dev mailing list