Hi Adam,
Ich hab mal versucht ein eigenes Format für das Plugin zu schreiben.
Dabei bin ich nach der Anleitung aus der Doku
(Google Code Archive - Long-term storage for Google Code Project Hosting.
) vorgegangen. Da ich derzeit leider kein Projekt zur Hand habe mit
dem ich das testen kann, kann ich dir auch nicht sagen, ob sich nicht
doch ein Fehler eingeschlichen hat. Probiers mal aus und sag bitte
Bescheid, wenn’s klappt oder auch nicht klappt 
Schritt 1: Das hier in die environment.rb
CalendarDateSelect::FORMATS[:german_custom] = {
Here’s the code to pass to Date#strftime
:date => “%d.%m.%Y”,
:time => " %H:%M", # notice the space before time. If you want
date and time to be seperated with a space, put the leading space here.
:javascript_include => “german_custom”
}
Schritt 2: das hier in eine neue js-datei: /public/javascripts/
calendar_date_select/german_custom.js
Date.prototype.toFormattedString = function(include_time)
{
str = Date.padded2(this.getDate()) + “.” +
Date.padded2(this.getMonth() + 1) + “.” + this.getFullYear();
if (include_time) { str += " " + this.getHours() + “:” +
this.getPaddedMinutes() }
return str;
}
Date.parseFormattedString = function(string)
{
var regexp = ‘([0-9]{1,2}).(([0-9]{1,2}).(([0-9]{4})( ([0-9]
{1,2}):([0-9]{2})? *)?)?)?’;
var d = string.match(new RegExp(regexp, “i”));
if (d==null) return Date.parse(string); // at least give
javascript a crack at it.
var offset = 0;
var date = new Date(d[5], 0, 1);
if (d[3]) { date.setMonth(d[3] - 1); }
if (d[5]) { date.setDate(d[1]); }
if (d[7]) {
date.setHours(parseInt(d[7], 10));
}
if (d[8]) { date.setMinutes(d[8]); }
if (d[10]) { date.setSeconds(d[10]); }
return date;
}
Schritt 3: dann das plugin in der environment.rb so konfigurieren
(muss unterhalb des Codes von Schritt eins stehen)
CalendarDateSelect.format = :german_custom
WICHTIG: <%= calendar_date_select_includes %> muss in deinem layout-
template im header auftauchen! Sonst funzt der Spaß nicht.
Schöne Grüße,
Benjamin
Am 16.02.2009 um 23:01 schrieb Adam M.: