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?

CommentFileSizeAuthor
#6 using_date_in_other_formats-1413130-6.patch3.91 KBszt

Comments

fietserwin’s picture

Version: 7.x-3.2 » 7.x-3.x-dev
Category: support » feature

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!

pietrocap’s picture

Maybe the best choice is letting the user change or localize it in admin/config/regional/date-time/...

gynekolog’s picture

It does not work.

fietserwin’s picture

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)

gynekolog’s picture

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';

szt’s picture

Status: Active » Needs review
StatusFileSize
new3.91 KB

A possible solution using localized date patterns.
It converts a simple pattern from the date_format_short pattern.
Please test it.

fietserwin’s picture

Status: Needs review » Needs work

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.

szt’s picture

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.

fietserwin’s picture

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:

  1. Define our own date types, e.g. availability calendar booking formlet date and availability calendar availability search date (ugly but precise) and have an admin define the formats for those (per locale)
  2. Have an admin choose from the list of available date types (thus the list as you can see in admin/config/regional/date-time/types) to use on the booking formlet and to use in a view. This selection is, IMO, to be done in the field display form resp. view filter definition form.

You think you can manage to create it this way?

fietserwin’s picture

Assigned: Unassigned » fietserwin

Assigning to myself as to create a todo list for 7.x-3.3. So this will get a solution in the next version.

fietserwin’s picture

Status: Needs work » Fixed

I ended up doing this in a big update:
- Define date formats via the Drupal built in date types (admin/config/regional/date-time).
- Localize these date types in admin/config/regional/date-time/locale.
- Use these date types where needed (Views integration to search on availability, Booking formlet)
- Use the jquery.ui.datepicker.formatDate() function.
- So I had to define a conversion from PHP formatters to datepicker formats.

fietserwin’s picture

Assigned: fietserwin » Unassigned

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

correction of a wrong word.