On Tue, Feb 21, 2012 at 14:17, Yo-Yo Ma <baxterstock...@gmail.com> wrote:
>[...]
> When using UTC, which, if any, are true:

Not sure what you mean by "using UTC", I assume you mean "USE_TZ = True".
As per first sentence of
https://docs.djangoproject.com/en/dev/topics/i18n/timezones/
"When support for time zones is enabled, Django stores date and time
information in UTC in the database, uses time zone-aware datetime
objects internally, and translates them to the end user’s time zone in
templates and forms."

> A) If I have a view that simply adds a record of a model with a
> datetime field, and 3 users in different timezones load the view at
> the same time, all 3 records will have the same datetime value
> (assuming, of course, the database was able to write all 3 records
> within the same microsecond)

They will have the same value in the database, yes.

> B) UTC is *the* way to go for almost any application which will have a
> timezone = models.CharField(... setting for each user profile

See above - database will store everything in UTC.
You could use a timezone field like that to store user timezone and
activate it, e.g. through a middleware -
https://docs.djangoproject.com/en/dev/topics/i18n/timezones/#selecting-the-current-time-zone

NB: PostgrSQL already stores UTC internally -
https://docs.djangoproject.com/en/dev/topics/i18n/timezones/#postgresql
"The PostgreSQL backend stores datetimes as timestamp with time zone.
In practice, this means it converts datetimes from the connection's
time zone to UTC on storage, and from UTC to the connection's time
zone on retrieval."
For other backends that store naive datetimes "in UTC" means "assumed
as being UTC".

> C) When each user has a timezone setting, it doesn't affect the
> datetime that's entered into the database, it just gives me the
> ability to display the time to them in their timezone

It doesn't affect the database.
But it's up to you (middleware) to "activate" their timezone in order
to make it the "current" timezone.
If you don't do that, the "default" timezone (TIME_ZONE setting) will
be the current timezone.
Whatever a user enters in their "current" timezone is converted to UTC
for storage - UTC is the only sane "common denominator".

Cheers,
Danny

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to