* All apps: fix custom-field display for date-time and custom data_format like YmdHi

This commit is contained in:
Ralf Becker 2019-03-28 19:12:29 +01:00
parent 566f853900
commit 582231ecfc
2 changed files with 15 additions and 3 deletions

View File

@ -493,11 +493,11 @@ var et2_customfields_list = (function(){ "use strict"; return et2_valueWidget.ex
}, },
_setup_date: function(field_name, field, attrs) { _setup_date: function(field_name, field, attrs) {
attrs.data_format = 'Y-m-d'; attrs.data_format = field.values && field.values.format ? field.values.format : 'Y-m-d';
return true; return true;
}, },
_setup_date_time: function(field_name, field, attrs) { _setup_date_time: function(field_name, field, attrs) {
attrs.data_format = 'Y-m-d H:i:s'; attrs.data_format = field.values && field.values.format ? field.values.format : 'Y-m-d H:i:s';
return true; return true;
}, },
_setup_htmlarea: function(field_name, field, attrs) { _setup_htmlarea: function(field_name, field, attrs) {

View File

@ -1055,9 +1055,21 @@ var et2_date_ro = (function(){ "use strict"; return et2_valueWidget.extend([et2_
this.date = new Date(_value); this.date = new Date(_value);
this.date = new Date(this.date.valueOf() + (this.date.getTimezoneOffset()*60*1000)); this.date = new Date(this.date.valueOf() + (this.date.getTimezoneOffset()*60*1000));
} }
else if(typeof _value == 'string' && isNaN(_value)) else if(typeof _value == 'string' && (isNaN(_value) ||
this.options.data_format && this.options.data_format.substr(0,3) === 'Ymd'))
{ {
try { try {
// data_format is not handled server-side for custom-fields in nextmatch
// as parseDateTime requires a separate between date and time, we fix the value here
switch (this.options.data_format)
{
case 'Ymd':
case 'YmdHi':
case 'YmdHis':
_value = _value.substr(0, 4)+'-'+_value.substr(4, 2)+'-'+_value.substr(6, 2)+' '+
(_value.substr(8, 2) || '00')+':'+(_value.substr(10, 2) || '00')+':'+(_value.substr(12, 2) || '00');
break;
}
// parseDateTime to handle string PHP: DateTime local date/time format // parseDateTime to handle string PHP: DateTime local date/time format
var parsed = (typeof jQuery.datepicker.parseDateTime("yy-mm-dd","hh:mm:ss", _value) !='undefined')? var parsed = (typeof jQuery.datepicker.parseDateTime("yy-mm-dd","hh:mm:ss", _value) !='undefined')?
jQuery.datepicker.parseDateTime("yy-mm-dd","hh:mm:ss", _value): jQuery.datepicker.parseDateTime("yy-mm-dd","hh:mm:ss", _value):