On Thu, 2006-12-07 at 16:06 -0600, Jacob Kaplan-Moss wrote:
> On 12/7/06 3:41 PM, Todd O'Bryan wrote:
> > OK. I've read the Python docs on tzinfo objects and I think I could make
> > a tzinfo object, but it seems like there should be a way to get one out
> > of the Django innards.
> >
> > I assume one can use the django.utils.tzinfo.LocalTimezone class to
> > create a tzinfo object, but what the heck do you pass to the constructor
> > so it knows what to do?
>
> For some reason, dates/times and especially timezones absolutely suck eggs in
> Python. The best way I've found to sanely deal with 'em is the dateutil
> package: http://labix.org/python-dateutil.
>
> FWIW, though, here's a quick example that shows how you might use Django's
> tzinfo module::
>
> >>> import datetime
> >>> from django.utils import tzinfo
> >>> utc = tzinfo.FixedOffset(0)
> >>> utcnow = datetime.datetime.now(utc)
> >>> utcnow
> datetime.datetime(2006, 12, 7, 22, 3, 3, 481319, tzinfo=+0000)
>
> You're not alone in being frustrated by datetimes in Python; I'd venture to
> say that they're the suckiest part of being a Python programmer.
>
> Jacob
I'm apparently worse off than I thought. I just tried the {% now %} tag,
and it gave me UTC. But SELECT NOW(); in MySQL returns local time (US
Eastern Standard Time) and my system clock as indicated by the "date"
command in a terminal also shows EST.
I checked the code for the now tag and it just uses datetime.now() with
no attempt to check the local time zone.
Is this the correct behavior or should {% now %} do something else? If
it is correct behavior, what the heck do I have TIME_ZONE = 'America/New
York' for in the settings.py file?
Todd
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---