Date display should be appropriate to the user's locale. This could be done through a helper module e.g. country_code_date. Proposed implementation:

  • Determine mapping between Drupal short, medium, long date formats and country codes. Where no appropriate format exists, determine custom format.
  • Provide UI for manual override/designation of date format by country.
  • In hook_init() (or, possibly, hook_boot()), reset the global $conf values for date formatting based on the user's country code.

Another possibility is to make date input formatting locale appropriate.

This could be done with a hook_elements() implementation that declares a #process callback for elements that could contain dates, with the callback making locale-appropriate tweaks.

Comments

recidive’s picture

Another possibility is to make date input formatting locale appropriate.

This doesn't seem enough, as, for example, UK dates are DD/MM/YYYY and USA dates are MM/DD/YYYY and both have English as primary language.

Owen Barton’s picture

Subscribing

catch’s picture

@recidive: UK and USA have different spellings and vocabulary as well as date formats, so if a site cared enough to show localised dates, they could have an en_GB translation too (I've semi-jokingly considered doing one for core before). So I think doing it by locale makes sense.

recidive’s picture

@catch: yes, after more thought on the subject, I think the whole country->language variations stuff can be build on locale module, by adding one language for each country->language variation.

Maybe what we need here is a way of 'cascading' languages, so we can extend a language based on another. This way e.g. 'en-NL' could extend 'en-UK', so if it's missing a string on 'en-NL' it would get from 'en-UK' instead of default 'en' language (need to check if this is feasible), not that the examples make any sense, just so you get the picture.

But back on the scope of this issue. If date format settings can really rely on locale, implementing a 'locale_date' module is sound. And for the UI, we could add hook_form_alter() the language add/edit form to allow setting date formats based on the language.

Owen Barton’s picture

I have a patch for date project started for this that takes the approach of:
* Allow the site admin to add any number of date format strings (in addition to the short/medium/long selections) on the main date and time admin page. These could be associated with a locale, but I think are also useful for many other cases (e.g. specific formats for specific types of events) so do not have to be. I think using t() for this as has been proposed in other issues is not user friendly, as there is not a "standard" date format for each country, but many - and I think this configuration should be in a much more intuitive place that in the string translation section :)
* Allow other modules to return callbacks for going to/from alternate calendar systems (see http://groups.drupal.org/node/10607) - I think this is an important requirement, and not a hard one to facilitate.
* Provide a simple wrapper (ideally, if this could be in core would just be format_date) to format a date according to one of the above configurations.

In terms of the end user interface, date field would simply use a configured formatter based on the selected node language.

If we allow multiple configurations per-language (probably needed at some point) then it gets more complex - we may want to allow the admin to limit the choices (list of checkboxes) on the date field configuration screen, and (ideally) allow node authors to select which format they would like if multiple options are still available for that locale.

I agree that we probably don't want to associate date formats with countries directly - it's probably more flexible to link them with locales. I'll post my patch tomorrow (it is on the project site also).

nedjo’s picture

Version: » 6.x-1.x-dev
Status: Active » Postponed

It looks like this will go into the separate module started by Grugnog2. From that module it shd be possible to call a method in country code to determine the country. Marking postponed.

nedjo’s picture

Status: Postponed » Needs review

I've committed a draft of a hook implementation to get this working with date_format. Untested. http://drupal.org/cvs?commit=146915

catch’s picture

Status: Needs review » Postponed

Marking postponed against this date API issue #318008: locale based handling and rendering