1/** 2 * This plug-in for DataTables represents the ultimate option in extensibility 3 * for sorting date / time strings correctly. It uses 4 * [Moment.js](http://momentjs.com) to create automatic type detection and 5 * sorting plug-ins for DataTables based on a given format. This way, DataTables 6 * will automatically detect your temporal information and sort it correctly. 7 * 8 * For usage instructions, please see the DataTables blog 9 * post that [introduces it](//datatables.net/blog/2014-12-18). 10 * 11 * @name Ultimate Date / Time sorting 12 * @summary Sort date and time in any format using Moment.js 13 * @author [Allan Jardine](//datatables.net) 14 * @depends DataTables 1.10+, Moment.js 1.7+ 15 * 16 * @example 17 * jQuery.fn.dataTable.moment( 'HH:mm MMM D, YY' ); 18 * jQuery.fn.dataTable.moment( 'dddd, MMMM Do, YYYY' ); 19 * 20 * $('#example').DataTable(); 21 */ 22 23(function (factory) { 24 if (typeof define === 'function' && define.amd) { 25 define(['jquery', 'moment', 'datatables.net'], factory); 26 } else { 27 if (typeof jQuery === 'undefined' || typeof moment === 'undefined' || !jQuery.fn || !jQuery.fn.dataTable) { 28 return; 29 } 30 factory(jQuery, moment); 31 } 32})(function (jQuery, moment) { 33 jQuery.fn.dataTable.moment = function (format, locale, reverseEmpties) { 34 var types = jQuery.fn.dataTable.ext.type; 35 36 // Add type detection 37 types.detect.unshift(function (d) { 38 if (d) { 39 // Strip HTML tags and newline characters if possible 40 if (d.replace) { 41 d = d.replace(/(<.*?>)|(\r?\n|\r)/g, ''); 42 } 43 44 // Strip out surrounding white space 45 d = jQuery.trim(d); 46 } 47 48 // Null and empty values are acceptable 49 if (d === '' || d === null) { 50 return 'moment-' + format; 51 } 52 53 return moment(d, format, locale, true).isValid() ? 'moment-' + format : null; 54 }); 55 56 // Add sorting method - use an integer for the sorting 57 types.order['moment-' + format + '-pre'] = function (d) { 58 if (d) { 59 // Strip HTML tags and newline characters if possible 60 if (d.replace) { 61 d = d.replace(/(<.*?>)|(\r?\n|\r)/g, ''); 62 } 63 64 // Strip out surrounding white space 65 d = jQuery.trim(d); 66 } 67 68 return !moment(d, format, locale, true).isValid() ? (reverseEmpties ? -Infinity : Infinity) : parseInt(moment(d, format, locale, true).format('x'), 10); 69 }; 70 }; 71});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.