I'm looking at this type of issue also.  From what I have been reading - 
it is normally advised to always keep dates in UTC, and just convert 
when needed.  I have two functions that I use to convert to the desired 
TZ just before sending to the template. 

def _convert_timezone(utctime, newzone):
    newtime = utctime.replace( tzinfo=tz.tzutc() ).astimezone(newzone)
    return newtime

def _convert_to_utc(oldtime, oldzone):
    newtime = oldtime.replace(tzinfo=oldzone).astimezone( tz.tzutc() 
).replace(tzinfo=None)
    return newtime

MySQL seems to have issues with datetimes that have tzinfo, so I always 
store without it.  I.e., I assume all datetimes are UTC, but without a 
tzinfo, until I convert it at the last moment for rendering a template.


-Mark


gmacgregor wrote:
> Some of my project app's models have a DateTimeField where the value
> is UTC while others have EDT/EST values. This is because I populate
> some models (ie. a blog entry) via django-admin while other data is
> populated via my flickr/del.icio.us accounts (via django-syncr <http://
> code.google.com/p/django-syncr/>).
>
> When displaying timestamps, I want all values to be EDT/EST-- the
> timezone in which I live. Is there an easy way to handle this
> conversion on the template level? Or should I start thinking about
> overriding the save() method to either make all DateTimeField values
> EDT/EST/UTC? Is there a simple solution out there that I just haven't
> yet considered? Thanks for the help...
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to