From 60362bf3c94df9c4682da530e0891626a684e46d Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 16 Mar 2019 11:04:24 +0300 Subject: [PATCH 1/2] Update datetime-moment plugin. Add a Boolean parameter that allows to invert the order of empty values. --- sorting/datetime-moment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sorting/datetime-moment.js b/sorting/datetime-moment.js index ae0cce57..1f12b13b 100644 --- a/sorting/datetime-moment.js +++ b/sorting/datetime-moment.js @@ -28,7 +28,7 @@ } }(function ($, moment) { -$.fn.dataTable.moment = function ( format, locale ) { +$.fn.dataTable.moment = function ( format, reverseEmpties, locale ) { var types = $.fn.dataTable.ext.type; // Add type detection @@ -66,7 +66,7 @@ $.fn.dataTable.moment = function ( format, locale ) { } return !moment(d, format, locale, true).isValid() ? - Infinity : + (reverseEmpties ? -Infinity : Infinity) : parseInt( moment( d, format, locale, true ).format( 'x' ), 10 ); }; }; From 61dfc198c2593f36daac834cbb5e93c2cbd227af Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 16 Mar 2019 17:52:57 +0300 Subject: [PATCH 2/2] Move the parameter to the end of the function. Move the parameter to the end of the function for backward compatibility purposes. --- sorting/datetime-moment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sorting/datetime-moment.js b/sorting/datetime-moment.js index 1f12b13b..f937531b 100644 --- a/sorting/datetime-moment.js +++ b/sorting/datetime-moment.js @@ -28,7 +28,7 @@ } }(function ($, moment) { -$.fn.dataTable.moment = function ( format, reverseEmpties, locale ) { +$.fn.dataTable.moment = function ( format, locale, reverseEmpties ) { var types = $.fn.dataTable.ext.type; // Add type detection