commit 44d2a86a56bd1a09911d712ed0c2df26a4757b5e
Author: Szelenyi Tamas <tamas@szelenyi.hu>
Date:   Wed Mar 21 16:13:27 2012 +0100

    locale date usage added

diff --git a/booking_formlet/availability_calendar_booking_formlet.js b/booking_formlet/availability_calendar_booking_formlet.js
index da734fc..773b08c 100644
--- a/booking_formlet/availability_calendar_booking_formlet.js
+++ b/booking_formlet/availability_calendar_booking_formlet.js
@@ -13,7 +13,7 @@
  *   The id of the formlet instance that this object instance is linked to.
  * @see AvailabilityCalendars API object.
  */
-Drupal.availabilityCalendar.BookingFormlet = function(cids, bookedState, instanceId) {
+Drupal.availabilityCalendar.BookingFormlet = function(cids, bookedState, instanceId, dateFormat) {
   var cid = null;
   var calendarLabel = null;
   var from = null;
@@ -141,7 +141,7 @@ Drupal.availabilityCalendar.BookingFormlet = function(cids, bookedState, instanc
     }
     else {
       $('.acbf-arrival', instanceId)
-        .val(from.toFormattedString('dd-mm-yyyy'))
+        .val(from.toFormattedString(dateFormat))
         .removeAttr('disabled')
         .removeClass('form-button-disabled');
       if (to === null) {
@@ -156,7 +156,7 @@ Drupal.availabilityCalendar.BookingFormlet = function(cids, bookedState, instanc
       else {
         var showTo = new Date(to.getFullYear(), to.getMonth(), to.getDate() + 1);
         $('.acbf-departure', instanceId)
-          .val(showTo.toFormattedString('dd-mm-yyyy'))
+          .val(showTo.toFormattedString(dateFormat))
           .removeAttr('disabled')
           .removeClass('form-button-disabled');
         $('.acbf-reset-from', instanceId).css('display', 'none');
diff --git a/booking_formlet/availability_calendar_booking_formlet.module b/booking_formlet/availability_calendar_booking_formlet.module
index 155ef50..88223f5 100644
--- a/booking_formlet/availability_calendar_booking_formlet.module
+++ b/booking_formlet/availability_calendar_booking_formlet.module
@@ -359,9 +359,12 @@ function availability_calendar_booking_formlet_form($form_id, $form_state) {
     array('type' => 'file')
   );
   $cids = implode(',', $cids);
+  
+  $date_locale_converted = availability_calendar_booking_formlet_date_format_converter(locale_get_localized_date_format($language));
+  
   drupal_add_js("Drupal.behaviors.availabilityCalendarBookingFormlet$formlet_count = {
       attach: function(context, settings) {
-        Drupal.availabilityCalendar.bookingFormlet$formlet_count = new Drupal.availabilityCalendar.BookingFormlet([$cids], {$settings['booked_state']}, '#{$form['#id']}');
+        Drupal.availabilityCalendar.bookingFormlet$formlet_count = new Drupal.availabilityCalendar.BookingFormlet([$cids], {$settings['booked_state']}, '#{$form['#id']}', '{$date_locale_converted}');
       }
     };",
     array('type' => 'inline', 'scope' => 'footer')
@@ -370,3 +373,24 @@ function availability_calendar_booking_formlet_form($form_id, $form_state) {
 
   return $form;
 }
+
+
+/**
+ * Convert the localized short date format pattern for JavaScript (eg. Y-m-d -> yyyy-mm-dd, or d/m/Y -> dd/mm/yyyy).
+ *
+ * @param $date_format_locale
+ *   The original localized date format.
+ * @return 
+ *   The converted date format string string.
+ */
+function availability_calendar_booking_formlet_date_format_converter($date_format_locale) {
+  $converted_date = $date_format_locale['date_format_short'];
+  //Cut out the 'year-month-day' part of the pattern
+  $converted_date = preg_replace('#(.*)([YyFmMndDjl]{1}[\.\s-/,]*[YyFmMndDjl]{1}[\.\s-/,]*[YyFmMndDjl]{1}[\.]?)(.*)#', '$2', $converted_date);
+  //Change the 'year' part to yyyy and the 'month' part to 'mm' and the 'day' part to 'dd'
+  $from = array('#y#','#Y#','#m#','#M#','#F#','#n#','#d#','#D#','#j#','#l#');
+  $to = array('yyyy','yyyy','mm','mm','mm','mm','dd','dd','dd');
+  $converted_date = preg_replace($from, $to, $converted_date);
+  
+  return $converted_date;
+}
\ No newline at end of file
