PageSourceSearch

https://onlineservice.eins.de/powercommerce/eins/fo/portal/resourc…/jquery/jquery.dataTables-moment.min.js

js eins.de collected 2026-10-01 14:39:30 UTC 2,048 bytes, 70 lines download raw bytes

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 *    $.fn.dataTable.moment( 'HH:mm MMM D, YY' );
18 *    $.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		factory(jQuery, moment);
28	}
29}(function ($, moment) {
30
31function strip (d) {
32	if ( typeof d === 'string' ) {
33		// Strip HTML tags and newline characters if possible
34		d = d.replace(/(<.*?>)|(\r?\n|\r)/g, '');
35
36		// Strip out surrounding white space
37		d = d.trim();
38	}
39
40	return d;
41}
42
43$.fn.dataTable.moment = function ( format, locale, reverseEmpties ) {
44	var types = $.fn.dataTable.ext.type;
45
46	// Add type detection
47	types.detect.unshift( function ( d ) {
48		d = strip(d);
49
50		// Null and empty values are acceptable
51		if ( d === '' || d === null ) {
52			return 'moment-'+format;
53		}
54
55		return moment( d, format, locale, true ).isValid() ?
56			'moment-'+format :
57			null;
58	} );
59
60	// Add sorting method - use an integer for the sorting
61	types.order[ 'moment-'+format+'-pre' ] = function ( d ) {
62		d = strip(d);
63		
64		return !moment(d, format, locale, true).isValid() ?
65			(reverseEmpties ? -Infinity : Infinity) :
66			parseInt( moment( d, format, locale, true ).format( 'x' ), 10 );
67	};
68};
69
70}));

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.