caktus / django-timepiece

A multi-user Django application for tracking people's time on projects.
MIT License
361 stars 115 forks source link

Respect date format localization in DateInput widgets #565

Open tomusher opened 11 years ago

tomusher commented 11 years ago

DateInput and SplitDateTimeWidget form fields all use hardcoded date formats (%m/%d/%Y) - should use L10N date format instead.

When a form with a calendar widget is used on an installation with L10N enabled with a UK localisation, the calendar widget inputs dates in d/m/Y format (23/11/2012) but the field still expects the hardcoded format.

ghost commented 11 years ago

Thanks for pointing this out! The work for this is related to #467. If you're interested in making the change yourself, we happily accept pull requests!

tomusher commented 11 years ago

No problem, great work on Timepiece so far - nice to see a tool like this out there! Will definitely contribute if I get some time.

dpoirier commented 11 years ago

Django 1.4 is the first to allow settings and localization to control the date input formats. Once we drop Django 1.3 support, we can remove the hard-coded format and just use the settings to make the input formats what we're used to without breaking other locales.

tomusher commented 11 years ago

Is 1.4's timezone support needed for this? Django 1.2 introduced locale-aware formatting - is that not all that is needed?

dpoirier commented 11 years ago

That's interesting. According to the 1.2 doc on format localization, you can set localized=True on form fields and they'll adapt - how is not really specified - and try to parse dates and times using the current locale. But the 1.2 doc for the date/time input widgets makes no mention of that, and states pretty clearly that it will only use one format to try to parse the entered data. Yet the 1.2 doc on settings documents settings that can control that, but they're not mentioned in the field or widget docs. Doc fail.

It does sound to me now as if we can just drop the hard-coded format anytime.

dpoirier commented 11 years ago

I've discovered a complication - we're actually using jquery-ui's DatePicker widgets for a lot of our date and time input, not Django's widgets. These aren't connected to Django's settings. I'm going to see if it's possible to arrange for whatever the settings are in Django to get passed to DatePicker somehow.