Subversion-Projekte lars-tiefland.faltradxxs.de

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 1
/**
2
 * Similar to the Date (dd/mm/YY) data sorting plug-in, this plug-in offers
3
 * additional  flexibility with support for spaces between the values and
4
 * either . or / notation for the separators.
5
 *
6
 * Please note that this plug-in is **deprecated*. The
7
 * [datetime](//datatables.net/blog/2014-12-18) plug-in provides enhanced
8
 * functionality and flexibility.
9
 *
10
 *  @name Date (dd . mm[ . YYYY])
11
 *  @summary Sort dates in the format `dd/mm/YY[YY]` (with optional spaces)
12
 *  @author [Robert Sedovšek](http://galjot.si/)
13
 *  @deprecated
14
 *
15
 *  @example
16
 *    $('#example').dataTable( {
17
 *       columnDefs: [
18
 *         { type: 'date-eu', targets: 0 }
19
 *       ]
20
 *    } );
21
 */
22
 
23
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
24
	"date-eu-pre": function ( date ) {
25
		date = date.replace(" ", "");
26
 
27
		if ( ! date ) {
28
			return 0;
29
		}
30
 
31
		var year;
32
		var eu_date = date.split(/[\.\-\/]/);
33
 
34
		/*year (optional)*/
35
		if ( eu_date[2] ) {
36
			year = eu_date[2];
37
		}
38
		else {
39
			year = 0;
40
		}
41
 
42
		/*month*/
43
		var month = eu_date[1];
44
		if ( month.length == 1 ) {
45
			month = 0+month;
46
		}
47
 
48
		/*day*/
49
		var day = eu_date[0];
50
		if ( day.length == 1 ) {
51
			day = 0+day;
52
		}
53
 
54
		return (year + month + day) * 1;
55
	},
56
 
57
	"date-eu-asc": function ( a, b ) {
58
		return ((a < b) ? -1 : ((a > b) ? 1 : 0));
59
	},
60
 
61
	"date-eu-desc": function ( a, b ) {
62
		return ((a < b) ? 1 : ((a > b) ? -1 : 0));
63
	}
64
} );