Here is a simplified version of the script that does our calendar format:
- startDay: start day for calender picker (starts on sunday for us, starts on monday for iso)
- format: date format for display (differs)
- emptyText: empty hint text for date fields
- altFormats: input formats (the different formats that can be typed in a date field)
Code:
<?php
...
$bUseIsoCalendar = TRUE / FALSE;
$strCalendarStartDay = ($bUseIsoCalendar ? "1" : "0");
// n = month with optional leading zeroes; j = day of month with optional leading zeroes
$strDateFormat = ($bUseIsoCalendar ? "d/m/Y" : "m/d/Y");
$strDateFormatAlt = ($bUseIsoCalendar ? "j/n/Y|j-n-y|j-n-Y|j/n|j-n|dm|dmy|dmY|d|Y-n-j" : "n/j/Y|n-j-y|n-j-Y|n/j|n-j|md|mdy|mdY|d|Y-n-j");
$strDateEmpty = ($bUseIsoCalendar ? "dd/mm/yyyy" : "mm/dd/yyyy");
?>
if(Ext.util.Format){
Ext.util.Format.date = function(v, format){
if(!v) return "";
if(!(v instanceof Date)) v = new Date(Date.parse(v));
return v.dateFormat(format || <?php echo json_encode($strDateFormat); ?>);
};
}
if(Ext.DatePicker){
Ext.apply(Ext.DatePicker.prototype, {
format : <?php echo json_encode($strDateFormat); ?>,
startDay : <?php echo strval($strCalendarStartDay); ?>
});
}
if(Ext.form.DateField){
Ext.apply(Ext.form.DateField.prototype, {
emptyText : <?php echo json_encode($strDateEmpty);?>,
format : <?php echo json_encode($strDateFormat); ?>,
altFormats : <?php echo json_encode($strDateFormatAlt); ?>,
startDay : <?php echo strval($strCalendarStartDay); ?>
});
}