Django effects Python time/datetime and gives wrong time after DST update
I have some scripts that run tasks and use Django DB models. They have been running an hour late today after all the DST changes (here in the US). I've traced it down to any call to Django is shifting my time back an hour (like it was before this weekend's shift). So the time as reported by time.time() and datetime.datetime.now() are both correct _before_ this call: task = Task.objects.get(pk=opts['--taskid']) where Task is a Django DB model. But immediately after this call both time.time() and datetime.datetime.now() return a time an hour earlier (after formatting using strftime). I'm running under Windows 2003 Server (patched for DST and verfied that the OS is patched). And I have TIME_ZONE set to 'EST5DT' in my Django settings file. I've tried manually setting the TIME_ZONE variable using django.conf.settings.configure so it wouldn't effect the os.environ['TZ'] setting, but then all python time seems to be based as UTC, not New York time. Has anyone seen anything similar? Can someone suggest a fix or at least a quick workaround? Thanks, -Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django effects Python time/datetime and gives wrong time after DST update
I found a workaround but I'm not sure what the ramifications are. I commented out this line in django.conf.__init__.py: os.environ['TZ'] = self.TIME_ZONE On Mar 12, 10:19 am, "DavidA" <[EMAIL PROTECTED]> wrote: > I have some scripts that run tasks and use Django DB models. They have > been running an hour late today after all the DST changes (here in the > US). I've traced it down to any call to Django is shifting my time > back an hour (like it was before this weekend's shift). > > So the time as reported by time.time() and datetime.datetime.now() are > both correct _before_ this call: > > task = Task.objects.get(pk=opts['--taskid']) > > where Task is a Django DB model. But immediately after this call both > time.time() and datetime.datetime.now() return a time an hour earlier > (after formatting using strftime). > > I'm running under Windows 2003 Server (patched for DST and verfied > that the OS is patched). And I have TIME_ZONE set to 'EST5DT' in my > Django settings file. > > I've tried manually setting the TIME_ZONE variable using > django.conf.settings.configure so it wouldn't effect the > os.environ['TZ'] setting, but then all python time seems to be based > as UTC, not New York time. > > Has anyone seen anything similar? Can someone suggest a fix or at > least a quick workaround? > > Thanks, > -Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django effects Python time/datetime and gives wrong time after DST update
On 3/12/07, DavidA <[EMAIL PROTECTED]> wrote: > > I found a workaround but I'm not sure what the ramifications are. I > commented out this line in django.conf.__init__.py: > > os.environ['TZ'] = self.TIME_ZONE > What version/revision of Django are you using?. See ticket #2315 and changeset [4487] for some work donde in the Windows time zone stuff front. Regards, -- Ramiro Morales --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django effects Python time/datetime and gives wrong time after DST update
Thanks. I am on trunk, 4227 so I don't have this fix. On Mar 12, 10:53 am, "Ramiro Morales" <[EMAIL PROTECTED]> wrote: > On 3/12/07, DavidA <[EMAIL PROTECTED]> wrote: > > > > > I found a workaround but I'm not sure what the ramifications are. I > > commented out this line in django.conf.__init__.py: > > > os.environ['TZ'] = self.TIME_ZONE > > What version/revision of Django are you using?. > > See ticket #2315 and changeset [4487] for some work donde > in the Windows time zone stuff front. > > Regards, > > -- > Ramiro Morales --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django effects Python time/datetime and gives wrong time after DST update
On Mon, 2007-03-12 at 11:53 -0300, Ramiro Morales wrote: > On 3/12/07, DavidA <[EMAIL PROTECTED]> wrote: > > > > I found a workaround but I'm not sure what the ramifications are. I > > commented out this line in django.conf.__init__.py: > > > > os.environ['TZ'] = self.TIME_ZONE > > > > What version/revision of Django are you using?. > > See ticket #2315 and changeset [4487] for some work donde > in the Windows time zone stuff front. By the way, if anybody wants a fun little side project and enjoys doing Windows development, they could write some decent win32 timezone support stuff for us. There are obviously ways to do it (although the idea would be not to corrupt the whole server's idea of timezone -- just the current process), but it's not the same as the Unix world and so some specialist knowledge is required. Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---