Posted by pietrocap on January 22, 2012 at 11:54am
4 followers
| Project: | Availability Calendars |
| Version: | 7.x-3.x-dev |
| Component: | User interface |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
Hi,
thank you for this module!
There is a way to use a different date format in the arrival date and departure date textbox?
For example dd-mm-yyyy?
Comments
#1
I didn't give it much attention because I actually assume people will be using the date popup, thus this being a non issue. However, this is not the 1st request regarding this, so I guess I will have to find out how to integrate this.
Any ideas?
- Use the date part of the short date type (how to get only the date part)?
- Add a date type specific for Availability Calendar and have the user change/localize it over there (= admin/config/regional/date-time/...)?
Reactions would be welcome!
#2
Maybe the best choice is letting the user change or localize it in admin/config/regional/date-time/...
#3
It does not work.
#4
Because nothing has been changed yet. It thus still works as before with 1 fixed date format only yyyy-mm-dd (the only date format that everybody in the world understands, but also nobody in the world sees as preferred format)
#5
Excuse me and my english, I incorrectly translated post by pietrocap.
If someone really need date format for availability search, edit line 191 in availability_calendar_handler_filter_availability.inc
ex. for 31.01.2012 change
$element['#date_format'] = 'Y-m-d';on
$element['#date_format'] = 'd.m.Y';#6
A possible solution using localized date patterns.
It converts a simple pattern from the date_format_short pattern.
Please test it.
#7
Thank you for your patch. I thought, the issue at hand is about the date format of the date field(s) when using a view to search on availability. That one is not covered by your patch. But still it is a nice feature, so I would love to apply your patch.
Some remarks about your patch:
- The change in the js file is OK.
++ $date_locale_converted = availability_calendar_booking_formlet_date_format_converter(locale_get_localized_date_format($language));
+
- Contains white space
- According to the doc, the param to locale_get_localized_date_format() should be an array of languages. So that needs some work.
+ $converted_date = $date_format_locale['date_format_short'];- Why the short format? The format is shown only and not editable, so a longer format could do better?
- Does date_format_short always exists or should there be a check?
- Perhaps better to define an own date format (that the administrator can fill in admin) or present the administrator a list of existing date formats he can select from in the field display settings form? At first sight, I would opt for the latter.
#8
Ok, i know my patch is a sort of hacking :)
I didn't find any nice solution to convert php-style patterns to JS-style.
If you look at the date_format table, all the default patterns have the year-month-day parts together somehow ('Y-m-d', 'm/d/Y', 'd/m/Y', 'Y/m/d', 'M j Y', 'Y M j', 'F j, Y', 'j F, Y' etc.).
I'm building a site with 5 languages, and my approach handle these, maybe others as well.
If this direction is pointing forward, i will work on it.
Other possible direction would be a (translatable) config page textbox with the pattern.
#9
This is available in core: admin/config/regional/date-time/types (define date types) and, subsequently, via admin/config/regional/date-time/formats (define allowed date formats for all lcoales) to admin/config/regional/date-time/locale (assign date formats to date types for all available locales).
So, there are ways to use this:
You think you can manage to create it this way?