On Wed, Jan 19, 2011 at 01:40, David Walker <d...@walker.cx> wrote:

> There seem to be two main places where date formats originate.  They
> are set in settings.py and in the locale's formats.py
> (django.conf.locale.<locale_code>.formats).
>
> formats.py sets (amongst others) DATE_FORMAT and SHORT_DATE_FORMAT for
> the locale in question (along with a load of other datetime formats).
> setings.py sets L10N, and also DATE_FORMAT and SHORT_DATE_FORMAT.
>
> If L10N is True, the SHORT_DATE_FORMAT in settings.py is not used in
> rendering, with the localised version from the appropriate formats.py
> being used instead.
> However, Django uses two versions of DATE_FORMAT.  The settings.py one
> defaults to to the US format of 'N j, Y', but can be changed.  The
> formats.py one contains the appropriate setting for your locale (but
> see en_GB below!).
>
> So, what does all this mean for rendering?  I think that the following
> happens (assuming that d is a date):
> {{d|date:"SHORT_DATE_FORMAT"}}
>    produces a localised short date: 'd/m/Y' here in the UK
> {{d}}
>    produces a localised long date: 'j \de F \de Y' in Portugal
> {{d|date}}
>    produces a date based on the settings.DATE_FORMAT ( 'N j, Y'
> unless changed), but incredibly the month name is translated to the
> browser locale.  This often produces date that no one would ever use
> like: Março 10, 2010 (the default setting with a Portuguese browser).
> I seem to remember seeing in some documentation somewhere (that I now
> can't find) that it was intended that the date filter without
> arguments would produce a consistent, machine readable date format.
>
> While it may be useful to have a locale independent date format, this,
> to me, has a number of problems:
> 1. re-using the variable name DATE_FORMAT is bound to cause confusion
> 2. using a common human format for locale independent machine readable
> dates is likely to cause confusion.
> 3. translating the result renders the whole process pointless.
>
> Meanwhile, the documentation says:
> http://docs.djangoproject.com/en/dev/ref/settings/#date-format
>    Note that if USE_L10N is set to True, then the locale-dictated
> format has higher precedence and will be applied instead.
> http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
>    When used without a format string...the formatting string defined
> in the DATE_FORMAT setting will be used, without applying any
> localization.
>
> Neither of these statements correctly describe the actual behaviour I
> have observed.
>
> To add to my confusion, django.conf.locale.en_GB.formats contains
> DATE_FORMAT='N j, Y', whereas I think it should be something like 'j F
> Y', 'j N Y' or 'jS F Y'.  The Unicode Common Locale Data Repository
> seems to agree with me, plumping for 'd MMMM y' or 'd MMM
> y' (obviously these are in a different format).
>
> Have I got this right?

I am not sur e- you seem to have done the work and I trust you did it
correctly :)

> Where do I/we go from here?

I guess we need to bring it up with the developers - ie, should this
be listed as a bug, and if so is it a documentation bug/clarification
that's needed, or does something need to happen at a deeper level.
Plus, there seem to be a multitude of issues (precedence of SHORT_DATE
settings, en_GB short date format...) - which also complicates things.

> Is there a better forum for this?

Yes, I would say that the dev list is the place to go -
django-develop...@googlegroups.com I might send through a link to this
discussion to that list now

> Can I help improve things by writing bug reports?  enhancements
> requests? patches? documentation? or taking part in discussions?

Yes. How to do it is the hard part. I would frame it as a question,
with clearly demarked issues.

 re precedence: expected behavior vs explained behaviour vs witnessed
behaviour (remember to include OS, python version, django version,
documentation version)

re en_GB problems, raise it separately/secondarily and with links that
support your argument.

cheers
L.

-- 
"There are all kinds of pedants around with more time to read and
imitate Lynne Truss and John Humphrys than to write poems,
love-letters, novels and stories it seems. They whip out their
Sharpies and take away and add apostrophes from public signs, shake
their heads at prepositions which end sentences and mutter at split
infinitives and misspellings, but do they bubble and froth and slobber
and cream with joy at language? Do they ever let the tripping of the
tips of their tongues against the tops of their teeth transport them
to giddy euphoric bliss? Do they ever yoke impossible words together
for the sound-sex of it? Do they use language to seduce, charm,
excite, please, affirm and tickle those they talk to? Do they? I doubt
it. They’re too farting busy sneering at a greengrocer’s less than
perfect use of the apostrophe. Well sod them to Hades. They think
they’re guardians of language. They’re no more guardians of language
than the Kennel Club is the guardian of dogkind."
Stephen Fry

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to