|
|
@ -29,13 +29,11 @@
|
|
|
|
}(function ($, luxon) {
|
|
|
|
}(function ($, luxon) {
|
|
|
|
|
|
|
|
|
|
|
|
function strip (d) {
|
|
|
|
function strip (d) {
|
|
|
|
if ( typeof d === 'string' ) {
|
|
|
|
// Strip HTML tags and newline characters if possible
|
|
|
|
// Strip HTML tags and newline characters if possible
|
|
|
|
d = d.replace(/(<.*?>)|(\r?\n|\r)/g, '');
|
|
|
|
d = d.replace(/(<.*?>)|(\r?\n|\r)/g, '');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Strip out surrounding white space
|
|
|
|
// Strip out surrounding white space
|
|
|
|
d = d.trim();
|
|
|
|
d = d.trim();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return d;
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -45,25 +43,37 @@ $.fn.dataTable.luxon = function ( format, locale, reverseEmpties ) {
|
|
|
|
|
|
|
|
|
|
|
|
// Add type detection
|
|
|
|
// Add type detection
|
|
|
|
types.detect.unshift( function ( d ) {
|
|
|
|
types.detect.unshift( function ( d ) {
|
|
|
|
d = strip(d);
|
|
|
|
// Null values are acceptable
|
|
|
|
|
|
|
|
if ( d === null ) {
|
|
|
|
// Null and empty values are acceptable
|
|
|
|
|
|
|
|
if ( d === '' || d === null ) {
|
|
|
|
|
|
|
|
return 'luxon-'+format;
|
|
|
|
return 'luxon-'+format;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( typeof d === 'string' ) {
|
|
|
|
|
|
|
|
d = strip(d);
|
|
|
|
|
|
|
|
|
|
|
|
return luxon.DateTime.fromFormat( d, format).isValid ?
|
|
|
|
// Empty values are acceptable
|
|
|
|
'luxon-'+format :
|
|
|
|
if ( d === '' ) {
|
|
|
|
null;
|
|
|
|
return 'luxon-'+format;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return luxon.DateTime.fromFormat( d, format).isValid ?
|
|
|
|
|
|
|
|
'luxon-'+format :
|
|
|
|
|
|
|
|
null;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
|
|
// Add sorting method - use an integer for the sorting
|
|
|
|
// Add sorting method - use an integer for the sorting
|
|
|
|
types.order[ 'luxon-'+format+'-pre' ] = function ( d ) {
|
|
|
|
types.order[ 'luxon-'+format+'-pre' ] = function ( d ) {
|
|
|
|
d = strip(d);
|
|
|
|
if ( typeof d === 'string' ) {
|
|
|
|
|
|
|
|
d = strip(d);
|
|
|
|
return !luxon.DateTime.fromFormat(d, format).isValid ?
|
|
|
|
|
|
|
|
(reverseEmpties ? -Infinity : Infinity) :
|
|
|
|
return !luxon.DateTime.fromFormat(d, format).isValid ?
|
|
|
|
parseInt( luxon.DateTime.fromFormat( d, format).ts, 10 );
|
|
|
|
(reverseEmpties ? -Infinity : Infinity) :
|
|
|
|
|
|
|
|
parseInt( luxon.DateTime.fromFormat( d, format).ts, 10 );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|